NAME

SQL::DBx::Deploy - Deployment support for SQL::DB

VERSION

0.19_10. Development release.

SYNOPSIS

package MyApp::Deploy::SQLite;
1;

# Only ever ADD lines to this file. Never delete them!

__DATA__
- sql: |
    CREATE TABLE actors (
        id integer primary key,
        name varchar
    )

- sql: |
    CREATE TABLE films (
        id integer primary key,
        title varchar
    )

- perl: |
    print "Perl sections are eval'd\n";

- sql: |
    CREATE TABLE film_actors (
        actor_id integer references actors(id),
        film_id integer references films(id),
        primary key (actor_id,film_id)
    )


# In your code somewhere else
use SQL::DB;
use SQL::DBx::Deploy;

my $db = SQL::DB->connect('dbi:SQLite:dbname=test');

# The '::Deploy::SQLite' part is auto appended
$db->deploy('MyApp');

# Multiple calls are safe
$db->deploy('MyApp');

DESCRIPTION

SQL::DBx::Deploy adds deployment support to SQL::DB. Your SQL and Perl statements (formatted as YAML) are included in the __DATA__ section of a Perl module. Calls to deploy() will load that module and run any statements contained inside that have not already been applied to the database. SQL::DBx::Deploy keeps track of what has been run through a table in your database called '_deploy'.

Note that the approach is very simple, based on the number of statements already executed. You can only ever add new statements to your deploy module.

METHODS

deploy($app)

Deploy the YAML found in the __DATA__ section of the $app::Deploy::$driver module.

last_deploy_id( $app )

Returns the count of all deployment statements.

SEE ALSO

SQL::DB, Moo::Role

AUTHOR

Mark Lawrence <nomad@null.net>

COPYRIGHT AND LICENSE

Copyright (C) 2011 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.