refactor(database): improve make:migration experience
#1935
+835
−118
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.
The followings are now possible:
The table name and alter are also predicted (as mentioned above).
For the
$alterfeature, the guesser is expecting acreatekeyword as the first word, if that appears, it will predicttrue, acreatemigration. If not, then we are looking for prepositions (_to_,_from_,_in_), if any of those exist, we predictfalse, analtermigration. If none of those exists, we fall back totrue, acreatemigration.For the table name prediction, the guesser follows the same rules: if the migration starts with a
createkeyword, we stripcreate_and the optional_tablesuffix, and use what remains as the table name (in this case:books). If not, then we are looking for prepositions (_to_,_from_,_in_), and if any of those exist, we take everything after the last preposition, strip the optional_tablesuffix, and use that as the table name. If none of those exists, we fall back to using the full migration name as the table name candidate, and then normalize it to get the final table name.The command also takes
NamingStrategyandMigrationPrefixStrategyinto account when creating the final table name.