Package Data | |
---|---|
Maintainer Username: | nobodyiscertain |
Maintainer Contact: | hello@jamiewagner.me (Jamie Wagner) |
Package Create Date: | 2015-11-21 |
Package Last Update: | 2022-03-26 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:02:11 |
Package Statistics | |
---|---|
Total Downloads: | 2,234 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 1 |
Total Forks: | 1 |
Total Open Issues: | 1 |
Here are few Artisan commands to help with common database tasks. This package currently handles:
Note: Currently, this package only supports MySQL. Should you have a need for a different database driver, please open an issue or feel free to fork and pull request away.
Install with Composer:
composer require nobodyiscertain/laravel-db-commands
Add service provider to config/app.php:
Nobodyiscertain\DbCommands\DbCommandsServiceProvider::class
On the command line, run:
php artisan vendor:publish
This will publish the config file laravel-db-commands.php
to your
config directory. You will need to configure that to match your setup
and you should be good to go! Details on the configuration for each of
the commands can be found below.
This command makes it a snap to pull a database dump from a specific
environment. After you have it configured, a simple php artisan db:pull production
will pull the production database and import it locally.
php artisan db:pull <db_connection_name>
db_connection_name
: Pass in the name of the connection used in your
config/database.php
that you'd like to pull.
dbpull_auto_import
: If you would like the database to be auto imported
locally after it's pulled, set this to true, otherwise, false.
dbpull_local_db_conn
: Set this to the name of your local db connection
you'd like the dump imported to.
dbpull_dump_destination
: Set this to a local path you'd like the dump
to be stored. I generally use /tmp
so it'll get wiped.
This command saves the hassle of typing the lengthy artisan command to refresh the testing database and, optionally, run the seeds. Inspried by a similar command in Rails.
php artisan db:test-prepare
testing_db_connection
: Set this to the name of the testing database
connection configured in config/database.php
.
testing_run_seeds
: If you'd like to run the seeds after the database
is refreshed, set this to true, otherwise, false.
This command will pull a database dump and upload it to a configured filesystem location. It's great for making one off backups or scheduling with Artisan to make automated backups a breeze.
php artisan db:backup
backup_db_conn
: This is the name of database connection in
config/database.php
you'd like to backup. Keep in mind the context of
where this command will run. If it's going to be run on the a prodcution
server, then most likely it'll be your default mysql
connection.
backup_dump_destination
: A local filepath to store the database dump.
If on a UNIX-based system, /tmp
works great.
backup_disk
: This is the disk name from config/filesystems.php
that
you'd like to permanently store the database dump.
If you'd like to setup automated backups, drop in something like this
into app/Console/Kernal.php
.
$schedule->command('db:backup')->twiceDaily();