MCPcopy
hub / github.com/go-gorm/gorm / TestMigrateWithQuotedIndex

Function TestMigrateWithQuotedIndex

tests/migrate_test.go:456–473  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

454}
455
456func TestMigrateWithQuotedIndex(t *testing.T) {
457 if DB.Dialector.Name() != "mysql" {
458 t.Skip()
459 }
460
461 type QuotedIndexStruct struct {
462 gorm.Model
463 Name string `gorm:"size:255;index:AS"` // AS is one of MySQL reserved words
464 }
465
466 if err := DB.Migrator().DropTable(&QuotedIndexStruct{}); err != nil {
467 t.Fatalf("Failed to drop table, got error %v", err)
468 }
469
470 if err := DB.AutoMigrate(&QuotedIndexStruct{}); err != nil {
471 t.Fatalf("Failed to auto migrate, but got error %v", err)
472 }
473}
474
475func TestMigrateIndexes(t *testing.T) {
476 type IndexStruct struct {

Callers

nothing calls this directly

Calls 4

NameMethod · 0.65
DropTableMethod · 0.65
MigratorMethod · 0.65
AutoMigrateMethod · 0.65

Tested by

no test coverage detected