53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package migrations
|
|
|
|
import (
|
|
"doormile/models"
|
|
"doormile/utils"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func Migrate(db *gorm.DB) error {
|
|
utils.Info("Starting database auto-migrations for 21 logistics tables...")
|
|
|
|
err := db.AutoMigrate(
|
|
&models.PartnerInfo{},
|
|
&models.Hub{},
|
|
&models.Vehicle{},
|
|
&models.AppUser{},
|
|
&models.MilerProfile{},
|
|
&models.AppCustomer{},
|
|
&models.AppCustomerLocation{},
|
|
&models.Consignment{},
|
|
&models.PickupBooking{},
|
|
&models.BookingParcel{},
|
|
&models.BookingServiceOption{},
|
|
&models.BookingPayment{},
|
|
&models.BookingAssignment{},
|
|
&models.BookingVehicleRequirement{},
|
|
&models.Tripsheet{},
|
|
&models.TripsheetItem{},
|
|
&models.DeliveryProof{},
|
|
&models.Pricing{},
|
|
&models.ConsignmentHistory{},
|
|
&models.ConsignmentException{},
|
|
&models.TenantLocation{},
|
|
&models.AppLocation{},
|
|
&models.Tenant{},
|
|
&models.Customer{},
|
|
&models.CustomerLocation{},
|
|
&models.DoormileClient{},
|
|
&models.DoormileAuth{},
|
|
&models.CompetitorBranch{},
|
|
&models.CarrierPricing{},
|
|
&models.DoormilePricing{},
|
|
)
|
|
|
|
if err != nil {
|
|
utils.Error("❌ Database migration failed", "error", err)
|
|
return err
|
|
}
|
|
|
|
utils.Info("✅ Database migration completed successfully!")
|
|
return nil
|
|
}
|