updates on the ai agents and time series prediction and updates on the api to

This commit is contained in:
2026-10-09 13:50:30 +05:30
parent 29690c56f2
commit 153be40e5c
42 changed files with 4889 additions and 186 deletions

View File

@@ -0,0 +1,29 @@
cmd/migratecheck — run the real migration against a throwaway Postgres.
The test suite never calls migrations.Migrate(): the integration tests
AutoMigrate only the models they need. So every raw statement at the end of
migrations/migrate.go — CREATE EXTENSION, the views, the indexes, the registry
seed — was unexecuted until this existed, and Migrate() logs those failures
NON-FATALLY. A broken view therefore returned "migration completed
successfully" and failed later at query time.
That is not hypothetical: it caught `bd.destinationid` (the real column is
bookingdestinationid), which would have left consignment_booking uncreated and
every query that joins through it failing in production.
Run it before shipping a migration change:
docker run -d --name dm-testpg -e POSTGRES_PASSWORD=test -e POSTGRES_DB=logistics \
-p 55432:5432 pgvector/pgvector:pg16
docker exec dm-testpg psql -U postgres -d logistics -c "CREATE EXTENSION IF NOT EXISTS vector;"
MIGRATE_CHECK_DSN="host=localhost port=55432 user=postgres password=test dbname=logistics sslmode=disable" \
go run ./cmd/migratecheck
Check the OUTPUT, not just the exit code — Migrate() returns OK on a logged
failure. Any ❌ or ⚠️ line is a statement that did not run.
The same DSN unskips 50 Postgres integration tests:
REGISTRY_TEST_DSN="host=localhost port=55432 user=postgres password=test dbname=logistics sslmode=disable" \
go test ./... -count=1

40
cmd/migratecheck/main.go Normal file
View File

@@ -0,0 +1,40 @@
// Runs migrations.Migrate() against a throwaway Postgres, so the DDL is
// executed at least once before it runs on a real database at server startup.
//
// The test suite never calls Migrate — the integration tests AutoMigrate the
// models they need — so every raw statement at the end of migrations/migrate.go
// (CREATE EXTENSION, the views, the CONCURRENTLY index, the seed) was
// unexecuted until this existed.
//
// Usage: MIGRATE_CHECK_DSN="host=... " go run ./cmd/migratecheck
package main
import (
"fmt"
"os"
"doormile/db"
"doormile/migrations"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
func main() {
dsn := os.Getenv("MIGRATE_CHECK_DSN")
if dsn == "" {
fmt.Println("MIGRATE_CHECK_DSN is required (a THROWAWAY database)")
os.Exit(2)
}
gdb, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if err != nil {
fmt.Println("connect:", err)
os.Exit(1)
}
db.DB = gdb // the registry seed reads the package handle
if err := migrations.Migrate(gdb); err != nil {
fmt.Println("MIGRATE FAILED:", err)
os.Exit(1)
}
fmt.Println("MIGRATE RETURNED OK")
}