wheels db drop
Drop an existing database.
Synopsis
Description
The wheels db drop
command permanently deletes a database. This is a destructive operation that cannot be undone. By default, it requires confirmation unless the --force
flag is used.
Options
--datasource=
Specify which datasource's database to drop. If not provided, uses the default datasource from your Wheels configuration.
--environment=
Specify the environment to use. Defaults to the current environment.
--force
Skip the confirmation prompt. Useful for scripting.
Examples
Basic Usage
Drop database with confirmation:
Force Drop
Drop without confirmation:
Drop Test Database
Safety Features
Confirmation Required: By default, you must type "yes" to confirm
Production Warning: Extra warning when dropping production databases
Clear Messaging: Shows database name and environment before dropping
Database-Specific Behavior
MySQL/MariaDB
Uses
DROP DATABASE IF EXISTS
statementConnects to
information_schema
to execute command
PostgreSQL
Terminates existing connections before dropping
Uses
DROP DATABASE IF EXISTS
statementConnects to
postgres
system database
SQL Server
Sets database to single-user mode to close connections
Uses
DROP DATABASE IF EXISTS
statementConnects to
master
system database
H2
Deletes database files (.mv.db, .lock.db, .trace.db)
Shows which files were deleted
Warning
This operation is irreversible! Always ensure you have backups before dropping a database.
Best Practices
Always backup first:
Use --force carefully: Only in scripts where you're certain
Double-check environment: Especially important for production
Error Messages
"Database not found"
The database doesn't exist. No action needed.
"Access denied"
The database user doesn't have permission to drop databases. Grant DROP privileges to the user.
"Database in use"
Some databases prevent dropping while connections are active. The command attempts to close connections automatically.
Related Commands
wheels db create
- Create a new databasewheels db reset
- Drop and recreate databasewheels db dump
- Backup before dropping
Last updated
Was this helpful?