foreach my $moniker (@monikers)
{
- #eval "use $tableclass";
- #print("Can't load $tableclass"), next if($@);
my $source = $dbixschema->source($moniker);
next if $seen_tables{$source->name}++;
my $colcount = 0;
foreach my $col ($source->columns)
{
- # assuming column_info in dbix is the same as DBI (?)
+ # assuming column_info in dbic is the same as DBI (?)
# data_type is a number, column_type is text?
my %colinfo = (
name => $col,
}
}
- foreach my $idx ( $source->indices ) {
- my $ret = $table->add_index(%$idx)
- or die $table->error;
- }
-
my @rels = $source->relationships();
my %created_FK_rels;
)
{
$created_FK_rels{$rel_table}->{$key_test} = 1;
- $table->add_constraint(
- type => 'foreign_key',
- name => "fk_$keys[0]",
- fields => \@keys,
- reference_fields => \@refkeys,
- reference_table => $rel_table,
- on_delete => $on_delete,
- on_update => $on_update
- );
+ if (scalar(@keys)) {
+ $table->add_constraint(
+ type => 'foreign_key',
+ name => "fk_$keys[0]",
+ fields => \@keys,
+ reference_fields => \@refkeys,
+ reference_table => $rel_table,
+ on_delete => $on_delete,
+ on_update => $on_update
+ );
+
+ my $index = $table->add_index(
+ name => $table->name . "_fk_$keys[0]",
+ fields => \@keys,
+ type => 'NORMAL',
+ );
+ }
+
}
}
}
+
+ if ($source->result_class->can('sqlt_deploy_hook')) {
+ $source->result_class->sqlt_deploy_hook($table);
+ }
+ }
+
+ if ($dbixschema->can('sqlt_deploy_hook')) {
+ $dbixschema->sqlt_deploy_hook($schema);
}
+
return 1;
}