8000 Add flag to increment by arbitrary integer by lwileczek · Pull Request #957 · pressly/goose · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add flag to increment by arbitrary integer #957

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lwileczek
Copy link
@lwileczek lwileczek commented Jun 18, 2025

Summary

Allow users to increment sequential migrations by an arbitrary integer, with 1 as the default.
This leaves rooms for users to use serial migrations, but if they need to insert one betwixt to existing migrations, they do not have to renumber all of the proceeding migrations. A common pattern when making network rules is to increment by 100 for this very reason.

By default, the current behavior will continue.

Example

$ mkdir __tmp
$ goose -dir __tmp -s -inc 10 create create_roles sql
2025/06/18 10:46:27 Created new file: __tmp/00010_create_roles.sql

$ goose -dir __tmp -s -inc 10 create create_users sql
2025/06/18 10:47:06 Created new file: __tmp/00020_create_users.sql

Why?

When starting a new project and creating many migrations, I often find myself forgetting to make a migration/table that is required to satisfy a foreign key constraint on one of my tables.

Allow users to increment sequential migrations by an arbitrary integer.
This allows them to add migrations like network rules to add new
migrations between existing ones
Fix the test which checks for the name of sequential migrations
incrementing by an arbitrary number. The migration numbers will be
increasing by (fileN*incV) + incV, not starting at one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0