Skip to content

Commit

Permalink
Remove the ability to rename columns with alter_column operations (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
andrew-farries authored Jan 17, 2025
1 parent 895afe4 commit 3657bb5
Show file tree
Hide file tree
Showing 19 changed files with 424 additions and 912 deletions.
7 changes: 5 additions & 2 deletions internal/jsonschema/testdata/alter-column-2.txtar
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a valid 'alter_column' migration.
It sets `name` and therefore does not specify `up` or `down`.
It sets both `type` and `nullable`.

-- alter_column.json --
{
Expand All @@ -9,7 +9,10 @@ It sets `name` and therefore does not specify `up` or `down`.
"alter_column": {
"table": "reviews",
"column": "review",
"name": "new_name"
"type": "integer",
"nullable": true,
"up": "foo",
"down": "foo"
}
}
]
Expand Down
7 changes: 2 additions & 5 deletions internal/jsonschema/testdata/alter-column-3.txtar
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is an invalid 'alter_column' migration.
It sets only `name` but also sets `up` and `down`.
It specifies a table and column but no changes.

-- alter_column.json --
{
Expand All @@ -8,10 +8,7 @@ It sets only `name` but also sets `up` and `down`.
{
"alter_column": {
"table": "reviews",
"column": "review",
"name": "new_name",
"up": "foo",
"down": "foo"
"column": "review"
}
}
]
Expand Down
20 changes: 0 additions & 20 deletions internal/jsonschema/testdata/alter-column-4.txtar

This file was deleted.

20 changes: 0 additions & 20 deletions internal/jsonschema/testdata/alter-column-5.txtar

This file was deleted.

22 changes: 0 additions & 22 deletions internal/jsonschema/testdata/alter-column-6.txtar

This file was deleted.

20 changes: 0 additions & 20 deletions internal/jsonschema/testdata/alter-column-7.txtar

This file was deleted.

22 changes: 0 additions & 22 deletions internal/jsonschema/testdata/alter-column-8.txtar

This file was deleted.

18 changes: 0 additions & 18 deletions internal/jsonschema/testdata/alter-column-9.txtar

This file was deleted.

12 changes: 0 additions & 12 deletions pkg/migrations/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,6 @@ func (e ConstraintAlreadyExistsError) Error() string {
return fmt.Sprintf("constraint %q on table %q already exists", e.Constraint, e.Table)
}

type NoUpSQLAllowedError struct{}

func (e NoUpSQLAllowedError) Error() string {
return "up SQL is not allowed for this operation"
}

type NoDownSQLAllowedError struct{}

func (e NoDownSQLAllowedError) Error() string {
return "down SQL is not allowed for this operation"
}

type BackfillNotPossibleError struct {
Table string
}
Expand Down
Loading

0 comments on commit 3657bb5

Please sign in to comment.