SQLT DH should be copying schema_version
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionStorage / Deprecated.pm
CommitLineData
fe3b6dff 1package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated;
01342998 2use Moose;
9deabd1f 3
4# ABSTRACT: (DEPRECATED) Use this if you are stuck in the past
5
01342998 6use Method::Signatures::Simple;
7
8has schema => (
9 isa => 'DBIx::Class::Schema',
10 is => 'ro',
11 required => 1,
12);
13
14has version_rs => (
15 isa => 'DBIx::Class::ResultSet',
16 is => 'ro',
fe3b6dff 17 builder => '_build_version_rs',
01342998 18 handles => [qw( database_version version_storage_is_installed )],
19);
20
21with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage';
22
fe3b6dff 23use DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult;
01342998 24sub _build_version_rs {
25 $_[0]->schema->register_class(
26 dbix_class_schema_versions =>
27 'DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult'
28 );
29 $_[0]->schema->resultset('dbix_class_schema_versions')
30}
31
32sub add_database_version {
33 # deprecated doesn't support ddl or upgrade_ddl
34 $_[0]->version_rs->create({ version => $_[1]->{version} })
35}
36
f344dd91 37sub delete_database_version {
38 $_[0]->version_rs->search({ version => $_[1]->{version}})->delete
39}
40
01342998 41__PACKAGE__->meta->make_immutable;
42
431;
44
e52174e3 45# vim: ts=2 sw=2 expandtab
46
01342998 47__END__
48
bcc72297 49=head1 DEPRECATED
50
51I begrudgingly made this module (and other related modules) to keep porting
52from L<DBIx::Class::Schema::Versioned> relatively simple. I will make changes
53to ensure that it works with output from L<DBIx::Class::Schema::Versioned> etc,
54but I will not add any new features to it.
55
56Once I hit major version 1 usage of this module will emit a warning.
57On version 2 it will be removed entirely.
58
3885a58b 59=head1 THIS SUCKS
60
61Here's how to convert from that crufty old Deprecated VersionStorage to a shiny
62new Standard VersionStorage:
63
64 my $s = My::Schema->connect(...);
65 my $dh = DeploymentHandler({
66 schema => $s,
67 });
68
69 $dh->prepare_version_storage_install;
70 $dh->install_version_storage;
71
72 my @versions = $s->{vschema}->resultset('Table')->search(undef, {
73 order_by => 'installed',
74 })->get_column('version')->all;
75
76 $dh->version_storage->add_database_vesion({ version => $_ })
77 for @versions;
78