diff --git a/composer.json b/composer.json index 781aa300..612db10f 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,8 @@ "dragon-code/laravel-migration-actions": "*" }, "suggest": { - "doctrine/dbal": "This package must be installed if you are using Laravel 10." + "doctrine/dbal": "This package must be installed if you are using Laravel 10.", + "dragon-code/laravel-data-dumper": "Required if you want to save the execution state using the `schema:dump` console command" }, "minimum-stability": "stable", "prefer-stable": true, diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 7daafb79..d6929370 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -104,6 +104,10 @@ export default defineUserConfig({ { text: 'Installation', link: '/getting-started/installation/index.md' + }, + { + text: 'Database Dumper', + link: '/getting-started/database-dumper/index.md' } ] }, diff --git a/docs/getting-started/database-dumper/index.md b/docs/getting-started/database-dumper/index.md new file mode 100644 index 00000000..8fa342ad --- /dev/null +++ b/docs/getting-started/database-dumper/index.md @@ -0,0 +1,34 @@ +# Database Dumper + +As you build your application, you may accumulate more and more migrations over time. +This can lead to your `database/migrations` directory becoming bloated with potentially hundreds of migrations. +If you would like, you may "squash" your migrations into a single SQL file. +To get started, execute the `schema:dump` command: + +```bash +php artisan schema:dump + +# Dump the current database schema and prune all existing migrations... +php artisan schema:dump --prune +``` + +You can read more about the operation of this console command in +the [official documentation](https://laravel.com/docs/11.x/migrations#squashing-migrations). + +Here we mention this console command because operations tend to save the execution state in order to prevent re-runs +where this is not explicitly allowed. +But if you run sequentially the console commands `php artisan schema:dump` and `php artisan migrate:fresh`, you will see +that all actions will be called again. + +This is due to the fact that the dump mechanism saves the contents of just one table - `migrations`. + +To solve this problem, there is a [Database Data Dumper](https://github.com/TheDragonCode/laravel-data-dumper) +project that allows you to specify a list of tables required for export to a dump. + +In addition to those that you can easily specify in its configuration file, we recommend that you also specify +the `operations` table from this project in order to save the state of the operations when performing a clean deployment +of the database from a dump. + +```bash +composer require dragon-code/laravel-data-dumper --dev +```