func migrateDb(db *sql.DB) {
driver, _ := postgres.WithInstance(db, &postgres.Config{
MigrationsTable: "migrations",
SchemaName: "myschema"})
m, _ := migrate.NewWithDatabaseInstance(
"file:///sql/migrations",
"blablabla", driver)
if err := m.Up(); err != nil {
Log("FATAL", err)
}
}
Expected Behavior
Schema myschema used for the creation of the migrations table
Migrate Version
v3.4
Loaded Database Drivers
postgres, postgresql
Duplicate of https://github.com/golang-migrate/migrate/issues/262
Try updating to v4.7+. If you still have issues, use the other thread.
This still doesn't work. If I create a new schema named "my_test_schema" and set:
postgres.Config{
DatabaseName: "testdb",
SchemaName: "my_test_schema",
}
The migration table and all the migrations will be created in the public schema.
As per my comment above, I think the issue is that in the sql files I'm not using the schema name prefixed to the table names and this is why it creates it in the public schema.
I think a "SET SCHEMA
Most helpful comment
This still doesn't work. If I create a new schema named "my_test_schema" and set:
The migration table and all the migrations will be created in the public schema.