From eb458da9b4965fdeb9c5d62dfee0e627118d2b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20=C3=87engel?= Date: Sat, 10 Oct 2026 19:39:04 +0300 Subject: [PATCH] feat(schema): model enum renames and replace an enum on its name ALTER TYPE ... RENAME TO renames a modeled enum in its position and every scalar and array column of that type follows it; RENAME VALUE renames a label in its position. A CREATE TYPE ... AS ENUM or RENAME TO onto a modeled enum's name replaces that enum, so the migration that replaces an enum loads in either usual shape. OWNER TO and the attribute actions are ignored without resolving the type, RENAME TO and SET SCHEMA of an unmodeled type are ignored, and SET SCHEMA of a modeled enum is rejected naming the action. --- docs/postgresql.md | 36 ++- .../schema/parser/DefaultSchemaParser.java | 235 +++++++++++++-- .../compiler/PostgresIntegrationTest.java | 119 ++++++++ .../parser/DefaultSchemaParserTest.java | 284 +++++++++++++++++- 4 files changed, 633 insertions(+), 41 deletions(-) diff --git a/docs/postgresql.md b/docs/postgresql.md index dbbaff9..faf12ed 100644 --- a/docs/postgresql.md +++ b/docs/postgresql.md @@ -94,9 +94,10 @@ order the files are read in. - One rule decides every statement: only the `CREATE TABLE`, `DROP TABLE`, and `ALTER TABLE` forms listed in [Ordered Table DDL](#ordered-table-ddl) and the - `CREATE TYPE ... AS ENUM` and `ALTER TYPE ... ADD VALUE` forms listed in - [Enum Types](#enum-types) update the schema model, and every other statement - a schema file records is accepted and leaves it unchanged. Only the few + `CREATE TYPE ... AS ENUM` and `ALTER TYPE ... ADD VALUE`, `RENAME TO`, and + `RENAME VALUE` forms listed in [Enum Types](#enum-types) update the schema + model, and every other statement a schema file records is accepted and + leaves it unchanged. Only the few statements listed in [Ignored Statements](#ignored-statements) are rejected instead, because sqlcj cannot tell what they would do to the model. - The statements of the schema files of one entry are applied in order to one @@ -247,17 +248,29 @@ left: | `ALTER TYPE ... ADD VALUE '