1234567891011121314151617181920212223242526 |
- package models
- import (
- db "ERP_storage/initialize"
- "ERP_storage/models/ContractReview"
- _ "github.com/go-sql-driver/mysql"
- "log"
- )
- func init() {
- AutoMigrateDB()
- }
- func AutoMigrateDB() {
- //自动迁移模式
- err := db.DB.Set("gorm:table_options", "charset=utf8mb4").
- AutoMigrate(
- &ContractReview.ServiceType{},
- &ContractReview.ServiceItem{},
- &ContractReview.ContractReview{},
- &ContractReview.ContractReviewServiceItem{},
- )
- if err != nil {
- log.Fatalf("migrate db fail: %v", err)
- }
- }
|