-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.7] Allow migration table name to be guessed without _table
suffix
#26429
[5.7] Allow migration table name to be guessed without _table
suffix
#26429
Conversation
Can't we just change the patterns to |
@staudenmeir Thanks for the feedback. I did it the way I have to ensure and make it very clear that the |
I think you mean: /^create_(\w+?)(_table)?$/ (You missed your end slashes)
I do like the idea of splitting them up on purpose to show that it should be It is worth noting that optimization is not as important as this is a single time operation. |
@taylorotwell Thanks for merging. 🙂 👍 |
With current code, order of the patterns is important, i.e. if It seems this possibility of future regression is already covered by tests. Still, how about adding a negative assertion? → |
This being said, I'd favor the single pattern |
Why in the world was this added? Such a terrible feature. Migrations aren't only for tables. I have never benefited from this feature (I will use the proper options like every command interface ever). But half my migrations are migrating data or refactors from one thing to another and added stuff I have to delete for no reason. I don't know how anyone could think this was a good idea, do you work on projects where you make 5 tables then you're done and you couldn't type |
About half the PRs for the framework now are for taking something you can do with 8 keystrokes and making it so you can do it with 5 instead. Basically just muddying the core or some like this where it actually has unintended side effects. |
The feature is literally called a A super common thing to do would be |
Real migrations I have made that now this feature assualts.
And that's only looking at the last 50 migrations. But main thing is this is a CLI command changing how the command works based on the user input name. Since I got this update half of the migrations I have made have done this and I thought there was a bug. |
This PR modifies the
TableGuesser
class to allow the table name to be parsed from migrations that do not have the_table
suffix.This will allow devs to create migrations with shorter names and still have them pre-populated with the relevant creation or change boilerplate content. See the following examples.
Original functionality (longer migration names) still works fine. The original regex pattern is checked first, prior to checking the new regex pattern.
Even though this is a minor change, it should help speed up and make migration creation just a tiny bit more intuitive. This change was actually inspired by a colleague who recently accidentally missed out the
_table
prefix from theirartisan
command and asked me why the boilerplate content was not added.This PR also adds a test which was missing from the
TableGuesser
class tests, to ensure migrations in created in the formatfoo_in_bar_table
are parsed correctly.