Unverified Commit d11e1fc5 authored by Francesc Guasch's avatar Francesc Guasch Committed by GitHub
Browse files

fix: drop constraint if different (#1700)

parent 15396a69
......@@ -218,7 +218,7 @@ sub _do_create_constraints($self) {
my ($name) = $constraint =~ /CONSTRAINT (\w+)\s/;
warn "INFO: creating constraint $name \n"
if !$FIRST_TIME_RUN && $0 !~ /\.t$/;
if $name && !$FIRST_TIME_RUN && $0 !~ /\.t$/;
print "+" if $FIRST_TIME_RUN && !$CAN_FORK;
$self->_clean_db_leftovers();
......@@ -2049,6 +2049,12 @@ sub _create_constraints($self, $table, @constraints) {
my $name = "constraint_${table}_$field";
next if $known->{$name} && $known->{$name} eq $sql;
if ($known->{$name}) {
push @{$self->{_constraints}}
,"alter table $table DROP constraint $name";
}
$sql = "alter table $table add CONSTRAINT $name $sql";
# $CONNECTOR->dbh->do($sql);
push @{$self->{_constraints}},($sql);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment