- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 30 for AutoMigrate (0.1 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) -
migrator.go
for len(tx.Statement.scopes) > 0 { tx = tx.executeScopes() } return tx.Dialector.Migrator(tx.Session(&Session{})) } // AutoMigrate run auto migration for given models func (db *DB) AutoMigrate(dst ...interface{}) error { return db.Migrator().AutoMigrate(dst...) } // ViewOption view option type ViewOption struct { Replace bool // If true, exec `CREATE`. If false, exec `CREATE OR REPLACE`
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Oct 30 09:15:49 UTC 2023 - 3.1K bytes - Viewed (0) -
tests/postgres_test.go
type CompanyNew struct { ID int Name int } func TestAlterColumnDataType(t *testing.T) { DB.AutoMigrate(Company{}) if err := DB.Table("companies").Migrator().AlterColumn(CompanyNew{}, "name"); err != nil { t.Fatalf("failed to alter column from string to int, got error %v", err) } DB.AutoMigrate(Company{})
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Sat Oct 08 09:16:32 UTC 2022 - 6.4K bytes - Viewed (0) -
tests/preload_suits_test.go
Level1 Level1 Level3ID uint } Level3 struct { ID uint Name string Level2 Level2 } ) DB.Migrator().DropTable(&Level3{}, &Level2{}, &Level1{}) if err := DB.AutoMigrate(&Level3{}, &Level2{}, &Level1{}); err != nil { t.Error(err) } want := Level3{Level2: Level2{Level1: Level1{Value: "value"}}} if err := DB.Create(&want).Error; err != nil { t.Error(err) }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Fri Mar 18 05:38:46 UTC 2022 - 30.3K 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/associations_test.go
gorm.Model Number string MemberID uint `gorm:"not null"` } type Member struct { gorm.Model Profiles []Profile } DB.Migrator().DropTable(&Member{}, &Profile{}) if err := DB.AutoMigrate(&Member{}, &Profile{}); err != nil { t.Fatalf("Failed to migrate, got error: %v", err) } member := &Member{ Profiles: []Profile{{ Number: "1", }, { Number: "2", }}, }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed Feb 08 08:29:09 UTC 2023 - 10.9K 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/error_translator_test.go
if supported, found := dialectors[db.Dialector.Name()]; !(found && supported) { return } DB.Migrator().DropTable(&City{}) if err = db.AutoMigrate(&City{}); err != nil { t.Fatalf("failed to migrate cities table, got error: %v", err) } err = db.Create(&City{Name: "Kabul"}).Error if err != nil { t.Fatalf("failed to create record: %v", err) }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed Jul 12 13:21:22 UTC 2023 - 3.1K bytes - Viewed (0) -
tests/serializer_test.go
} func TestSerializer(t *testing.T) { schema.RegisterSerializer("custom", NewCustomSerializer("hello")) DB.Migrator().DropTable(adaptorSerializerModel(&SerializerStruct{})) if err := DB.Migrator().AutoMigrate(adaptorSerializerModel(&SerializerStruct{})); err != nil { t.Fatalf("no error should happen when migrate scanner, valuer struct, got error %v", err) } createdAt := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Fri Apr 21 14:09:38 UTC 2023 - 7.6K bytes - Viewed (0) -
tests/customize_field_test.go
ID int64 `gorm:"column:mapped_id; primary_key:yes"` Name string `gorm:"column:mapped_name"` Date *time.Time `gorm:"column:mapped_time"` } DB.Migrator().DropTable(&CustomizeColumn{}) DB.AutoMigrate(&CustomizeColumn{}) expected := "foo" now := time.Now() cc := CustomizeColumn{ID: 666, Name: expected, Date: &now} if count := DB.Create(&cc).RowsAffected; count != 1 {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Fri Sep 11 09:33:31 UTC 2020 - 6.9K bytes - Viewed (0)