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

Add append mode #219

Merged
merged 2 commits into from
Feb 14, 2025
Merged

Add append mode #219

merged 2 commits into from
Feb 14, 2025

Conversation

LBannenberg
Copy link
Contributor

This PR adds the possibility of appending (using >> ) instead of overwriting ( > ) when dumping a MySQL DB to a file.

This is useful when doing a two-step dump, where in the first step you dump the whole schema, and in the second step you dump the contents of only some tables. For example:

  • Dump a copy of a production database for a webshop, keeping product data but stripping customer data.
  • Dump a copy of a database where you only keep the migrations table.

For an extended example of that functionality, see https://github.com/netz98/n98-magerun/wiki/Stripped-Database-Dumps ; I've implemented it myself in https://github.com/LBannenberg/laravel-mysqldump

I was able to do it myself ( https://github.com/LBannenberg/laravel-mysqldump ) by extending \Spatie\DbDumper\Databases\MySql , but with this PR that would not be needed anymore, especially now that #208 made the doNotDumpData() command available.

Because I'm not sure if this functionality also makes sense for other DBs than MySQL I only added the method to set the flag in \Spatie\DbDumper\Databases\MySql, but the flag is used in the main \Spatie\DbDumper\DbDumper class. This seemed preferable to copying the echoToFile command to \Spatie\DbDumper\Databases\MySql .

I added an exception when trying to combine append-mode with compressors because I don't expect that behavior to be compatible.

@freekmurze freekmurze merged commit c295baa into spatie:main Feb 14, 2025
11 checks passed
@freekmurze
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants