Closed hazcod closed 5 years ago
Version: "github.com/go-pg/migrations/v7" Running against cockroachdb, which should support IF EXISTS.
"github.com/go-pg/migrations/v7"
IF EXISTS
Error:
ERROR #0A000 unimplemented at or near \"if\""
Code:
func MigrateDatabase(db *pg.DB, schemaName string) error { // set the metadata table name migrations.SetTableName(fmt.Sprintf("%s.%s", schemaName, migrationsTableName)) // discover the local migration files if err := migrations.DefaultCollection.DiscoverSQLMigrations(migrationsPath); err != nil { return errors.New(fmt.Sprintf("could not discover migrations: %v", err)) } // try intializing the migrations meta table and migrating log.Debug("initializing migrations database") _, _, err := migrations.Run(db, "init") if err != nil { log.Warnf("could not init migrations: %v", err) } log.Debugf("migrating database") oldVersion, newVersion, err := migrations.Run(db, "up") if err != nil { return errors.New(fmt.Sprintf("could not migrate: %v", err)) } log.Debugf("upgraded db from version %d to version %d", oldVersion, newVersion) return nil }
Caused by https://github.com/cockroachdb/cockroach/issues/26443
Version:
"github.com/go-pg/migrations/v7"
Running against cockroachdb, which should supportIF EXISTS
.Error:
Code: