Skip to content

Support table and column rename operations preceding create_constraint FOREIGN KEY operations #682

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

Merged
merged 2 commits into from
Feb 14, 2025

Conversation

andrew-farries
Copy link
Collaborator

Ensure that create_constraint FOREIGN KEY operations can be preceded by rename table and rename column operations as in the following example:

{
  "name": "22_multiple_ops",
  "operations": [
    {
      "rename_table": {
        "from": "items",
        "to": "products"
      }
    },
    {
      "rename_column": {
        "table": "products",
        "from": "owner",
        "to": "owner_id"
      }
    },
    {
      "create_constraint": {
        "table": "products",
        "type": "foreign_key",
        "name": "fk_items_users",
        "columns": ["owner_id"],
        "references": {
          "table": "users",
          "columns": ["id"]
        },
        "up": {
          "owner_id": "owner_id"
        },
        "down": {
          "owner_id": "owner_id"
        }
      }
    }
  ]
}

Follow up to #674 and #676.

Part of #239.

Use the physical table name when adding a foreign key constraint. This
ensures that if the table has been renamed in the in-memory schema by an
earlier operation, the correct table name is used when adding the
constraint.
@andrew-farries andrew-farries merged commit 97dbca2 into main Feb 14, 2025
28 checks passed
@andrew-farries andrew-farries deleted the support-multi-op-create-fk-constraint branch February 14, 2025 11:40
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

Successfully merging this pull request may close these issues.

2 participants