Laravel Migrations Naming Convention

Noman Ur Rehman picture Noman Ur Rehman · Apr 27, 2015 · Viewed 9.7k times · Source

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 ?

Answer

Vitalii picture Vitalii · Mar 4, 2019

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