Laravel Migrations Naming Convention

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.


Make sure you don't use the same class name with your model, it still works but for understanding,

Put create_ if you are creating for example,or

If the tables are pivot to each other make it like article_comment to make sure you will understand when you try to change it 5 months later :)


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+)$/',
];