You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for PostgreSQL-style ALTER COLUMN syntax
PostgreSQL (and standard SQL) uses `ALTER COLUMN` instead of MySQL's `CHANGE COLUMN` / `MODIFY COLUMN` for modifying existing columns. This adds parsing and schema evaluation for the five main sub-commands:
- `ALTER COLUMN col TYPE newtype`
- `ALTER COLUMN col SET NOT NULL`
- `ALTER COLUMN col DROP NOT NULL`
- `ALTER COLUMN col SET DEFAULT expr`
- `ALTER COLUMN col DROP DEFAULT`
These can be combined with other actions in a single `ALTER TABLE` statement, eg.:
```
ALTER TABLE t
DROP COLUMN old_col,
ALTER COLUMN col TYPE SMALLINT,
ALTER COLUMN col SET NOT NULL;
```
Migration generation (inverse actions + SQL fragments) is also supported for all five variants.
Copy file name to clipboardExpand all lines: test/out/alter.xml
+19Lines changed: 19 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,25 @@
13
13
<in/>
14
14
<out/>
15
15
</stmt>
16
+
<stmtname="create_bar"sql="CREATE TABLE "bar" (
"id" INTEGER NOT NULL,
"role" SMALLINT NOT NULL,
"role_new" INTEGER NOT NULL,
"omniscience" INTEGER NOT NULL
)"category="DDL"kind="create"target="bar"cardinality="0">
17
+
<in/>
18
+
<out/>
19
+
</stmt>
20
+
<stmtname="alter_bar_4"sql="ALTER TABLE "bar"
 DROP COLUMN "role",
 ALTER COLUMN "role_new" TYPE SMALLINT,
 ALTER COLUMN "role_new" SET NOT NULL,
 ALTER COLUMN "omniscience" TYPE BOOLEAN,
 ALTER COLUMN "omniscience" SET NOT NULL"category="DDL"kind="alter"target="bar"cardinality="0">
21
+
<in/>
22
+
<out/>
23
+
</stmt>
24
+
<stmtname="alter_bar_5"sql="ALTER TABLE "bar" RENAME COLUMN "role_new" TO "role""category="DDL"kind="alter"target="bar"cardinality="0">
0 commit comments