You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
behavior now:
db.AutoMigrate() failed when index already created
func TestSequentialAutoMigrateWithIndex(t *testing.T) {
type Migrations struct {
ID string `gorm:"primarykey;not null"`
Payload string `gorm:"index"`
}
dsn, has := os.LookupEnv("YDB_CONNECTION_STRING")
if !has {
t.Skip("skip test '" + t.Name() + "' without env 'YDB_CONNECTION_STRING'")
}
pathPrefix := t.Name()
for i := 0; i < 5; i++ {
t.Run("", func(t *testing.T) {
db, err := gorm.Open(
ydb.Open(dsn,
ydb.WithTablePathPrefix(pathPrefix),
),
)
require.NoError(t, err)
require.NotNil(t, db)
db = db.Debug()
err = db.AutoMigrate(&Migrations{})
require.NoError(t, err)
})
}
}
result:
=== RUN TestSequentialAutoMigrateWithIndex/#00
[494.824ms] [rows:0] CREATE TABLE `migrations` (`id` Utf8 NOT NULL,`payload` Utf8,PRIMARY KEY (`id`),INDEX `idx_migrations_payload` GLOBAL ON (`payload`))
--- PASS: TestSequentialAutoMigrateWithIndex/#00 (3.18s)
=== RUN TestSequentialAutoMigrateWithIndex/#01
[959.834ms] [rows:-] SELECT DATABASE()
[1095.721ms] [rows:-] SELECT count(*) FROM information_schema.statistics WHERE table_schema = $1 AND table_name = $2 AND index_name = $3
[327.297ms] [rows:0] CREATE INDEX `idx_migrations_payload` ON `migrations`(`payload`)
operation/GENERIC_ERROR (code = 400080, address = ..., issues = [{4:0 => 'Unexpected token 'CREATE' : cannot match to any predicted input...'}])
at `github.com/ydb-platform/ydb-go-sdk/v3/internal/conn.(*conn).Invoke(conn.go:361)`
at `github.com/ydb-platform/ydb-go-sdk/v3/internal/balancer.(*Balancer).wrapCall(balancer.go:293)`
at `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.(*session).executeDataQuery(session.go:733)`
at `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.(*session).Execute(session.go:688)`
at `github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*conn).execContext(conn.go:190)`
--- FAIL: TestSequentialAutoMigrateWithIndex/#01 (5.83s)
The text was updated successfully, but these errors were encountered:
https://gorm.io/docs/indexes.html
https://ydb.tech/en/docs/yql/reference/syntax/alter_table#secondary-index
behavior now:
db.AutoMigrate() failed when index already created
result:
The text was updated successfully, but these errors were encountered: