Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/hanami/cli/commands/app/db/drop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Drop < App::Command
desc "Delete database"

# @api private
def call(**)
if database.drop_command
def call(force: false)
if database.drop_command(force:)
out.puts "=> database #{database.name} dropped"
else
out.puts "=> failed to drop #{database.name}"
Expand Down
2 changes: 1 addition & 1 deletion lib/hanami/cli/commands/app/db/utils/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def create_command
end

# @api private
def drop_command
def drop_command(force: false)
raise Hanami::CLI::NotImplementedError
end

Expand Down
6 changes: 4 additions & 2 deletions lib/hanami/cli/commands/app/db/utils/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ def create_command
end

# @api private
def drop_command
system(cli_env_vars, "dropdb #{escaped_name}")
def drop_command(force: false)
command = force ? "dropdb --force" : "dropdb"

system(cli_env_vars, "#{command} #{escaped_name}")
end

# @api private
Expand Down
2 changes: 1 addition & 1 deletion lib/hanami/cli/commands/app/db/utils/sqlite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def create_command
end

# @api private
def drop_command
def drop_command(**)
file_path.unlink
true
end
Expand Down