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.
I'm not sure what would be your favourite flavour here this or that:
command = "dropdb"
if force
command << " --force"
end|
|
||
| # @api private | ||
| def drop_command | ||
| def drop_command(**) |
There was a problem hiding this comment.
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 resetit will fail if the user has any other ongoing connection, like a connection to db client(like dbeaver), or ahanami consolesession.Couple other possible approaches are:
Reference:
https://www.postgresql.org/docs/current/sql-dropdatabase.html#id-1.9.3.108.6