hanami / hanami/hanami-cli

Either always `force` psql drop or allow `force` as option

Open
#82 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
33
Forks
55
Avg merge
8d 7h
Merged PRs (30d)
2

Description

**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 a `hanami console` session.

![image](https://user-images.githubusercontent.com/10784051/229680065-fbd05716-2d47-4f35-8cf8-7c58203d720e.png)

Couple other possible approaches are:

```ruby
# create a dedicated method for force drop
def force_drop_command
system(cli_env_vars, "dropdb --force #{escaped_name}")
end
```
```ruby
# force as option/param
def drop_command(force=false)
command_prefix = force ? "dropdb --force" : "dropdb"

system(cli_env_vars, "#{command_prefix} #{escaped_name}")
end
```

**Reference:**
https://www.postgresql.org/docs/current/sql-dropdatabase.html#id-1.9.3.108.6

PR with proposal:
https://github.com/hanami/cli/pull/81

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.