Skip to content

Bug(postgres): When recreating primary key(s) constraint, not null is not removed from old PK(s)  #6248

@erezrokah

Description

@erezrokah

Related to #6246

When we recreate primary keys during migration, we set new primary keys columns to not null:

if err := c.setNullOnPks(ctx, table); err != nil {

However we don't remove not null enforcement on previous primary keys.
Since we also don't delete renamed columns, when we try to insert new data to the table, the old column is populated with NULL and the insert fails.

Proposed solution(s)

  • Solution 1 - Look for all not null columns and remove the enforcement when recreating primary keys
  • Solution 2 - If after the migration the table has not null columns that are not part of the new schema, fail the migration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions