~ubuntu-branches/ubuntu/saucy/padre/saucy-proposed

« back to all changes in this revision

Viewing changes to lib/Padre/DB/Timeline.pm

  • Committer: Package Import Robot
  • Author(s): Dominique Dumont, gregor herrmann, Dominique Dumont
  • Date: 2012-01-04 12:04:20 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20120104120420-i5oybqwf91m1d3il
Tags: 0.92.ds1-1
[ gregor herrmann ]
* Remove debian/source/local-options; abort-on-upstream-changes
  and unapply-patches are default in dpkg-source since 1.16.1.
* Swap order of alternative (build) dependencies after the perl
  5.14 transition.

[ Dominique Dumont ]
* Imported Upstream version 0.92.ds1
* removed fix-spelling patch (applied upstream)
* lintian-override: use wildcard to avoid listing a gazillion files
* updated size of some 'not-real-man-page' entries
* rules: remove dekstop cruft (replaced by a file provided in debian
  directory)
* control: removed Breaks statement. Add /me to uploaders. Updated
  dependencies
* rules: make sure that non-DFSG file (i.e. the cute butterfly, sigh)
  is not distributed

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
use 5.008005;
6
6
use strict;
7
7
use warnings;
8
 
use DBI          ();
9
 
use DBD::SQLite  ();
10
 
use Params::Util ();
11
 
 
12
 
our $VERSION = '0.90';
13
 
 
14
 
 
15
 
 
16
 
 
17
 
 
18
 
######################################################################
19
 
# Constructor
20
 
 
21
 
sub new {
22
 
        my $class = shift;
23
 
        my $self = bless {@_}, $class;
24
 
 
25
 
        # Check the database handle
26
 
        unless ( Params::Util::_INSTANCE( $self->dbh, 'DBI::db' ) ) {
27
 
                die "Missing or invalid dbh database handle";
28
 
        }
29
 
        unless ( $self->dbh->{AutoCommit} ) {
30
 
                die "Database connection must be AutoCommit";
31
 
        }
32
 
 
33
 
        return $self;
34
 
}
35
 
 
36
 
sub dbh {
37
 
        $_[0]->{dbh};
38
 
}
39
 
 
40
 
 
41
 
 
42
 
 
43
 
 
44
 
#######################################################################
45
 
# Main Methods
46
 
 
47
 
sub upgrade {
48
 
        my $self = shift;
49
 
        my $want = Params::Util::_POSINT(shift);
50
 
        my $have = $self->user_version;
51
 
 
52
 
        # Roll the schema forwards
53
 
        while ( $want and $want > $have ) {
54
 
 
55
 
                # Find the migration step
56
 
                my $method = "upgrade" . ++$have;
57
 
                unless ( $self->can($method) ) {
58
 
                        die "No migration path to user_version $want";
59
 
                }
60
 
 
61
 
                # Run the migration step
62
 
                unless ( eval { $self->$method } ) {
63
 
                        die "Schema migration failed during $method: $@";
64
 
                }
65
 
 
66
 
                # Confirm completion
67
 
                $self->user_version($have);
68
 
        }
69
 
 
70
 
        return 1;
71
 
}
 
8
use ORLite::Migrate::Timeline ();
 
9
 
 
10
our $VERSION = '0.92';
 
11
our @ISA     = 'ORLite::Migrate::Timeline';
72
12
 
73
13
 
74
14
 
77
17
######################################################################
78
18
# Schema Migration (reverse chronological for readability)
79
19
 
 
20
sub upgrade12 {
 
21
        my $self = shift;
 
22
 
 
23
        # Create the debug breakpoints table
 
24
        $self->do(<<'END_SQL');
 
25
CREATE TABLE debug_breakpoints (
 
26
        id INTEGER NOT NULL PRIMARY KEY,
 
27
        filename VARCHAR(255) NOT NULL,
 
28
        line_number INTEGER NOT NULL,
 
29
        active BOOLEAN NOT NULL,
 
30
        last_used DATE
 
31
)
 
32
END_SQL
 
33
 
 
34
        return 1;
 
35
}
 
36
 
80
37
sub upgrade11 {
81
38
        my $self = shift;
82
39
 
350
307
        return 1;
351
308
}
352
309
 
353
 
 
354
 
 
355
 
 
356
 
 
357
 
######################################################################
358
 
# Support Methods
359
 
 
360
 
sub do {
361
 
        shift->dbh->do(@_);
362
 
}
363
 
 
364
 
sub selectall_arrayref {
365
 
        shift->dbh->selectall_arrayref(@_);
366
 
}
367
 
 
368
 
sub selectall_hashref {
369
 
        shift->dbh->selectall_hashref(@_);
370
 
}
371
 
 
372
 
sub selectcol_arrayref {
373
 
        shift->dbh->selectcol_arrayref(@_);
374
 
}
375
 
 
376
 
sub selectrow_array {
377
 
        shift->dbh->selectrow_array(@_);
378
 
}
379
 
 
380
 
sub selectrow_arrayref {
381
 
        shift->dbh->selectrow_arrayref(@_);
382
 
}
383
 
 
384
 
sub selectrow_hashref {
385
 
        shift->dbh->selectrow_hashref(@_);
386
 
}
387
 
 
388
 
sub user_version {
389
 
        shift->pragma( 'user_version', @_ );
390
 
}
391
 
 
392
 
sub pragma {
393
 
        $_[0]->do("pragma $_[1] = $_[2]") if @_ > 2;
394
 
        $_[0]->selectrow_arrayref("pragma $_[1]")->[0];
395
 
}
396
 
 
397
 
sub table_exists {
398
 
        $_[0]->selectrow_array(
399
 
                "select count(*) from sqlite_master where type = 'table' and name = ?",
400
 
                {}, $_[1],
401
 
        );
402
 
}
403
 
 
404
 
sub column_exists {
405
 
        $_[0]->table_exists( $_[1] )
406
 
                or $_[0]->selectrow_array( "select count($_[2]) from $_[1]", {} );
407
 
}
408
 
 
409
310
1;
410
311
 
411
312
# Copyright 2008-2011 The Padre development team as listed in Padre.pm.