Search code examples
laraveldatabase-migrationprefix

Prefix is not added to table on artisan migrate


I ran php artisan migrate, with empty value for prefix in the database config file.

Later I added a value for prefix in the database config file.

And then when I run php artisan migrate:refresh, the prefix is not added to the table. Why is that and what am I missing ?

This is my database config after adding prefix

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', 'database'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'laravel'),
    'username' => env('DB_USERNAME', 'laravel'),
    'password' => env('DB_PASSWORD', 'laravel'),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => 'my_prefix_',
    'strict' => true,
    'engine' => null,
]

Solution

  • It can be cache problem. Laravel can remember old settigns.

    Run artisan command and try again:

    php artisan config:cache