yet another untested howto
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionStorage / Standard.pm
1 package DBIx::Class::DeploymentHandler::VersionStorage::Standard;
2 use Moose;
3 use Method::Signatures::Simple;
4
5 has schema => (
6   isa      => 'DBIx::Class::Schema',
7   is       => 'ro',
8   required => 1,
9 );
10
11 has version_rs => (
12   isa        => 'DBIx::Class::ResultSet',
13   is         => 'ro',
14   lazy_build => 1,
15   handles    => [qw( database_version version_storage_is_installed )],
16 );
17
18 with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage';
19
20 sub _build_version_rs {
21   $_[0]->schema->register_class(
22     __VERSION =>
23       'DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult'
24   );
25   $_[0]->schema->resultset('__VERSION')
26 }
27
28 sub add_database_version { $_[0]->version_rs->create($_[1]) }
29
30 sub delete_database_version {
31   $_[0]->version_rs->search({ version => $_[1]->{version}})->delete
32 }
33
34 __PACKAGE__->meta->make_immutable;
35
36 1;
37
38 __END__
39
40 =head1 THIS SUCKS
41
42 You started your project and weren't using DBICDH?  FOOL!  Lucky for you I had
43 you in mind when I wrote this doc <3
44
45 First off, you'll want to just install the version_storage:
46
47  my $s = My::Schema->connect(...);
48  my $dh = DeployHandler({ schema => $s });
49
50  $dh->prepare_version_storage_install;
51  $dh->install_version_storage;
52
53 Then, bump your schema version, and you can use DBICDH like normal!
54
55 vim: ts=2 sw=2 expandtab