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

Duplicated 'migrations' table when using schemas #16

Open
EyMaddis opened this issue Feb 28, 2017 · 6 comments · May be fixed by #49
Open

Duplicated 'migrations' table when using schemas #16

EyMaddis opened this issue Feb 28, 2017 · 6 comments · May be fixed by #49

Comments

@EyMaddis
Copy link

EyMaddis commented Feb 28, 2017

When using a schema: 'mySchema' configuration in the database.json, I can run db-migrate and it will create a migrations table on the publicschema. Running the migration again leads to a secondmigrationstable inside themySchema` schema.

I would guess that this might require a better configuration possibility for the migrations schema which is currently only possible via the --table my_migrations command line argument. I would like to configure a like like myOtherSchema.my_migrations, because I don't want to mix real/customer data with technical data (migrations).

Sidenote: is it possible to configure the migration table via the database.json? I tried, but failed.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@wzrdtales
Copy link
Member

@EyMaddis No you can't configure it via the database.json and currently you can't, but on the latest master branch there already is the rc config included which will allow you to do so via a .dbmigraterc config. About the behavior, this is really strange, can you provide me a full example to reproduce this?

@justinnguyen
Copy link

I ran into the same issue. What it ended up being for me was that my first migration script was creating the schema that I had configured in my schema field in database.json. Because this schema didn't exist until the first migration was run, the migrations table was created in the public schema the first time I ran db-migrate. On the next run, another migrations table was created in my configured schema, but because it is empty, all of my migrations are run all over again.

@ghost
Copy link

ghost commented Jun 18, 2018

Bump. Completely same behavior as @justinnguyen describe. Any progress on that?

@mo
Copy link

mo commented Jun 29, 2019

Bump. I hit the same issue as @justinnguyen and @igorlysak hit.

@mo
Copy link

mo commented Jun 29, 2019

I think it would be good if db-migrate-pg just checked if the schema specified in database.json exists, and if not then it should be created before the actual migrations start.

drakmail added a commit to drakmail/pg that referenced this issue Apr 9, 2020
Create db-migrate schema before creation of migrations table
@drakmail drakmail linked a pull request Apr 9, 2020 that will close this issue
@Kaltemrix
Copy link

Any update on when the above PR will be merged in?

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

Successfully merging a pull request may close this issue.

5 participants