Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Deploying and OIL migrate
  • So lets say your are deploying with something like capistrano. Obviously you want to run database migrations but how to specify the environment? I like this line from config.php which makes it easy to choose the environment and thus the DB with Apache's SetEnv
    'environment' => (isset($_SERVER['FUEL_ENV']) ? $_SERVER['FUEL_ENV'] : Fuel::DEVELOPMENT),
    
    Any ideas how to set the environment in OIL without a nasty hack?
  • I ended up scanning $_SERVER[argv] in config.php so I can do:
    php oil refine migrate {staging | production }
    
  • Why does the env matter when running migrations?
  • I have staging and production databases and I want to be able to run migrations on them separately without maintaining multiple config.php versions.
  • Would it be useful to create an argument like
    php oil r migrate --FUELENV=stage
    

    or has a better way been thought of since this post?
  • Rob McCann wrote on Tuesday 30th of August 2011:
    Would it be useful to create an argument like
    php oil r migrate --FUELENV=stage
    

    or has a better way been thought of since this post?

    wow, this one sets up the $_SERVER variable? thanks
  • Jaroslav Petrusevic wrote on Tuesday 30th of August 2011:
    Rob McCann wrote on Tuesday 30th of August 2011:
    Would it be useful to create an argument like
    php oil r migrate --FUELENV=stage
    

    or has a better way been thought of since this post?

    wow, this one sets up the $_SERVER variable? thanks

    not to my knowledge. I was querying whether I should make that change or if another way has already been discussed.
  • A good point. You can do this with environment variables set in your Apache config, which is probably more useful than checking the URL. Dont ask me how though :)
  • I don't think 'php oil migrate' cares much about your Apache configuration... You'll have to inform oil in which environment you're running, so you can select the correct database. For Fuel itself, you'll have the option to work with environment settings in your virtualhost config or .htaccess. For the commandline, those options do not exist.
  • Try this in bootstrap.php, allowing you to pass the enviroment like this: oil refine migrate production https://gist.github.com/3553622
  • Hey, not sure, but I saw smth like this in phpunit bootstrap: Fuel::$env = Fuel::TEST; hope that helps:) good luck!
  • Instead of setting an environment variable in Apache, I use Capistrano to create a file called "IN_PRODUCTION", "IN_TESTING" etc. in a private folder and check for it's existence when setting Fuel's environment variable. If you use Capistrano's multi-stage plugin, it's really easy to implement.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion