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

SchemaName is ignored for postgres.Config #342

Closed
pashagolub opened this issue Feb 15, 2020 · 3 comments
Closed

SchemaName is ignored for postgres.Config #342

pashagolub opened this issue Feb 15, 2020 · 3 comments
Labels
duplicate This issue or pull request already exists

Comments

@pashagolub
Copy link

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

@dhui dhui added the duplicate This issue or pull request already exists label Feb 15, 2020
@dhui
Copy link
Member

dhui commented Feb 15, 2020

Duplicate of #262
Try updating to v4.7+. If you still have issues, use the other thread.

@dhui dhui closed this as completed Feb 15, 2020
@feketegy
Copy link

feketegy commented Mar 3, 2020

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.

@feketegy
Copy link

feketegy commented Mar 3, 2020

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 " should be issued before running the migrations to make sure any sql that's read is appended on the correct schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants