Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added suggestion for dragon-code/laravel-data-dumper #162

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]
},
Expand Down
34 changes: 34 additions & 0 deletions docs/getting-started/database-dumper/index.md
Original file line number Diff line number Diff line change
@@ -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
```