Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR #0A000 unimplemented at or near \"if\"" #78

Closed
hazcod opened this issue Sep 29, 2019 · 1 comment
Closed

ERROR #0A000 unimplemented at or near \"if\"" #78

hazcod opened this issue Sep 29, 2019 · 1 comment

Comments

@hazcod
Copy link

hazcod commented Sep 29, 2019

Version: "github.com/go-pg/migrations/v7"
Running against cockroachdb, which should support 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
}
@hazcod
Copy link
Author

hazcod commented Sep 29, 2019

Caused by cockroachdb/cockroach#26443

@hazcod hazcod closed this as completed Sep 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant