This commit is contained in:
2026-07-04 11:10:52 +05:30
parent bd6427f5db
commit c8adaf7815
18 changed files with 1140 additions and 92 deletions

View File

@@ -41,6 +41,7 @@ func Migrate(db *gorm.DB) error {
&models.CarrierPricing{},
&models.DoormilePricing{},
&models.AgentDecision{},
&models.HubStaffAccount{},
)
if err != nil {
@@ -62,5 +63,16 @@ func Migrate(db *gorm.DB) error {
utils.Info("✅ ivfflat index on context_embedding ready")
}
// The tripsheets.status CHECK constraint predates this codebase (not derived
// from any gorm tag) and only allowed Draft/Dispatched/Arrived/Cancelled.
// Hub batches need an intermediate "Ready" stage before dispatch.
db.Exec(`ALTER TABLE tripsheets DROP CONSTRAINT IF EXISTS tripsheets_status_check`)
if res := db.Exec(`ALTER TABLE tripsheets ADD CONSTRAINT tripsheets_status_check
CHECK (status::text = ANY (ARRAY['Draft','Ready','Dispatched','Arrived','Cancelled']::text[]))`); res.Error != nil {
utils.Error("❌ Failed to widen tripsheets_status_check constraint", "error", res.Error)
} else {
utils.Info("✅ tripsheets_status_check constraint includes Ready")
}
return nil
}