MySQL-Workbench-Parser
view release on metacpan or search on metacpan
lib/MySQL/Workbench/Parser/MySQLParser.pm view on Meta::CPAN
}
if ( $fdata->{'is_unique'} ) {
$table->add_constraint(
name => '',
type => 'UNIQUE',
fields => $fdata->{'name'},
) or die $table->error;
}
for my $cdata ( @{ $fdata->{'constraints'} } ) {
next unless $cdata->{'type'} eq 'foreign_key';
$cdata->{'fields'} ||= [ $field->name ];
push @{ $tdata->{'constraints'} }, $cdata;
}
}
for my $idata ( @{ $tdata->{'indices'} || [] } ) {
my $index = $table->add_index(
name => $idata->{'name'},
type => uc $idata->{'type'},
fields => $idata->{'fields'},
) or die $table->error;
lib/MySQL/Workbench/Parser/MySQLParser.pm view on Meta::CPAN
if ( !exists $ignores->{$option_key} ) {
push @cleaned_options, $option;
}
}
} else {
@cleaned_options = @options;
}
$table->options( \@cleaned_options ) or die $table->error;
}
for my $cdata ( @{ $tdata->{'constraints'} || [] } ) {
my $constraint = $table->add_constraint(
name => $cdata->{'name'},
type => $cdata->{'type'},
fields => $cdata->{'fields'},
expression => $cdata->{'expression'},
reference_table => $cdata->{'reference_table'},
reference_fields => $cdata->{'reference_fields'},
match_type => $cdata->{'match_type'} || '',
on_delete => $cdata->{'on_delete'}
|| $cdata->{'on_delete_do'},
on_update => $cdata->{'on_update'}
|| $cdata->{'on_update_do'},
) or die $table->error;
}
# After the constrains and PK/idxs have been created,
# we normalize fields
normalize_field($_) for $table->get_fields;
}
my @procedures = sort {
$result->{procedures}->{ $a }->{'order'}
( run in 0.274 second using v1.01-cache-2.11-cpan-454fe037f31 )