-
Notifications
You must be signed in to change notification settings - Fork 106
Remove support for the name
field in migrations
#852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
Migrations need to have a name but they shouldn't be set by the user.
Migration names are no longer deserialized as part of a migration so this hack is no longer needed.
Use the `ReadMigration` function to deserialize migrations rather than calling json.Unmarshal directly. This ensures that the migration name field is set correcty.
Migrations no longer set the name of the migration in the migration JSON.
Remove mentions of the `name` field in migrations.
f6da8b9
to
03bf2ef
Compare
kvch
approved these changes
May 21, 2025
This was referenced May 21, 2025
andrew-farries
added a commit
that referenced
this pull request
Jun 13, 2025
#852 removed support for specifying a migration name via the `name` field in a migration file. While having an unambiguous source of truth for the migration name (the filename) is good, it is still often desirable to decouple the filename from the name of the version schema that the migration will create when applied because filenames: * can be longer than the limit Postgres imposes on schema names * can contain characters that are not legal in Postgres schema names * must be named so that migration files are ordered lexicographically on disk This PR adds support for a new `version_schema` field in migration files that allows the migration author to specify the name of the version schema that the migration will create. ## Example ```yaml # migration files can now specify the version schema # name to be created by the migration version_schema: my_version_schema operations: - create_table: name: items columns: - name: id type: serial pk: true - name: name type: varchar(255) ``` Running this migration: ``` $ pgroll start migrations/01_create_table.yaml --complete ``` Creates this version schema: ``` +-----------------------+-------------------+ | Name | Owner | |-----------------------+-------------------| ... | public_my_version_schema | postgres | +-----------------------+-------------------+ ``` Had the `version_schema` field not been specified in the migration file the version schema would have been: ``` +-----------------------+-------------------+ | Name | Owner | |-----------------------+-------------------| ... | public_01_create_table | postgres | +-----------------------+-------------------+ ``` --- This PR is part of a stack: * #884 (this PR) * #886 * #887 Part of #882
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.
Remove support for specifying a
name
field in migration files:The migration filename is the source of truth for the migration name. The
name
field was made optional and its use discouraged in the documentation in #744. This PR removes support for it entirely.This is a breaking change: migration files that set the
name
field will not be runnable bypgroll
until thename
field is removed.Because of #812
pgroll pull
andpgroll migrate
will still work with migration histories that contain migrations withname
fields.The easiest way to remove the
name
fields from all migrations in the history is topgroll pull
the migration history; this will serialize all migrations in the remote history, removing the anyname
fields.Closes #715 and #850