From: Arthur Axel 'fREW' Schmidt Date: Tue, 30 Mar 2010 06:53:23 +0000 (-0500) Subject: some initial (untested) migration doc X-Git-Tag: v0.001000_01~23 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3885a58b2ce7c1acbeb4896f82c7a5880eabed7a;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git some initial (untested) migration doc --- diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/Deprecated.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/Deprecated.pm index 19a7370..72a4939 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/Deprecated.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/Deprecated.pm @@ -7,7 +7,7 @@ use File::Spec::Functions; extends 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator', method _ddl_schema_consume_filenames($type, $version) { - return [$self->_ddl_schema_produce_filename($type, $version)] + return [$self->_ddl_schema_produce_filename($type, $version)] } method _ddl_schema_produce_filename($type, $version) { @@ -33,9 +33,32 @@ method _ddl_schema_up_produce_filename($type, $versions, $dir) { } method _ddl_schema_up_consume_filenames($type, $versions) { - return [$self->_ddl_schema_up_produce_filename($type, $versions)] + return [$self->_ddl_schema_up_produce_filename($type, $versions)] } __PACKAGE__->meta->make_immutable; 1; + +__END__ + +=head1 THIS SUCKS + +Yeah, this old Deprecated thing is a drag. It can't do downgrades, it can only +use a single .sql file for migrations, it has no .pl support. You should +totally switch! Here's how: + + my $init_part = ref $schema; + $init_part =~ s/::/-/g; + opendir my $dh, 'sql'; + for (readdir $dh) { + if (/\Q$init_part\E-(.*)-(.*)(?:-(.*))?/) { + if (defined $3) { + cp $_, $dh->deploy_method->_ddl_schema_up_produce_filename($3, [$1, $2]); + } else { + cp $_, $dh->deploy_method->_ddl_schema_produce_filename($2, $1); + } + } + } + +vim: ts=2 sw=2 expandtab diff --git a/lib/DBIx/Class/DeploymentHandler/VersionStorage/Deprecated.pm b/lib/DBIx/Class/DeploymentHandler/VersionStorage/Deprecated.pm index 282bf49..44c7a3d 100644 --- a/lib/DBIx/Class/DeploymentHandler/VersionStorage/Deprecated.pm +++ b/lib/DBIx/Class/DeploymentHandler/VersionStorage/Deprecated.pm @@ -41,4 +41,24 @@ __PACKAGE__->meta->make_immutable; __END__ +=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; + vim: ts=2 sw=2 expandtab