How do I run migrations for a specific environment in laravel

后端 未结 4 1199
忘了有多久
忘了有多久 2021-02-05 04:57

I\'m setting up a new app with laravel (Laravel 4), and having some issues setting up the database via migrations.

I made a migration file with:

artisan          


        
4条回答
  •  无人共我
    2021-02-05 05:35

    I figured out a solution to run migrate for different databases. Basically, the command artisan migrate --env=local doesn't work. But we can define a new connection string in config\database.php. For example:

     [
            'driver'    => 'mysql',
            'host'      => env('DB_TESTING_HOST'),
            'database'  => env('DB_TESTING_DATABASE'),
            'username'  => env('DB_TESTING_USERNAME'),
            'password'  => env('DB_TESTING_PASSWORD'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => 'prefix_',
        ],
    

    And specify the --database when we run artisan migrate like this:

    php artisan migrate --database=mysql_testing
    

    Hope this helps :)

提交回复
热议问题