-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Update psql drop_command to force dropdb #81
base: main
Are you sure you want to change the base?
Conversation
The reason behind it is to improve developer experience, as right now when running a command like `hanami db reset` it will fail if the user has any other ongoing connection, like a connection to db client(like dbeaver), or a `hanami console` session.
I don't think we should use force by default, but making it an option would be 👍 |
Give the DB drop command the option to force drop the Database
0902c35
to
0fec282
Compare
def drop_command | ||
system(cli_env_vars, "dropdb #{escaped_name}") | ||
def drop_command(force: false) | ||
command = force ? "dropdb --force" : "dropdb" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what would be your favourite flavour here this or that:
command = "dropdb"
if force
command << " --force"
end
@@ -17,7 +17,7 @@ def create_command | |||
end | |||
|
|||
# @api private | |||
def drop_command | |||
def drop_command(**) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like "unlink" doesn't support any params, so nothing to do here
https://apidock.com/ruby/Pathname/unlink
@parndt @timriley thanks for the follow up, I have updated the PR according to the conversation above, let me know if I got it right. I could not find document to update regard that interface change (making the I would appreciate some help here on how to use it....given I have the following on my if this PR gets merged I would update my "db drop" register command to this? Hanami::CLI.register "db drop", Hanami::CLI::Commands::App::DB::Drop.new(force: true) also would the other commands "follow" on the "force" ? I mean, if I call "db reset" would it use the "db drop" with the https://github.com/hanami/cli/blob/main/lib/hanami/cli/commands/app/db/reset.rb I highly appreciate you guys putting the time to look at this PR, thanks again! |
Context:
The reason behind it is to improve developer experience, as right now when running a command like
hanami db reset
it will fail if the user has any other ongoing connection, like a connection to db client(like dbeaver), or ahanami console
session.Couple other possible approaches are:
Reference:
https://www.postgresql.org/docs/current/sql-dropdatabase.html#id-1.9.3.108.6