Skip to content

Add OpRenameColumn for renaming columns #602

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 6 commits into from
Jan 17, 2025
Merged

Conversation

andrew-farries
Copy link
Collaborator

Add a new rename_column operation for performing column renames:

{
  "name": "13_rename_column",
  "operations": [
    {
      "rename_column": {
        "table": "employees",
        "from": "role",
        "to": "job_title"
      }
    }
  ]
}

Renaming columns is currently done using the alter_column operation:

{
  "name": "13_rename_column",
  "operations": [
    {
      "alter_column": {
        "table": "employees",
        "column": "role",
        "name": "job_title"
      }
    }
  ]
}

As of this PR both approaches are valid, but the second approach (using alter_column to perform column renames) will be removed as part of #601

Part of #601

Generate the type for `OpRenameColumn`.
Change the examples that rename a column to use the new `OpRenameColumn`
operation.
Add docuementation for the `rename_column` operation.

Remove references to renaming columns with the `alter_column` operation.
@andrew-farries andrew-farries merged commit 895afe4 into main Jan 17, 2025
28 checks passed
@andrew-farries andrew-farries deleted the add-op-rename-column branch January 17, 2025 15:08
andrew-farries added a commit that referenced this pull request Jan 17, 2025
…603)

Remove the ability to rename columns with `alter_column` operations.

#602 added the `rename_column` operation as the preferred way to rename
columns:

```json
{
  "name": "13_rename_column",
  "operations": [
    {
      "rename_column": {
        "table": "employees",
        "from": "role",
        "to": "job_title"
      }
    }
  ]
}
```

As of this PR, `rename_column` operations are the only way to rename
columns, with the ability to do so using `alter_column` operations
removed.

This is a breaking change to the `pgroll` migrations format.

This is the second (and final) part of #601 

Closes #601
kvch pushed a commit to kvch/pgroll that referenced this pull request Jan 20, 2025
…ataio#603)

Remove the ability to rename columns with `alter_column` operations.

xataio#602 added the `rename_column` operation as the preferred way to rename
columns:

```json
{
  "name": "13_rename_column",
  "operations": [
    {
      "rename_column": {
        "table": "employees",
        "from": "role",
        "to": "job_title"
      }
    }
  ]
}
```

As of this PR, `rename_column` operations are the only way to rename
columns, with the ability to do so using `alter_column` operations
removed.

This is a breaking change to the `pgroll` migrations format.

This is the second (and final) part of xataio#601 

Closes xataio#601
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