From 41b39d5177fb0986bb4561ebe43ae1c9d4730c97 Mon Sep 17 00:00:00 2001 From: Adriano Caloiaro Date: Sat, 9 Sep 2023 11:32:34 +0200 Subject: [PATCH] fix: Use neoq-specific schema migrations able When neoq is embedded in apps already use golang-migrate, they would both attempt to use the `schema_migrations` table for migrations. This commit moves neoq to its own `neoq_schema_migrations` table so as not to clash with other golang-migrate users. --- backends/postgres/postgres_backend.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backends/postgres/postgres_backend.go b/backends/postgres/postgres_backend.go index 46e9d0a..e79b039 100644 --- a/backends/postgres/postgres_backend.go +++ b/backends/postgres/postgres_backend.go @@ -187,7 +187,7 @@ func WithTransactionTimeout(txTimeout int) neoq.ConfigOption { // //nolint:funlen,gocyclo,cyclop func (p *PgBackend) initializeDB() (err error) { - d, err := iofs.New(migrationsFS, "migrations") + migrations, err := iofs.New(migrationsFS, "migrations") if err != nil { p.logger.Error("unable to run migrations", "error", err) return @@ -210,13 +210,13 @@ func (p *PgBackend) initializeDB() (err error) { sslMode = "disable" } - pqConnectionString := fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", + pqConnectionString := fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s&x-migrations-table=neoq_schema_migrations", pgxCfg.User, pgxCfg.Password, pgxCfg.Host, pgxCfg.Database, sslMode) - m, err := migrate.NewWithSourceInstance("iofs", d, pqConnectionString) + m, err := migrate.NewWithSourceInstance("iofs", migrations, pqConnectionString) if err != nil { p.logger.Error("unable to run migrations", "error", err) return