hub apis
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user