feat: 🎉 Add Feature to Skip AUTO_INCREMENT Values in MySQL Dumps #207
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new feature to the MySql dumper class, enabling users to exclude AUTO_INCREMENT values from their MySQL dumps. By adding a skipAutoIncrement boolean property along with two methods, skipAutoIncrement() and dontSkipAutoIncrement(), users can now toggle whether AUTO_INCREMENT values are included in the dump files. This flexibility is useful in scenarios where preserving AUTO_INCREMENT values is not necessary, such as when managing schema migrations or version controlling database structures.
Implementation Details:
A protected boolean property $skipAutoIncrement has been added to control whether AUTO_INCREMENT values are included in the dump.
The skipAutoIncrement() method sets $skipAutoIncrement to true, instructing the dumper to exclude AUTO_INCREMENT values from the output.
Conversely, the dontSkipAutoIncrement() method sets $skipAutoIncrement to false, including AUTO_INCREMENT values in the dump.
Within the getDumpCommand method, a conditional check on $skipAutoIncrement appends a sed command (sed 's/ AUTO_INCREMENT=[0-9]*\b//') to the mysqldump command. This sed command effectively removes any AUTO_INCREMENT declarations from the dump output.
Usage Example:
config/database.php