Skip to content
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

Support multiple columns in drop_constraint #458

Closed
kvch opened this issue Nov 8, 2024 · 2 comments
Closed

Support multiple columns in drop_constraint #458

kvch opened this issue Nov 8, 2024 · 2 comments
Assignees

Comments

@kvch
Copy link
Contributor

kvch commented Nov 8, 2024

Right now drop_constraint operation only supports dropping constraints that include a single column. With the introduction of create_constraint we now support creating constraints with multiple columns. Now we need to adjust drop_constraint.

@kvch kvch self-assigned this Nov 8, 2024
@kvch kvch removed their assignment Nov 19, 2024
@andrew-farries andrew-farries self-assigned this Nov 22, 2024
@andrew-farries
Copy link
Collaborator

andrew-farries commented Nov 22, 2024

This will require a breaking change to the drop_constraint operation format.

Dropping a multi-column constraint will require down, and optionally up, data migrations to be specified for all columns covered by the constraint. This will mean the operation has to change from its current format:

[
    {
      "drop_constraint": {
        "table": "posts",
        "name": "title_length",
        "up": "title",
        "down": "(SELECT CASE WHEN length(title) <= 3 THEN LPAD(title, 4, '-') ELSE title END)"
      }
    }
]

to something that allows up and down data migrations for multiple columns:

[
    {
      "drop_constraint": {
        "table": "tickets",
        "name": "check_zip_name",
        "up": {
          "sellers_name": "sellers_name",
          "sellers_zip": "sellers_zip"
        },
        "down": {
          "sellers_name": "sellers_name",
          "sellers_zip": "sellers_zip"
        }
      }
    }
]

This new format looks similar to the create_constraint operation which also allows up and down migrations for multiple columns.

@andrew-farries
Copy link
Collaborator

andrew-farries commented Nov 26, 2024

Implemented in #487 as a new operation type drop_multicolumn_constraint rather than make the breaking change to drop_constraint.

#489 tracks the removal of the obsoletedrop_constraint operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants