Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adding data from certain tables when executing the `php artisan schema:dump` console command

License

NotificationsYou must be signed in to change notification settings

TheDragonCode/laravel-data-dumper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

the dragon code database data dumper

Stable VersionTotal DownloadsGithub Workflow StatusLicense

Introduction

Thesquashing migrations in Laravel does not export datafrom tables?

There is a solution!

How it works?

After installing and configuring the package, you simply run the console commandphp artisan schema:dump (with orwithout flags - it's up to you), and the final SQL dump file will contain the data structure including the contents ofthe tables you specified at the configuration stage.

This will allow you to painlessly execute thephp artisan schema:dump --prune command, which will remove unnecessarymigration files.

Requirements

  • Laravel 10, 11, 12
  • PHP 8.2 or higher
  • Databases:
    • Sqlite 3
    • MySQL 5.7, 8, 9
    • PostgreSQL 12, 13, 14, 15, 16, 17

Installation

To get the latest version ofDatabase Data Dumper, simply require the projectusingComposer:

composer require dragon-code/laravel-data-dumper

Or manually updaterequire block ofcomposer.json and runcomposer update.

{"require": {"dragon-code/laravel-data-dumper":"^1.0"    }}

Configuration

Since Laravel mechanism for publishing configuration files does not allow them to be merged on the fly,a new array element must be added to theconfig/database.php file:

return [/*    |--------------------------------------------------------------------------    | Schema Settings    |--------------------------------------------------------------------------    |    | This block will contain the names of the tables for which it is    | necessary to export data along with the table schema.    |    */'schema' => ['tables' => [// 'foo',// 'bar',// App\Models\Article::class,// 'qwerty1' => ['column_name_1', 'database/foo'],// 'qwerty2' => ['column_name_2', __DIR__ . '/../bar'],        ],    ],];

After that, add to the array the names of the tables for which you want to export data.

That's it. Now you can run thephp artisan schema:dumpconsole command and enjoy the result.

Note

If you need to delete files from a folder to which a table is related (for example, themigrations table),you can specify an array of two values in the parameter, where the first element should be the name of the columncontaining the file name, and the second element should be absolute or relative folder path.

Warning

Laravel 11.35.2 and below does not know how to report the presence of the--prune parameter when calling theartisan schema:dump console command, so specifying paths to folders will always delete files from them.

Starting with Laravel version 11.36, files will be deleted only when calling the console command with the--prune parameter.

License

This package is licensed under theMIT License.

About

Adding data from certain tables when executing the `php artisan schema:dump` console command

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

    Contributors5

    Languages


    [8]ページ先頭

    ©2009-2025 Movatter.jp