DBIx-Class-Migration
view release on metacpan or search on metacpan
t/upgrade-downgrade-sqlite.t view on Meta::CPAN
FOREIGN KEY (country_fk) REFERENCES country(country_id) ON DELETE CASCADE ON UPDATE CASCADE
);
;
CREATE INDEX artist_idx_country_fk04 ON artist (country_fk);
;
INSERT INTO artist SELECT artist_id, country_fk, name FROM artist_temp_alter;
;
DROP TABLE artist_temp_alter;
;
COMMIT;
END
close($downgrade_fh);
$migration->upgrade;
is $schema->resultset('Artist')->search({last_name=>'Two'})->first->last_name, 'Two';
$migration->dump_all_sets;
ok -e catfile($target_dir, 'fixtures','2','all_tables','country','1.fix'),
'found a fixture for version 2 of the schema';
$migration->downgrade;
}
CHECK_DOWNGRADE: {
ok(
my $migration = DBIx::Class::Migration->new(
schema_class=>'Local::Schema',
target_dir => $dir,
),
'created migration with schema_class');
isa_ok(
my $schema = $migration->schema, 'Local::Schema',
'got a reasonable looking schema');
ok ((my $rocker = $schema->resultset('Artist')->search({name=>'Rocker One'})->first),
'got some previously inserted data');
is $rocker->name, 'Rocker One';
}
CHECK_TO_VERSION_FIXTURE: {
# keep same fixtures, zap SQLite DB so start from fresh
my $file = $schema_args->[0];
$file =~ s#^(.*?:){2}##;
ok unlink($file), "deleted db '$file' ok";
require DBIx::Class::Migration::Script;
local @ARGV = (
'--schema_class' => 'Local::v2::Schema',
'--to_version' => 1,
'--target_dir' => $dir,
'install'
);
ok(
my $migration = DBIx::Class::Migration::Script->new_with_options,
'created migration with lowered to_version');
is $migration->to_version, 1, 'DH has correct version';
is $migration->migration->build_dbic_fixtures_init_args->{config_dir},
rel2abs(catdir($dir, qw(fixtures 1 conf))), 'DBICF has correct version';
$migration->run;
}
done_testing;
( run in 2.209 seconds using v1.01-cache-2.11-cpan-5b529ec07f3 )