Code Monkey home page Code Monkey logo

Comments (6)

wzrdtales avatar wzrdtales commented on September 25, 2024

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.

vertiman avatar vertiman commented on September 25, 2024

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.

wzrdtales avatar wzrdtales commented on September 25, 2024

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.

wzrdtales avatar wzrdtales commented on September 25, 2024

yes they are, they get passed as config object here https://github.com/db-migrate/pg/blob/master/index.js#L486

from pg.

vertiman avatar vertiman commented on September 25, 2024

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.

wzrdtales avatar wzrdtales commented on September 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.