Open lorisleiva opened 6 years ago
Two of the suggestions are reasonable default values for the migration name in case it isn't provided, and one is to mangle the parameter names into something unreadable.
I'm +2/3 to this suggestion as it is currently written. Do we really have to add short parameter names?
Thanks for the input. Glad to see you're on board with the main part of this proposal.
I don't really see any inconvenience in adding two non conflictual shortcuts in options that are frequently used. Could you please provide some of your cons regarding that matter?
Agreed. I don't see a downside to shorthand parameter names, SO LONG AS the long-form continue to exist as well. Laravel is full of short-hand features for those that prefer it, but nobody is forced to use them.
What a coincidence, I wans't aware of this laravel/ideas
repository and created a first draft for this a few minutes ago. While creating a few migration for a new project I noticed in most cases where I create a new table, I was using the same format: create_$tablename_table
.
The modified file can be found in this fork: https://github.com/PendoNL/framework/blob/5.6/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php (commit diff here: https://github.com/PendoNL/framework/commit/619779395d419b788b46789579587edf6ef2baf5).
I'm not sure if there's a good default for updating a table. When I look at my personal situation it's very diverse of what names I want to give them, like add_active_field_to_posts
, add_address_fields_to_post
, remove_unused_fields_from_posts
, etc. So,.. not sure about that one or what default fits best for all cases. Having an update_posts_table
migration is just to vague for my taste.
Fair enough! That's a few key strokes less ;-)
@joshuadegier Nice, thanks for sharing. I totally agree with your opinion on the updating convention. The issue is that if we provide a default name for --create
, then name
will be an optional parameter. Thus, we have to also provide some default for --table
. And like you said update_$tablename_table
is just too vague and basically not something that people use.
In my code there's only an exception thrown if the parameter is missing when using any other than --create
. Seems a fair solution, I'll just leave it here to gather some more thoughts of others.
Hi 👋,
Currently, when generating a migration that creates a new table I write :
create_$tableName_table
, I thought it could be a good idea to provide this convention as a default migration name when thename
argument is omitted and thecreate
option is provided.table
option is provided.create
andtable
, the respective shortcuts-c
and-t
.The bash command above could then be shorten to:
If you guys, girls and agender people think it's a good idea, I am more than happy to open a PR.
💪💾