Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"log"
"net/http"
"os"
"regexp"
"strings"

"github.com/gorilla/mux"
Expand Down Expand Up @@ -248,6 +249,11 @@ func main() {
func runMigrations(db *database.DB) error {
log.Println("Running database migrations...")

// Compile regex pattern once for efficiency
// Only process numbered migrations (e.g., 001_init.sql, 002_sample_data.sql)
// Skip helper scripts like bootstrap_existing_db.sql
migrationPattern := regexp.MustCompile(`^\d{3}_.*\.sql$`)

// Create migrations tracking table if it doesn't exist
createTableSQL := `
CREATE TABLE IF NOT EXISTS schema_migrations (
Expand Down Expand Up @@ -289,6 +295,12 @@ func runMigrations(db *database.DB) error {
continue
}

// Skip non-numbered migration files (e.g., bootstrap scripts)
if !migrationPattern.MatchString(entry.Name()) {
log.Printf("Skipping non-numbered migration file: %s", entry.Name())
continue
}
Comment on lines +298 to +302

Copilot AI Jan 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new filtering logic that skips non-numbered migration files lacks test coverage. Consider adding tests to verify that:

  1. Numbered migration files (e.g., 001_init.sql) are processed correctly
  2. Non-numbered files (e.g., bootstrap_existing_db.sql) are skipped with appropriate logging
  3. Edge cases like files with partial number patterns are handled correctly

Other functions in the codebase have comprehensive test coverage (see tests/a2a/, internal/models/models_test.go, internal/validator/validator_test.go), suggesting that adding tests for this migration filtering logic would be consistent with project practices.

Copilot uses AI. Check for mistakes.

// Skip if already applied
if appliedMigrations[entry.Name()] {
continue
Expand Down
Loading