Skip to content

Commit 3b9fa9c

Browse files
feat(db): no auto migration)
1 parent f695d99 commit 3b9fa9c

6 files changed

Lines changed: 9 additions & 33 deletions

File tree

Makefile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,6 @@ benchmark:
114114
echo "Running benchmarks and saving to $$log_file..."; \
115115
go test -bench=. -benchmem -run=^$$ ./tests/benchmarks/... | tee $$log_file
116116

117-
# Database migrations (requires DATABASE_URL)
118-
migrate-up:
119-
migrate -path $(MIGRATIONS_PATH) -database "$(DATABASE_URL)" up
120-
121-
migrate-down:
122-
migrate -path $(MIGRATIONS_PATH) -database "$(DATABASE_URL)" down 1
123-
124-
migrate-version:
125-
migrate -path $(MIGRATIONS_PATH) -database "$(DATABASE_URL)" version
126-
127-
migrate-create:
128-
@if [ -z "$(name)" ]; then echo "usage: make migrate-create name=add_users_index"; exit 1; fi
129-
migrate create -ext sql -dir $(MIGRATIONS_PATH) -seq $(name)
130-
131117
# Linting
132118
lint:
133119
golangci-lint run ./...

cmd/server/main.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ func main() {
5252

5353
ctx := context.Background()
5454

55-
// Apply database migrations before serving traffic.
56-
if err := database.RunMigrations(ctx, cfg.Database.URL, cfg.Database.MigrationsPath); err != nil {
57-
slog.Error("failed to run database migrations", "error", err, "path", cfg.Database.MigrationsPath)
58-
os.Exit(1)
59-
}
60-
slog.Info("database migrations applied", "path", cfg.Database.MigrationsPath)
61-
6255
// Connect to database
6356
pool, err := database.NewPool(ctx, cfg.Database.URL)
6457
if err != nil {

internal/database/migrations_integration_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,20 @@ import (
1818
)
1919

2020
func TestMigrationsApplyAndRollback(t *testing.T) {
21-
pool := testutils.SetupEmptyTestDB(t)
22-
defer pool.Close()
23-
24-
ctx := context.Background()
2521
migrationsDir := repoRoot(t, 2)
2622
migrationsDir = filepath.Join(migrationsDir, "migrations")
2723

2824
upFiles, downFiles := migrationFiles(t, migrationsDir)
29-
require.NotEmpty(t, upFiles, "no migration files found in %s", migrationsDir)
25+
if len(upFiles) == 0 {
26+
t.Skipf("no migration files found in %s", migrationsDir)
27+
}
3028
require.Equal(t, len(upFiles), len(downFiles), "up/down migration file count mismatch")
3129

30+
pool := testutils.SetupEmptyTestDB(t)
31+
defer pool.Close()
32+
33+
ctx := context.Background()
34+
3235
beforeState := snapshotPublicSchema(t, ctx, pool)
3336

3437
for i, path := range upFiles {

migrations/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

migrations/20260223004319_initial_schema.down.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

migrations/20260223004319_initial_schema.up.sql

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)