nachopitt / db-commands
Artisan commands for managing databases.
v0.6.0
2026-07-16 06:56 UTC
Requires
- php: ^8.2
- laravel/framework: ^11.0|^12.0|^13.0
- symfony/process: ^7.0|^8.0
Requires (Dev)
- laravel/pint: ^1.13
- mockery/mockery: ^1.6
- orchestra/testbench: ^9.0|^10.0|^11.0
- phpunit/phpunit: ^11.0
- shipmonk/composer-dependency-analyser: ^1.8
README
A set of Laravel Artisan commands for database management.
Installation
You can install the package via composer:
composer require nachopitt/db-commands
Usage
db:create
Create a new MySQL database.
php artisan db:create {name?} {--c|connection=}
| Argument / Option | Description |
|---|---|
name |
The name of the MySQL database to create. If not provided, the command will use the database name from your configuration. |
--connection |
The database connection to use (e.g. mysql). Defaults to the active default connection. |
db:drop
Drop an existing MySQL database.
php artisan db:drop {name?} {--c|connection=} {--force}
| Argument / Option | Description |
|---|---|
name |
The name of the MySQL database to drop. If not provided, the command will use the database name from your configuration. |
--connection |
The database connection to use. Defaults to the active default connection. |
--force |
Force the operation to run without prompting for confirmation. |
db:export
Export an existing MySQL database into SQL statements.
php artisan db:export {schema?} {--c|connection=} {--skip-ssl}
| Argument / Option | Description |
|---|---|
schema |
The name of the MySQL database to export. If not provided, the command will use the database name from your configuration. |
--connection |
The database connection to use. Defaults to the active default connection. |
--skip-ssl |
Bypass SSL certificate verification for the mysqldump command. |
db:import
Import a SQL file into an existing MySQL database.
php artisan db:import {file?} {--s|schema=} {--i|ignore-foreign-key-checks} {--c|connection=}
| Argument / Option | Description |
|---|---|
file |
The path to the SQL file to import. If not provided, the command will use database_model/{database}.sql. |
--schema |
The name of the MySQL database to import into. If not provided, the command will use the database name from your configuration. |
--ignore-foreign-key-checks |
Ignore foreign key checks while importing. |
--connection |
The database connection to use. Defaults to the active default connection. |
db:truncate
Truncate tables from a MySQL database.
php artisan db:truncate {tables?} {--s|schema=} {--i|ignore-foreign-key-checks} {--c|connection=}
| Argument / Option | Description |
|---|---|
tables |
A comma-separated list of tables to truncate. If not provided, the command will truncate all tables in the database. |
--schema |
The name of the MySQL database to truncate tables from. If not provided, the command will use the database name from your configuration. |
--ignore-foreign-key-checks |
Ignore foreign key checks while truncating. |
--connection |
The database connection to use. Defaults to the active default connection. |
Testing
You can run the automated tests via:
composer test
License
The MIT License (MIT). Please see License File for more information.