在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):spatie/laravel-db-snapshots开源软件地址(OpenSource Url):https://github.com/spatie/laravel-db-snapshots开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):Quickly dump and load databasesThis package provides Artisan commands to quickly dump and load databases in a Laravel application. # Create a dump
php artisan snapshot:create my-first-dump
# Make some changes to your db
# ...
# Create another dump
php artisan snapshot:create my-second-dump
# Load up the first dump
php artisan snapshot:load my-first-dump
# Load up the latest dump
php artisan snapshot:load --latest
# List all snapshots
php artisan snapshot:list
# Remove old snapshots. Keeping only the most recent
php artisan snapshot:cleanup --keep=2 This package supports MySQL, PostgreSQL and SQLite. Support usWe invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products. We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall. Support usWe invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products. We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall. Installation
You can install the package via Composer: composer require spatie/laravel-db-snapshots You should add a disk named // ...
'disks' => [
// ...
'snapshots' => [
'driver' => 'local',
'root' => database_path('snapshots'),
],
// ... Optionally, you may publish the configuration file with: php artisan vendor:publish --provider="Spatie\DbSnapshots\DbSnapshotsServiceProvider" --tag="config" This is the content of the published file: return [
/**
* The name of the disk on which the snapshots are stored.
*/
'disk' => 'snapshots',
/**
* The connection to be used to create snapshots. Set this to null
* to use the default configured in `config/database.php`
*/
'default_connection' => null,
/**
* The directory where temporary files will be stored.
*/
'temporary_directory_path' => storage_path('app/laravel-db-snapshots/temp'),
/*
* Create dump files that are gzipped
*/
'compress' => false,
/*
* Only these tables will be included in the snapshot. Set to `null` to include all tables.
*
* Default: `null`
*/
'tables' => null,
]; UsageTo create a snapshot (which is just a dump from the database) run: php artisan snapshot:create my-first-dump Giving your snapshot a name is optional. If you don't pass a name the current date time will be used: # Creates a snapshot named something like `2017-03-17 14:31`
php artisan snapshot:create Maybe you only want to snapshot a couple of tables. You can do this by passing the # Bot commands create a snapshot containing only the posts and users tables:
php artisan snapshot:create --table=posts,users
php artisan snapshot:create --table=posts --table=users When creating snapshots, you can optionally create compressed snapshots. To do this either pass the # Creates a snapshot named my-compressed-dump.sql.gz
php artisan snapshot:create my-compressed-dump --compress After you've made some changes to the database you can create another snapshot: php artisan snapshot:create my-second-dump To load a previous dump issue this command: php artisan snapshot:load my-first-dump To load a previous dump to another DB connection: php artisan snapshot:load my-first-dump --connection=connectionName By default, php artisan snapshot:load my-first-dump --drop-tables=0 By default, php artisan snapshot:load my-first-dump --stream To list all the dumps run: php artisan snapshot:list A dump can be deleted with: php artisan snapshot:delete my-first-dump To remove all backups except the most recent 2 php artisan snapshot:cleanup --keep=2 If you need to pass extra options to the underlying db-dumper, add a
To the EventsThere are several events fired which can be used to perform some logic of your own:
Testingcomposer test ChangelogPlease see CHANGELOG for more information on what has changed recently. ContributingPlease see CONTRIBUTING for details. Security VulnerabilitiesPlease review our security policy on how to report security vulnerabilities. CreditsLicenseThe MIT License (MIT). Please see License File for more information. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论