Repository navigation
feat(schema): ignore listed statements and locate rejected ones - #46
Merged
Merged
Conversation
Schema sources now accept index, comment, extension, sequence, grant, function, trigger, data, enum-type, and constraint ALTER TABLE statements without changing the schema model. A CREATE FUNCTION is ignored only when its own declaration has a dollar-quoted body. Every other statement fails as "Unsupported schema statement: <kind> at line <n>", where the line is read from the parse tree's token chain.
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 contain many statements that never change a table's columns, types, or nullability, such as indexes, grants, functions, triggers, comments, and seed data. Schema sources now accept a documented list of these statements and leave the schema model unchanged, so an existing migration directory loads without edits. Every other statement is still rejected, and the diagnostic now names the line the statement begins on.
Changes
CREATE/ALTER/DROP INDEX,COMMENT ON TABLE/COLUMN/VIEW,CREATE EXTENSION,CREATE/ALTER/DROP SEQUENCE,GRANT,REVOKE,CREATE [OR REPLACE] FUNCTIONwith an untagged$$ ... $$body,DROP FUNCTION,CREATE/DROP TRIGGER,INSERT,UPDATE,DELETE, andCREATE TYPE ... AS ENUM. Ignored statements are not resolved against the schema.ALTER TABLEconstraint actions:ADD [CONSTRAINT name] PRIMARY KEY,UNIQUE, orFOREIGN KEY,ADD CONSTRAINT name CHECK,DROP CONSTRAINT [IF EXISTS], andRENAME CONSTRAINT. They may stand alone or beside modeled actions. The altered table must still exist.CREATE FUNCTIONwhose own body is not dollar-quoted at the line it begins on, even when the parser captures a later dollar-quoted function into it.Unsupported schema statement: <kind> at line <n>. The line is derived from the parser's token chain, so comments and multi-line function bodies do not shift it. The compiler prefixes the message with the failing migration file.$$only, with tagged delimiters such as$body$being a syntax error;COMMENT ONlimited toTABLE,COLUMN, andVIEW; unnamedADD CHECKbeing a syntax error), and the new diagnostic.Scope and non-goals
ALTER TABLEadds are not recorded.COMMENT ONtargets remain syntax errors.ALTER TABLEactions such asSET DEFAULT, otherDROPobjects such as views,ALTER TYPE, and every other statement kind remain rejected. Missing-reference and syntax diagnostics are unchanged.