mirror of
https://github.com/xataio/pgroll.git
synced 2024-10-05 17:47:59 +03:00
f764993640
Implement the **drop column** migration operation. A migration to drop a column looks like this: ```json { "name": "09_drop_column", "operations": [ { "drop_column": { "table": "fruits", "column": "price", "down": "0" } } ] } ``` The migration takes the name of the table and column that should be dropped along with (optionally) some `down` SQL to run to populate the field in the underlying table when insertions are done via the new schema version while the migration is in progress. * On `Start`, the relevant view in the new version schema is created without the dropped column. The column is not deleted from the underlying table. * If `down` SQL is specified, a trigger is created on the underlying table to populate the column to be removed when inserts are made from the new schema version. * On `Rollback` any triggers on the underlying table are removed. * On `Complete` the old version of the schema is removed and the column is removed from the underlying table. Any triggers are also removed.
27 lines
472 B
JSON
27 lines
472 B
JSON
{
|
|
"name": "08_create_fruits_table",
|
|
"operations": [
|
|
{
|
|
"create_table": {
|
|
"name": "fruits",
|
|
"columns": [
|
|
{
|
|
"name": "id",
|
|
"type": "serial",
|
|
"pk": true
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "varchar(255)",
|
|
"unique": true
|
|
},
|
|
{
|
|
"name": "price",
|
|
"type": "decimal(10,2)"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|