sub field_autoinc { ( $_[1]->is_auto_increment ? 'IDENTITY' : () ) }
+sub primary_key_constraint {
+ 'CONSTRAINT ' .
+ $_[0]->shim->quote($_[1]->name || $_[1]->table->name . '_pk') .
+ ' PRIMARY KEY (' .
+ join( ', ', map $_[0]->shim->quote($_), $_[1]->fields ) .
+ ')'
+}
+
+sub index {
+ 'CREATE INDEX ' .
+ $_[0]->shim->quote($_[1]->name || $_[1]->table->name . '_idx') .
+ ' ON ' . $_[0]->shim->quote($_[1]->table->name) .
+ ' (' . join( ', ', map $_[0]->shim->quote($_), $_[1]->fields ) . ');'
+}
+
1;
if ( $type eq PRIMARY_KEY ) {
- $name = ($name ? unreserve($name) : mk_name( $table_name . '_pk' ));
- $c_def =
- "CONSTRAINT $name PRIMARY KEY ".
- '(' . join( ', ', @fields ) . ')';
+ $c_def = $future->primary_key_constraint($constraint)
}
elsif ( $type eq UNIQUE ) {
$name = $name_ur || mk_name( $table_name . '_uc' );
# Indices
#
for my $index ( $table->get_indices ) {
- my $idx_name = $index->name || mk_name($table_name . '_idx');
- my $idx_name_ur = unreserve($idx_name);
- push @index_defs,
- "CREATE INDEX $idx_name_ur ON $table_name_ur (".
- join( ', ', map unreserve($_), $index->fields ) . ");";
+ push @index_defs, $future->index($index)
}
my $create_statement = "";