X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F94versioning.t;h=3667c5282da200104f5a952f764b592dc3639b88;hb=2bf79155a8be1532cce2538e967f32c4ff22a87b;hp=86dd11bdcd3928071dc7899a89a8b343305ee33e;hpb=8424c090432d689f0776d11a07d37c48ce4ded74;p=dbsrgits%2FDBIx-Class.git diff --git a/t/94versioning.t b/t/94versioning.t index 86dd11b..3667c52 100644 --- a/t/94versioning.t +++ b/t/94versioning.t @@ -18,14 +18,18 @@ BEGIN { eval "use DBD::mysql; use SQL::Translator 0.08;"; plan $@ ? ( skip_all => 'needs DBD::mysql and SQL::Translator 0.08 for testing' ) - : ( tests => 9 ); + : ( tests => 13 ); } +my $version_table_name = 'dbix_class_schema_versions'; +my $old_table_name = 'SchemaVersions'; + use lib qw(t/lib); use_ok('DBICVersionOrig'); my $schema_orig = DBICVersion::Schema->connect($dsn, $user, $pass); -eval { $schema_orig->storage->dbh->do('drop table SchemaVersions') }; +eval { $schema_orig->storage->dbh->do('drop table ' . $version_table_name) }; +eval { $schema_orig->storage->dbh->do('drop table ' . $old_table_name) }; is($schema_orig->ddl_filename('MySQL', 't/var', '1.0'), File::Spec->catfile('t', 'var', 'DBICVersion-Schema-1.0-MySQL.sql'), 'Filename creation working'); unlink('t/var/DBICVersion-Schema-1.0-MySQL.sql') if (-e 't/var/DBICVersion-Schema-1.0-MySQL.sql'); @@ -56,3 +60,26 @@ eval "use DBICVersionNew"; }; is($@, '', 'new column created'); } + +{ + my $schema_version = DBICVersion::Schema->connect($dsn, $user, $pass); + eval { + $schema_version->storage->dbh->do('select * from ' . $version_table_name); + }; + is($@, '', 'version table exists'); + + eval { + $schema_version->storage->dbh->do("DROP TABLE IF EXISTS $old_table_name"); + $schema_version->storage->dbh->do("RENAME TABLE $version_table_name TO $old_table_name"); + }; + is($@, '', 'versions table renamed to old style table'); + + $schema_version = DBICVersion::Schema->connect($dsn, $user, $pass); + is($schema_version->get_db_version, '2.0', 'transition from old table name to new okay'); + + eval { + $schema_version->storage->dbh->do('select * from ' . $old_table_name); + }; + ok($@, 'old version table gone'); + +}