Port to Moo
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionStorage / Deprecated.pm
index 385d070..d5d2394 100644 (file)
@@ -1,22 +1,26 @@
-package DBIx::Class::DeploymentHandler::VersionStorage::Standard;
-use Moose;
-use Method::Signatures::Simple;
+package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated;
+use Moo;
+use Sub::Quote 'quote_sub';
+use DBIx::Class::DeploymentHandler::LogImporter ':log';
+use DBIx::Class::DeploymentHandler::Types 'ResultSet';
+
+# ABSTRACT: (DEPRECATED) Use this if you are stuck in the past
 
 has schema => (
-  isa      => 'DBIx::Class::Schema',
   is       => 'ro',
   required => 1,
 );
 
 has version_rs => (
-  isa        => 'DBIx::Class::ResultSet',
+  isa        => ResultSet,
   is         => 'ro',
-  lazy_build => 1,
+  builder    => '_build_version_rs',
   handles    => [qw( database_version version_storage_is_installed )],
 );
 
 with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage';
 
+use DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult;
 sub _build_version_rs {
   $_[0]->schema->register_class(
     dbix_class_schema_versions =>
@@ -27,13 +31,55 @@ sub _build_version_rs {
 
 sub add_database_version {
   # deprecated doesn't support ddl or upgrade_ddl
-  $_[0]->version_rs->create({ version => $_[1]->{version} })
+  my $version = $_[1]->{version};
+  log_debug { "Adding database version $version" };
+  $_[0]->version_rs->create({ version => $version })
 }
 
-__PACKAGE__->meta->make_immutable;
+sub delete_database_version {
+  my $version = $_[1]->{version};
+  log_debug { "Deleting database version $version" };
+  $_[0]->version_rs->search({ version => $version})->delete
+}
 
 1;
 
+# vim: ts=2 sw=2 expandtab
+
 __END__
 
-vim: ts=2 sw=2 expandtab
+=head1 DEPRECATED
+
+I begrudgingly made this module (and other related modules) to keep porting
+from L<DBIx::Class::Schema::Versioned> relatively simple.  I will make changes
+to ensure that it works with output from L<DBIx::Class::Schema::Versioned> etc,
+but I will not add any new features to it.
+
+Once I hit major version 1 usage of this module will emit a warning.
+On version 2 it will be removed entirely.
+
+=head1 THIS SUCKS
+
+Here's how to convert from that crufty old Deprecated VersionStorage to a shiny
+new Standard VersionStorage:
+
+ my $s  = My::Schema->connect(...);
+ my $dh = DeploymentHandler({
+   schema => $s,
+ });
+
+ $dh->prepare_version_storage_install;
+ $dh->install_version_storage;
+
+ my @versions = $s->{vschema}->resultset('Table')->search(undef, {
+   order_by => 'installed',
+ })->get_column('version')->all;
+
+ $dh->version_storage->add_database_vesion({ version => $_ })
+   for @versions;
+
+=head1 SEE ALSO
+
+This class is an implementation of
+L<DBIx::Class::DeploymentHandler::HandlesVersionStorage>.  Pretty much all the
+documentation is there.