From ecbb96cb18bd989bb728a950eb2a8ad11d8c7dd4 Mon Sep 17 00:00:00 2001 From: Alexis Rico Date: Wed, 4 Dec 2024 15:26:04 +0100 Subject: [PATCH] Update drop column Signed-off-by: Alexis Rico --- docs/config.json | 2 +- docs/operations/README.md | 28 -------------------------- docs/operations/alter_column/README.md | 10 --------- docs/operations/drop_column.md | 23 --------------------- docs/operations/drop_column.mdx | 25 +++++++++++++++++++++++ 5 files changed, 26 insertions(+), 62 deletions(-) delete mode 100644 docs/operations/drop_column.md create mode 100644 docs/operations/drop_column.mdx diff --git a/docs/config.json b/docs/config.json index 577ddd2a..d1dc60f2 100644 --- a/docs/config.json +++ b/docs/config.json @@ -97,7 +97,7 @@ { "title": "Drop Column", "href": "/operations/drop_column", - "file": "docs/operations/drop_column.md" + "file": "docs/operations/drop_column.mdx" }, { "title": "Drop Constraint (deprecated)", diff --git a/docs/operations/README.md b/docs/operations/README.md index ae14b7c6..0a568861 100644 --- a/docs/operations/README.md +++ b/docs/operations/README.md @@ -8,31 +8,3 @@ "operations": [...] } ``` - -See the [examples](../../examples) directory for examples of each kind of operation. - -`pgroll` supports the following migration operations: - -- [Add column](./add_column.md) -- [Alter column](./alter_column.md) - - [Rename column](./rename_column.md) - - [Change type](./change_type.md) - - [Change default](./change_default.md) - - [Change comment](./change_comment.md) - - [Add check constraint](./add_check_constraint.md) - - [Add foreign key](./add_foreign_key.md) - - [Add not null constraint](./add_not_null_constraint.md) - - [Drop not null constraint](./drop_not_null_constraint.md) - - [Add unique constraint](./add_unique_constraint.md) -- [Create index](./create_index.md) -- [Create table](./create_table.md) -- [Create constraint](./create_constraint.md) -- [Drop column](./drop_column.md) -- [Drop constraint](./drop_constraint.md) -- [Drop multi-column constraint](./drop_multi_column_constraint.md) -- [Drop index](./drop_index.md) -- [Drop table](./drop_table.md) -- [Raw SQL](./raw_sql.md) -- [Rename table](./rename_table.md) -- [Rename constraint](./rename_constraint.md) -- [Set replica identity](./set_replica_identity.md) diff --git a/docs/operations/alter_column/README.md b/docs/operations/alter_column/README.md index cfc3b703..d3ca5af6 100644 --- a/docs/operations/alter_column/README.md +++ b/docs/operations/alter_column/README.md @@ -3,13 +3,3 @@ An alter column operation alters the properties of a column. The operation supports several sub-operations, described below. An alter column operation may contain multiple sub-operations. For example, a single alter column operation may rename a column, change its type, and add a check constraint. - -- [Rename column](./rename_column.md) -- [Change type](./change_type.md) -- [Change default](./change_default.md) -- [Change comment](./change_comment.md) -- [Add check constraint](./add_check_constraint.md) -- [Add foreign key](./add_foreign_key.md) -- [Add not null constraint](./add_not_null_constraint.md) -- [Drop not null constraint](./drop_not_null_constraint.md) -- [Add unique constraint](./add_unique_constraint.md) diff --git a/docs/operations/drop_column.md b/docs/operations/drop_column.md deleted file mode 100644 index ffb87fd8..00000000 --- a/docs/operations/drop_column.md +++ /dev/null @@ -1,23 +0,0 @@ -# Drop column - -## Structure - -A drop column operation drops a column from an existing table. - -**drop column** operations have this structure: - -```json -{ - "drop_column": { - "table": "name of table", - "column": "name of column to drop", - "down": "SQL expression" - } -} -``` - -The `down` field above is required in order to backfill the previous version of the schema during an active migration. For instance, in our [example](../../examples/09_drop_column.json), you can see that if a new row is inserted against the new schema without a `price` column, the old schema `price` column will be set to `0`. - -## Examples - -- [09_drop_column.json](../../examples/09_drop_column.json) diff --git a/docs/operations/drop_column.mdx b/docs/operations/drop_column.mdx new file mode 100644 index 00000000..0f234e7c --- /dev/null +++ b/docs/operations/drop_column.mdx @@ -0,0 +1,25 @@ +# Drop column + +## Structure + +A drop column operation drops a column from an existing table. + +```json +{ + "drop_column": { + "table": "name of table", + "column": "name of column to drop", + "down": "SQL expression" + } +} +``` + +The `down` field above is required in order to backfill the previous version of the schema during an active migration. + +## Examples + +### Drop a column with a default value + +If a new row is inserted against the new schema without a `price` column, the old schema `price` column will be set to `0`. + +