Replies: 2 comments
-
I am going to tag @taylorotwell here, since code history shows you being the author of many parts of this code. I hope that's okay |
Beta Was this translation helpful? Give feedback.
0 replies
-
Another use case: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
Today we encountered an issue while executing the
schema:dump
command in our Laravel app. Our app is connected to a database that contains about 400 tables. The execution ofphp artisan schema:dump
took about 2:30 minutes, while being connected to our staging database. On its own, this wouldn't pose a problem. The actual problem emerges when trying to access the app/database during the execution: The app won't load at all, since the entire database is locked bymysqldump
during the whole time.Solution
mysqldump
offers an option called--single-transaction
, which runs the dump command on a temporary snapshot. When only dumping the database structure - likeschema:dump
does - this should be the preferred way of dealing with larger databases.Possible implementations
Note: All three solutions only target the MySQL schema, since I am not familiar with PostgreSQL or SQLite and potential similar options.
Add
--single-transaction
to the parameters here:framework/src/Illuminate/Database/Schema/MySqlSchemaState.php
Lines 21 to 23 in 7e69645
Add a new option parameter to the
schema:dump
command, which optionally enables the--single-transaction
mode:framework/src/Illuminate/Database/Console/DumpCommand.php
Lines 22 to 25 in 7e69645
Allow any kind of additional parameters for
mysqldump
, defined inconfig/database.php
, similar to what spatie/laravel-backup does:Beta Was this translation helpful? Give feedback.
All reactions