Is there a naming convention or guide that one should follow while naming Laravel migrations or should the name only be descriptive enough ?
Also, suppose you are adding 12 columns to modify a table then in such a case the migration name would be too long if made descriptive so are there any guide lines to follow ?
According to \Illuminate\Database\Console\Migrations\TableGuesser
class source there are two default patterns to guess migration table and stub type.
const CREATE_PATTERNS = [
'/^create_(\w+)_table$/',
'/^create_(\w+)$/',
];
const CHANGE_PATTERNS = [
'/_(to|from|in)_(\w+)_table$/',
'/_(to|from|in)_(\w+)$/',
];
It should be descriptive enough for you to check back and understand what did you do with DB in this migration.
If you start migration with table_ then Laravel adds Schema::create
.
If you have to or from or in then Laravel creates Schema::table
for you. This makes you life easier.
I usually name the migrations based on feature eg implement_user_roles or make_employee_profile_editable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With