You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(migration): Make naming constraint fail softer on updates
Only on installation we want to break hard, so that all developers notice
the bugs when installing the app on any database or CI, and can work on
fixing their migrations before releasing a version incompatible with Postgres.
In case of updates we might be running on production instances and the
administrators being faced with the error would not know how to resolve it
anyway. This can also happen with instances, that had the issue before the
current update, so we don't want to make their life more complicated
than needed.
Signed-off-by: Joas Schilling <coding@schilljs.com>
@@ -668,14 +687,20 @@ public function ensureUniqueNamesConstraints(Schema $targetSchema): void {
668
687
}
669
688
670
689
if (isset($constraintNames[$thing->getName()])) {
671
-
thrownew \InvalidArgumentException('Index name "' . $thing->getName() . '" for table "' . $table->getName() . '" collides with the constraint on table "' . $constraintNames[$thing->getName()] . '".');
690
+
if ($isInstalling) {
691
+
thrownew \InvalidArgumentException('Index name "' . $thing->getName() . '" for table "' . $table->getName() . '" collides with the constraint on table "' . $constraintNames[$thing->getName()] . '".');
692
+
}
693
+
$this->logErrorOrWarning('Index name "' . $thing->getName() . '" for table "' . $table->getName() . '" collides with the constraint on table "' . $constraintNames[$thing->getName()] . '".');
@@ -688,20 +713,34 @@ public function ensureUniqueNamesConstraints(Schema $targetSchema): void {
688
713
}
689
714
690
715
if (isset($constraintNames[$indexName])) {
691
-
thrownew \InvalidArgumentException('Primary index name "' . $indexName . '" for table "' . $table->getName() . '" collides with the constraint on table "' . $constraintNames[$thing->getName()] . '".');
716
+
if ($isInstalling) {
717
+
thrownew \InvalidArgumentException('Primary index name "' . $indexName . '" for table "' . $table->getName() . '" collides with the constraint on table "' . $constraintNames[$thing->getName()] . '".');
718
+
}
719
+
$this->logErrorOrWarning('Primary index name "' . $indexName . '" for table "' . $table->getName() . '" collides with the constraint on table "' . $constraintNames[$thing->getName()] . '".');
692
720
}
693
721
$constraintNames[$indexName] = $table->getName();
694
722
}
695
723
}
696
724
697
725
foreach ($sequencesas$sequence) {
698
726
if (isset($constraintNames[$sequence->getName()])) {
699
-
thrownew \InvalidArgumentException('Sequence name "' . $sequence->getName() . '" for table "' . $table->getName() . '" collides with the constraint on table "' . $constraintNames[$thing->getName()] . '".');
727
+
if ($isInstalling) {
728
+
thrownew \InvalidArgumentException('Sequence name "' . $sequence->getName() . '" for table "' . $table->getName() . '" collides with the constraint on table "' . $constraintNames[$thing->getName()] . '".');
729
+
}
730
+
$this->logErrorOrWarning('Sequence name "' . $sequence->getName() . '" for table "' . $table->getName() . '" collides with the constraint on table "' . $constraintNames[$thing->getName()] . '".');
0 commit comments