Comments (6)
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?
from pg.
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?
from pg.
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:
Open up a "maintenance" connection on the driver and connect to the default db to execute this kinds of queries. This connection gets either opened on demand and closed instantly after the action has taken place or is opened on the driver creation.
From the point that it is currently not implemented as a feature to switch the database when using scopes see https://github.com/db-migrate/pg/blob/master/index.js#L105-L121 and http://db-migrate.readthedocs.org/en/latest/Getting%20Started/the%20commands/#scope-configuration, it might be from interest to look at the possibility of creating new connections and disposing old ones, or replacing them, on the pg driver level.
from pg.
yes they are, they get passed as config object here https://github.com/db-migrate/pg/blob/master/index.js#L486
from pg.
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?
from pg.
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.
from pg.
Related Issues (20)
- Invalid SQL Syntax when generating Table with Foreign Key HOT 5
- Scope Configuration doesn't work with Postgres HOT 3
- Fails to assert pg version correctly
- [ERROR] AssertionError [ERR_ASSERTION]: ifError got unwanted exception: self signed certificate
- supporting multiple host in connection string does not work. HOT 1
- Changelog is outdated
- Feature Request - env. variable for setting migrations table schema DATABASE_SCHEMA
- BUG: Schema option is not reflected
- "The driver you are using does not support the new state management." HOT 4
- Not able to add enum value through Migration script HOT 1
- The server does not support SSL connections HOT 1
- Failed to drop database! error: cannot drop the currently open database
- DELETE HOT 3
- Replace vows with supported test suite
- BUG: Support for Postgres 15 HOT 2
- broken version 1.2.3 HOT 2
- No such driver found HOT 11
- Lib broken in node v12 HOT 3
- ssl configs are not working HOT 1
- error: type "string" does not exist HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg.