Migration and seed implementaion#152
Open
Gautam7352 wants to merge 32 commits into
Open
Conversation
TanishqSingla
requested changes
Apr 5, 2026
TanishqSingla
requested changes
Apr 5, 2026
…th are separately initiated
TanishqSingla
requested changes
Apr 8, 2026
| github.com/testcontainers/testcontainers-go v0.41.0 | ||
| github.com/testcontainers/testcontainers-go/modules/postgres v0.41.0 | ||
| golang.org/x/crypto v0.48.0 | ||
| pgregory.net/rapid v1.2.0 |
Contributor
There was a problem hiding this comment.
what is this used for?
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
Implements database migrations and seeding using Goose, replacing the previous stub
InitSchema()approach. Migrations are now a dedicated CI/CD step, fully decoupled from the app server.fixes #51
fixes #127
fixes #56
fixes #57
fixes #58
fixes #59
What changed
Migration runner (
cmd/migrate)Seed runner (
cmd/seed)ON CONFLICT (id) DO NOTHINGso re-runs are safeEmbedded migrations (
db/embed.go)embed.FSbackend/db/init.sqlwith a proper Goose migration atbackend/db/migrations/00001_init_schema.sqlDatabase package (
internal/database/db.go)InitSchema()stubDockerfile
migrate-builderandmigratestage (scratch-based, statically linked)migratetarget produces a minimal binary-only imageDocker Compose (
compose.yml/compose-dev.yml)migrateservice that runs the migrate binarybackendnow depends onmigratecompleting successfully (service_completed_successfully) instead of directly on the DB being healthy./backup/data:/var/lib/postgresql/dataMakefile
make migrateandmake seedtargetsair.toml
bin/full_binfields withentrypointDocs
docs/readme.mdto reflect the new migration and seed workflowTests
Added
backend/internal/database/migrate_test.gowith property-based tests using rapid and testcontainers:CREATE TABLE IF NOT EXISTS)goose_db_versionaftergoose.Up)goose.Uptwice doesn't change row counts)goose_db_versiontable)Tests spin up a real Postgres 17 container per test via testcontainers — no mocks.
How to run locally