my $schema = DBICTest->init_schema;
-plan tests => 55;
+plan tests => 60;
my $translator = SQL::Translator->new(
parser_args => {
ok($output, "SQLT produced someoutput")
or diag($translator->error);
-
# Note that the constraints listed here are the only ones that are tested -- if
# more exist in the Schema than are listed here and all listed constraints are
# correct, the test will still pass. If you add a class with UNIQUE or FOREIGN
on_delete => '', on_update => '',
},
],
+ # ForceForeign
+ forceforeign => [
+ {
+ 'display' => 'forceforeign->artist',
+ 'selftable' => 'forceforeign', 'foreigntable' => 'artist',
+ 'selfcols' => ['artist'], 'foreigncols' => ['artist_id'],
+ on_delete => '', on_update => '',
+ },
+ ],
+
);
my %unique_constraints = (
# ],
);
-my %indices = (
+my %indexes = (
artist => [
{
'fields' => ['name']
);
my $tschema = $translator->schema();
+# Test that the $schema->sqlt_deploy_hook was called okay and that it removed
+# the 'link' table
+ok( !defined($tschema->get_table('link')), "Link table was removed by hook");
# Test that nonexistent constraints are not found
my $constraint = get_constraint('FOREIGN KEY', 'cd', ['title'], 'cd', ['year']);
ok( !defined($constraint), 'nonexistent FOREIGN KEY constraint not found' );
$constraint = get_constraint('UNIQUE', 'cd', ['artist']);
ok( !defined($constraint), 'nonexistent UNIQUE constraint not found' );
+$constraint = get_constraint('FOREIGN KEY', 'forceforeign', ['cd'], 'cd', ['cdid']);
+ok( !defined($constraint), 'forced nonexistent FOREIGN KEY constraint not found' );
for my $expected_constraints (keys %fk_constraints) {
for my $expected_constraint (@{ $fk_constraints{$expected_constraints} }) {
}
}
-for my $table_index (keys %indices) {
- for my $expected_index ( @{ $indices{$table_index} } ) {
+for my $table_index (keys %indexes) {
+ for my $expected_index ( @{ $indexes{$table_index} } ) {
ok ( get_index($table_index, $expected_index), "Got a matching index on $table_index table");
}