Repository navigation
feat(schema): model enum renames and replace an enum on its name - #66
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migration histories that rename an enum type, rename an enum label, or replace an enum by declaring a new type under its name now load. Previously every
ALTER TYPEaction other thanADD VALUEwas rejected, and aCREATE TYPEonto an existing enum name failed asType already exists, so the common replace-an-enum migration could not be read.Changes
ALTER TYPE ... RENAME TOrenames a modeled enum in its position, keeping its labels; every column of that type, scalar and array alike, follows the new name.ALTER TYPE ... RENAME VALUErenames a label in its position, preserving PostgreSQL's sort order; a missing label or an existing new label fails as PostgreSQL rejects it.CREATE TYPE ... AS ENUMorRENAME TOonto a modeled enum's name replaces that enum in its position, because theDROP TYPEthat freed the name is not readable. Both usual migration shapes load: renaming the old type away first, or declaring the new type beside it and renaming it onto the old name.OWNER TOand the composite attribute actions are ignored without resolving the type.RENAME TOandSET SCHEMAof a type sqlcj does not model are ignored.SET SCHEMAof a modeled enum is rejected asUnsupported ALTER TYPE action: SET SCHEMA <schema> at line <n>.ALTER TYPEform, the replacement rule, and the remaining diagnostics.Scope and non-goals
public.moodandmoodare different names. A qualifiedRENAME TOorSET SCHEMAname that matches no modeled enum fails asType not foundrather than being ignored.RENAME TOtarget, several comma-joined actions, andSET (...)stay rejected as unreadable type DDL.DROP TYPEis still ignored. A column that still names a replaced enum is modeled with the replacing enum's labels, the same unseenDROP TYPE ... CASCADEcase already documented.