-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Drop Db doesn't (can't) work if connected to the db you want to drop #3
Comments
Hum, ic. This is problematic indeed, quick thought, if it is not possible to delete the db you're connected to. I assume it is also not possible to delete a db as long as at least one 1 connection is open to it? |
Yeah, although I think you can issue commands to drop others connections. Are you thinking establish a separate connection inside the dropDatabase on a different database? Are all the connection parameters (login, password, host) available in that scope? |
Ok, I take a few minutes of my time now for a quick write up: Since postgres is always only connected to one db per connection and it is not possible to switch (I already stumbled this when I implemented the scopes a while ago) dbs and now it opens that it is also not possible to delete dbs. What I can think of is: |
yes they are, they get passed as config object here https://github.com/db-migrate/pg/blob/master/index.js#L486 |
Ok I'll fiddle with this over the next few days. Need to work on something else first. Thanks for the idea, it will probably work. From a usage perspective, can you do a db:drop at the same time as any other command? I don't think so, right? So we don't have to worry about someone polluting the "main" connection, if I manage to programatically kill it? |
It would be possible, but I do not see a reason why one would execute a drop action in another instance of db-migrate while migrating something. |
The Drop DB command doesn't work if you're trying to drop the database which you're connected to. You can get around this by creating another environment that connects to the template1 or postgres database, and then drop the one you want.
I can't think of an intelligent way to bake this behaviour into the driver so we don't need to use a workaround, any ideas? If you have an implementation idea I'm happy to take a stab at implementing it.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: