Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Connection string for package migration
  • The documentation says that Oil uses the Application connection string according to the Environment variable. I want to use a separate connection string for a Package and run migration for the package. How can I accomplish this?
  • HarroHarro
    Accepted Answer
    Since migrations aren't designed to work over multiple databases (the state of migrations are tracked in the database itself), the is no feature available to configure this. The state is also tracked in the migrations config file.

    However, the Migration class itself has a configuration key "migrations.connection" that can be used to set the connection string that is used, but since it is already used upon class load (in it's _init() method), you need to set it before the class loads.

    So you probably need to copy the Migrate task, add the option to specify the connection string, and set it before loading the Migrate class.

    Given the fact that you'll end up with a discrepancy between the migrations config file and the migrations table (which will be spread over two databases), I don't do this.

    If your application requires the use of multiple databases, it probably better to keep track of all migrations in the app itself, and just pass the connection string you need to the individual DB calls in your migration classes.

Howdy, Stranger!

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

In this Discussion