Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(db-postgres): v2-v3 migration errors with relation already exists #12310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

DanRibbens
Copy link
Contributor

@DanRibbens DanRibbens commented May 3, 2025

This fixes three issues identified in the predefined migration for postgres v2-v3

relation already exists

Can error with the following:

{
  err: [DatabaseError],
  msg: 'Error running migration 20250502_020052_relationships_v2_v3 column "relation_id" of relation "table_name" already exists.'
}

This was happening when you run a migration with both a required relationship or upload field and no schema specified in the db adapter. When both of these are true the function that replaces ADD COLUMN and ALTER COLUMN in order to add NOT NULL constraints for requried fields, wasn't working. This resulted in the ADD COLUMN statement from being being called multiple times instead of altering it after data had been copied over.

camelCase column change

Enum columns from using select or radio have changed from camelCase to snake case in v3. This change was not accounted for in the relationship migration and needed to be accounted for.

DROP CONSTRAINT

It was pointed out by here that the DROP CONSTRAINT needs to include IF EXISTS so that it can continue if the contraint was already removed in a previous statement.

fixes #10162

@DanRibbens DanRibbens requested a review from r1tsuu May 5, 2025 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error running migration ...postgres_relationships_v2_v3 relation "payload_locked_documents" does not exist.
1 participant