Skip to content

Commit

Permalink
fix: drop constraint if different (UPC#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol authored Feb 3, 2022
1 parent 15396a6 commit d11e1fc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Ravada.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d11e1fc

Please sign in to comment.