-
Notifications
You must be signed in to change notification settings - Fork 343
feat(seed): Add new flag option for setting custom seed file path #4680
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new --override-seed-file flag to the supabase db reset command, allowing users to specify a custom seed SQL file at runtime instead of using the default supabase/seed.sql. The flag is mutually exclusive with --no-seed.
Key Changes:
- New
--override-seed-fileflag added to override the default seed file path - Mutual exclusivity enforcement between
--no-seedand--override-seed-fileflags - Documentation updated to describe the new flag and its use case
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/supabase/db/reset.md | Added documentation explaining the new --override-seed-file flag and its use case for specifying custom seed files |
| cmd/db.go | Introduced overrideSeedFile variable, flag registration, mutual exclusivity setup, and logic to update SqlPaths when the flag is provided |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| if noSeed { | ||
| utils.Config.Db.Seed.Enabled = false | ||
| } else if len(overrideSeedFile) > 0 { |
Copilot
AI
Jan 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using the override seed file, the code only updates SqlPaths but doesn't ensure that Seed.Enabled is set to true. If seeding is disabled in the config file, the override seed file won't be executed. Consider adding a line to enable seeding when an override file is provided.
| } else if len(overrideSeedFile) > 0 { | |
| } else if len(overrideSeedFile) > 0 { | |
| utils.Config.Db.Seed.Enabled = true |
| resetFlags.StringVar(&overrideSeedFile, "override-seed-file", "", "Path to a custom seed SQL file to use instead of the default.") | ||
| dbResetCmd.MarkFlagsMutuallyExclusive("db-url", "linked", "local") | ||
| dbResetCmd.MarkFlagsMutuallyExclusive("no-seed", "override-seed-file") |
Copilot
AI
Jan 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new --override-seed-file flag lacks test coverage. Consider adding tests to verify that the custom seed file is used correctly and that it's properly mutually exclusive with --no-seed.
|
You can specify custom seed paths via config.toml |
What kind of change does this PR introduce?
Feature
What is the current behavior?
Currently, supabase db reset only supports two seed behaviors:
Run the default seed file(s) defined in config (e.g.
supabase/seed.sql)Skip seeding entirely with
--no-seedThere is no way to specify an alternative seed file at runtime. Users who want to reset their database with different initial data (e.g., an empty state with minimal setup vs. a full product example) must either:
Manually swap seed files before running reset
Skip seeding and manually run the desired seed file afterward
What is the new behavior?
Added a new
--override-seed-fileflag tosupabase db resetthat allows specifying a custom seed SQL file path:The
--override-seed-fileand--no-seedflags are mutually exclusive since using both doesn't make sense.Additional context
Add any other context or screenshots.