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

Remove the drop_constraint operation #489

Open
andrew-farries opened this issue Nov 26, 2024 · 0 comments
Open

Remove the drop_constraint operation #489

andrew-farries opened this issue Nov 26, 2024 · 0 comments
Labels
breaking-changes breaking changes to pgroll
Milestone

Comments

@andrew-farries
Copy link
Collaborator

Remove the drop_constraint operation type, which only drops single-column constraints.

The operation is redundant since the addition of drop_multicolumn_constraint in #487 which can drop single and multi-column constraints.

This a breaking change, and should be made just before a v1 release.

@andrew-farries andrew-farries added the breaking-changes breaking changes to pgroll label Nov 26, 2024
@andrew-farries andrew-farries added this to the v1 milestone Nov 26, 2024
andrew-farries added a commit that referenced this issue Nov 26, 2024
Add a new `drop_multicolumn_constraint` operation type. The new
operation is used to drop multi-column (and single-column) `CHECK`,
`UNIQUE`, and `FOREIGN KEY` constraints:

The following migration drops a multi-column constraint called
`check_zip_name`, and defines `up` and `down` SQL data migrations for
each column covered by the constraint:

```json
{
  "name": "48_drop_tickets_check",
  "operations": [
    {
      "drop_multicolumn_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"
        }
      }
    }
  ]
}
```

* On operation `Start` each column covered by the constraint is
duplicated, ignoring the constraint to be dropped. Triggers for data
migrations are created for each column covered by the constraint using
the SQL for each column from the migration file.
* On `Complete`, the duplicated column is renamed to the original name
and triggers are removed.
* `Validate` ensures that all columns covered by the constraint have
data migrations defined, and only columns covered by the constraint have
data migrations defined.

The new operation is in addition to the existing `drop_constraint`
operation which only drops single column constraints. This old operation
type is preserved for backwards compatibility but will be removed as a
breaking change before a v1 release.

#489 tracks the removal of the
`drop_constraint` operation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-changes breaking changes to pgroll
Projects
None yet
Development

No branches or pull requests

1 participant