- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 14 for AutoMigrate (0.07 sec)
-
tests/migrate_test.go
// create sequence err = DB.Table("events").AutoMigrate(&Event1{}) if err != nil { t.Errorf("AutoMigrate err:%v", err) } // delete sequence err = DB.Table("events").AutoMigrate(&Event{}) if err != nil { t.Errorf("AutoMigrate err:%v", err) } // update sequence err = DB.Table("events").AutoMigrate(&Event1{}) if err != nil { t.Errorf("AutoMigrate err:%v", err) }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Mar 18 11:24:16 UTC 2024 - 56.2K bytes - Viewed (0) -
tests/hooks_test.go
} func TestRunCallbacks(t *testing.T) { DB.Migrator().DropTable(&Product{}) DB.AutoMigrate(&Product{}) p := Product{Code: "unique_code", Price: 100} DB.Save(&p) if !reflect.DeepEqual(p.GetCallTimes(), []int64{1, 1, 0, 1, 1, 0, 0, 0, 0}) {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Jun 17 03:59:06 UTC 2024 - 16.7K bytes - Viewed (0) -
tests/embedded_struct_test.go
BasePost BasePost `gorm:"Embedded"` Author *Author `gorm:"Embedded;EmbeddedPrefix:author_"` // Embedded struct ImageUrl string } DB.Migrator().DropTable(&HNPost{}, &EngadgetPost{}) if err := DB.Migrator().AutoMigrate(&HNPost{}, &EngadgetPost{}); err != nil { t.Fatalf("failed to auto migrate, got error: %v", err) } for _, name := range []string{"author_id", "author_name", "author_email"} {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed May 08 04:07:58 UTC 2024 - 7.3K bytes - Viewed (0) -
tests/preload_test.go
ValueID uint } Value struct { ID uint Name string Nested Nested } ) DB.Migrator().DropTable(&Preload{}, &Join{}, &Nested{}, &Value{}) DB.Migrator().AutoMigrate(&Preload{}, &Join{}, &Nested{}, &Value{}) value1 := Value{ Name: "value", Nested: Nested{ Preloads: []*Preload{ {Value: "p1"}, {Value: "p2"}, }, Join: Join{Value: "j1"}, },
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed Jun 12 10:00:47 UTC 2024 - 15.9K bytes - Viewed (0) -
tests/non_std_test.go
unexported string // unexported value CreatedAt time.Time UpdatedAt time.Time } func TestNonStdPrimaryKeyAndDefaultValues(t *testing.T) { DB.Migrator().DropTable(&Animal{}) if err := DB.AutoMigrate(&Animal{}); err != nil { t.Fatalf("no error should happen when migrate but got %v", err) } animal := Animal{Name: "Ferdinand"} DB.Save(&animal) updatedAt1 := animal.UpdatedAt
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed May 08 04:07:58 UTC 2024 - 1.9K bytes - Viewed (0) -
tests/tests_test.go
DB.Migrator().DropTable("user_friends", "user_speaks") if err = DB.Migrator().DropTable(allModels...); err != nil { log.Printf("Failed to drop table, got error %v\n", err) os.Exit(1) } if err = DB.AutoMigrate(allModels...); err != nil { log.Printf("Failed to auto migrate, but got error %v\n", err) os.Exit(1) } for _, m := range allModels { if !DB.Migrator().HasTable(m) {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Sep 30 03:21:19 UTC 2024 - 3.3K bytes - Viewed (0) -
tests/create_test.go
CheckPet(t, *pet, *pet) } }) } func TestCreateEmptyStruct(t *testing.T) { type EmptyStruct struct { ID uint } DB.Migrator().DropTable(&EmptyStruct{}) if err := DB.AutoMigrate(&EmptyStruct{}); err != nil { t.Errorf("no error should happen when auto migrate, but got %v", err) } if err := DB.Create(&EmptyStruct{}).Error; err != nil {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Tue Mar 19 03:50:28 UTC 2024 - 26.4K bytes - Viewed (0) -
tests/default_value_test.go
Age int `gorm:"default:18"` Created time.Time `gorm:"default:2000-01-02"` Enabled bool `gorm:"default:true"` } DB.Migrator().DropTable(&Harumph{}) if err := DB.AutoMigrate(&Harumph{}); err != nil { t.Fatalf("Failed to migrate with default value, got error: %v", err) } harumph := Harumph{Email: "******@****.***"} if err := DB.Create(&harumph).Error; err != nil {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Apr 08 03:29:55 UTC 2024 - 2.3K bytes - Viewed (0) -
tests/scopes_test.go
t.Errorf("Should found two users's name in 1, 3, but got %v", len(users3)) } db := DB.Scopes(func(tx *gorm.DB) *gorm.DB { return tx.Table("custom_table") }).Session(&gorm.Session{}) db.AutoMigrate(&User{}) if db.Find(&User{}).Statement.Table != "custom_table" { t.Errorf("failed to call Scopes") } result := DB.Scopes(NameIn1And2, func(tx *gorm.DB) *gorm.DB { return tx.Session(&gorm.Session{})
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Fri Jan 12 08:42:21 UTC 2024 - 3.3K bytes - Viewed (0) -
tests/update_test.go
type ElementWithIgnoredField struct { Id int64 Value string IgnoredField int64 `gorm:"-"` } DB.Migrator().DropTable(&ElementWithIgnoredField{}) DB.AutoMigrate(&ElementWithIgnoredField{}) elem := ElementWithIgnoredField{Value: "foo", IgnoredField: 10} DB.Save(&elem) DB.Model(&ElementWithIgnoredField{}). Where("id = ?", elem.Id).
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Dec 04 03:50:58 UTC 2023 - 30.3K bytes - Viewed (0)