Skip to content
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

feat: track seeded files in migration table #2728

Merged
merged 5 commits into from
Oct 7, 2024
Merged

Conversation

sweatybridge
Copy link
Contributor

@sweatybridge sweatybridge commented Oct 4, 2024

What kind of change does this PR introduce?

feature

What is the new behavior?

Track seed files in a history table.

  • path resolves to local seed file and is also they primary key
  • hash is the sha256 checksum of the seed file

When loading seed files, we check the history table for path and hash match. Any unmatched files will be seeded next.

If file path exists in history but checksum doesn't match, the seed file will be marked dirty. Dirty files are not seeded, only their hash column will be updated.

If both path and hash match, the seed file is skipped, as it has been applied before.

$ supabase db push --local --include-seed
Connecting to local database...
Schema migrations are up to date.
Do you want to seed the remote database with these files?
 • supabase/seeds/buckets.sql
 • supabase/seeds/users.sql

 [Y/n] n
context canceled
exit status 1

Additional context

Also prompts before creating custom roles.

$ supabase db push --local --include-seed --include-roles
Connecting to local database...
Do you want to create custom roles in the database cluster? [Y/n]
Seeding globals from roles.sql...
Schema migrations are up to date.
Seed files are up to date.
Finished supabase db push.

@sweatybridge sweatybridge requested a review from a team as a code owner October 4, 2024 15:33
@sweatybridge sweatybridge force-pushed the seed-table branch 5 times, most recently from 88d43f1 to 998a407 Compare October 4, 2024 17:01
@coveralls
Copy link

coveralls commented Oct 4, 2024

Pull Request Test Coverage Report for Build 11209113791

Details

  • 63 of 93 (67.74%) changed or added relevant lines in 7 files are covered.
  • 11 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.08%) to 60.204%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/db/reset/reset.go 0 1 0.0%
internal/db/start/start.go 4 5 80.0%
internal/migration/apply/apply.go 6 8 75.0%
internal/utils/flags/db_url.go 0 4 0.0%
internal/db/push/push.go 41 63 65.08%
Files with Coverage Reduction New Missed Lines %
internal/db/reset/reset.go 1 76.05%
internal/gen/keys/keys.go 5 12.9%
internal/db/push/push.go 5 71.58%
Totals Coverage Status
Change from base Build 11207860418: -0.08%
Covered Lines: 6499
Relevant Lines: 10795

💛 - Coveralls

internal/db/reset/reset.go Show resolved Hide resolved
@sweatybridge sweatybridge merged commit c805fc6 into develop Oct 7, 2024
9 checks passed
@sweatybridge sweatybridge deleted the seed-table branch October 7, 2024 05:22
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.

3 participants