
=head1 NAME

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

=head1 VERSION

0.19_8. Development release.

=head1 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');

=head1 DESCRIPTION

B<SQL::DBx::Deploy> adds deployment support to L<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. B<You can only ever add new statements to
your deploy module>.

=head1 METHODS

=over 4

=item deploy($app)

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

=item last_deploy_id( $app )

Returns the count of all deployment statements.

=back

=head1 SEE ALSO

L<SQL::DB>, L<Moo::Role>

=head1 AUTHOR

Mark Lawrence E<lt>nomad@null.netE<gt>

=head1 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.

