add test: update: TestAutoMigrateInt8PG

This commit is contained in:
viatoriche / Maxim Panfilov 2022-10-14 11:25:46 +03:00
parent f320b86057
commit 560912d349

View File

@ -10,6 +10,7 @@ import (
"time" "time"
"gorm.io/driver/postgres" "gorm.io/driver/postgres"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/schema" "gorm.io/gorm/schema"
. "gorm.io/gorm/utils/tests" . "gorm.io/gorm/utils/tests"
@ -89,8 +90,8 @@ func TestAutoMigrateInt8PG(t *testing.T) {
Logger: DB.Config.Logger, Logger: DB.Config.Logger,
Test: func(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error) { Test: func(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error) {
sql, _ := fc() sql, _ := fc()
if sql == "ALTER TABLE \"migrate_ints\" ALTER COLUMN \"int8\" TYPE smallint" { if strings.HasPrefix(sql, "ALTER TABLE \"migrate_ints\" ALTER COLUMN \"int8\" TYPE smallint") {
t.Fatalf("shouldn't execute ALTER COLUMN TYPE if such type is already existed in DB schema") t.Fatalf("shouldn't execute ALTER COLUMN TYPE if such type is already existed in DB schema: sql: %s", sql)
} }
}, },
} }