Ad

How To Use Custom File Names In Laravel Migrations?

- 1 answer

I want shorter names for my migration files. This project will not have tens of thousands of migrations, therefor 2019_11_05_191747_create_units_table.php is verbose.

I want to have clean migration file names like:
0001_create_users_table.php
0002_create_units_table.php

But the code in vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php is exploding on _ and not liking it.
Symfony\Component\Debug\Exception\FatalThrowableError : Class '' not found

How to get this done?

Ad

Answer

You can't because you should not change Laravel main core (for update compatibility reasons)

You should use the migrations as intended with "YYYY_MM_DD_HHMMSS_action_table_table_description.php" format.

Well, there is a solution, which would be to create a custom command and do what laravel migration does but with another file format and that's a lot of work for just the name of the migration files.

Ad
source: stackoverflow.com
Ad