[discourse] Postgresql migration error from v15 to v16 #4313
-
Originally posted by KirillZy on Discourse Hi everyone. current migration {“current_version”: 15, “expected_version”: 16} In DB with schema version 15 I have: Table “public.rule_segments” Maybe there are some ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The migration error happens because the migration script expects a foreign key constraint named This mismatch likely comes from changes in how constraints were named and managed in earlier migrations. To resolve this, you can manually drop the existing constraint ( Before making these changes, ensure you have a backup of your database. Then, run: ALTER TABLE rule_segments DROP CONSTRAINT IF EXISTS rule_segments_namespace_key_fkey;
ALTER TABLE rollout_segment_references DROP CONSTRAINT IF EXISTS rollout_segment_references_namespace_key_fkey; After that, re-run the migration process. This should allow the migration to proceed and create the new constraints with the correct names and If you have existing data that would violate the new To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
The migration error happens because the migration script expects a foreign key constraint named
rule_segments_namespace_key_segment_key_fkey
to exist, but in your current schema (v15), the constraint is namedrule_segments_namespace_key_fkey
and usesON DELETE CASCADE
instead ofON DELETE RESTRICT
. The migration tries to drop and recreate this constraint with a new name and behavior, but fails since the expected constraint name doesn't match what's in your DB.This mismatch likely comes from changes in how constraints were named and managed in earlier migrations. To resolve this, you can manually drop the existing constraint (
rule_segments_namespace_key_fkey
) and then re-run the migratio…