1ORLite::Migrate(3)    User Contributed Perl Documentation   ORLite::Migrate(3)
2
3
4

NAME

6       ORLite::Migrate - Extremely light weight SQLite-specific schema
7       migration
8

SYNOPSIS

10         # Build your ORM class using a patch timeline
11         # stored in the shared files directory.
12         use ORLite::Migrate {
13             create       => 1,
14             file         => 'sqlite.db',
15             timeline     => File::Spec->catdir(
16                 File::ShareDir::module_dir('My::Module'), 'patches',
17             ),
18             user_version => 8,
19         };
20
21         # migrate-1.pl - A trivial schema patch
22         #!/usr/bin/perl
23
24         use strict;
25         use DBI ();
26
27         # Locate the SQLite database
28         my $file = <STDIN>;
29         chomp($file);
30         unless ( -f $file and -w $file ) {
31             die "SQLite file $file does not exist";
32         }
33
34         # Connect to the SQLite database
35         my $dbh = DBI->connect("dbi:SQLite(RaiseError=>1):$file");
36         unless ( $dbh ) {
37           die "Failed to connect to $file";
38         }
39
40         $dbh->do( <<'END_SQL' );
41         create table foo (
42             id integer not null primary key,
43             name varchar(32) not null
44         )
45         END_SQL
46

DESCRIPTION

48       THIS CODE IS EXPERIMENTAL AND SUBJECT TO CHANGE WITHOUT NOTICE
49
50       YOU HAVE BEEN WARNED!
51
52       SQLite is a light weight single file SQL database that provides an
53       excellent platform for embedded storage of structured data.
54
55       ORLite is a light weight single class Object-Relational Mapper (ORM)
56       system specifically designed for (and limited to only) work with
57       SQLite.
58
59       ORLite::Migrate is a light weight single class Database Schema
60       Migration enhancement for ORLite.
61
62       It provides a simple implementation of schema versioning within the
63       SQLite database using the built-in "user_version" pragma (which is set
64       to zero by default).
65
66       When setting up the ORM class, an additional "timeline" parameter is
67       provided, which should point to a directory containing standalone
68       migration scripts.
69
70       These patch scripts are named in the form migrate-$version.pl, where
71       $version is the schema version to migrate to. A typical timeline
72       directory will look something like the following.
73
74         migrate-01.pl
75         migrate-02.pl
76         migrate-03.pl
77         migrate-04.pl
78         migrate-05.pl
79         migrate-06.pl
80         migrate-07.pl
81         migrate-08.pl
82         migrate-09.pl
83         migrate-10.pl
84
85       ORLite::Migrate formulates a migration plan, it will start with the
86       current database "user_version", and then step forwards looking for a
87       migration script that has the version "user_version + 1".
88
89       It will continue stepping forwards until it runs out of patches to
90       execute.
91
92       If ORLite::Migrate is also invoked with a "user_version" param (to
93       ensure the schema matches the code correctly) the plan will be checked
94       in advance to ensure that the migration will end at the value specified
95       by the "user_version" param.
96
97       Because the migration plan can be calculated from any arbitrary
98       starting version, it is possible for any user of an older application
99       version to install the most current version of an application and be
100       ugraded safely.
101
102       The recommended location to store the migration timeline is a shared
103       files directory, locatable using one of the functions from
104       File::ShareDir.
105

SUPPORT

107       Bugs should be reported via the CPAN bug tracker at
108
109       http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ORLite-Migrate
110       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ORLite-Migrate>
111
112       For other issues, contact the author.
113

AUTHOR

115       Adam Kennedy <adamk@cpan.org>
116
118       Copyright 2009 Adam Kennedy.
119
120       This program is free software; you can redistribute it and/or modify it
121       under the same terms as Perl itself.
122
123       The full text of the license can be found in the LICENSE file included
124       with this module.
125
126
127
128perl v5.12.0                      2010-05-04                ORLite::Migrate(3)
Impressum