duellsy duellsy - 7 months ago 51
PHP Question

How do I run migrations for a specific environment in laravel

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 migrate:make --table="jobs" --create jobs

Which created a file in database/migrations as expected, I made some mods to this, and went to fire it up using

artisan migrate --env=local

But I'm getting the reply of
"Nothing to migrate"

If I try run without
, it uses the database.php in the config folder (not in the local / staging / production folder) which we don't want to use, as it won't be environment specific.

My first thought was OK, maybe I need to put the env flag on the
call, so I tried that, but got an error saying it couldn't create the migration file. Then I thought it doesn't make sense to make env based migrations anyway... they should be created generic, and simply run on a per env basis, so in the end, all environments are using the same migration scripts.

So I'm a bit stuck now on where to go to from here


You need to specify the environment before the migrate command.

artisan --env=local migrate

Running artisan help shows you the format in which commands are to follow.

artisan help

  [options] command [arguments]