Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Run module migration
  • Hi there,

    I'm trying to run a module migration and use its database config. I have a client module and its own database connection.
    What I want is when I use  php oil refine migrate --modules=client, will be used the client database's config instead of global. Is there a way to do that?

    I will set the customer's database on runtime, I have been trying to set database config with \Config::set(), but without success. I did a workarround as the following:

    'connection' => array(
                'dsn' => 'mysql:host=localhost;dbname='.\Session::get('client_database'),
                'username' => 'root',
                'password' => '',
            ),
    but I keep in mind that is the worst way to do that. 

    Is there a better way?

    Cheers
  • HarroHarro
    Accepted Answer
    Afaik there is no provision for per-module databases.

    I wonder, if you say the name of the database is determined "at runtime", how a commandline migrate should determine it? If only because it doesn't have a session.

    We only maintain one app that uses "per-client" databases, but those are stored in the (main) database.

    From what I can see, the code creates the connection dynamically using

    \DB::instance($clientname, $clientconfig);

    and then uses it in the ORM models using set_connection().
  • Thanks for replying,

    I have a list of all  databases. Running the app with multiples databases was a requirement of our client.
    I'm using a tenant_id to determine what databases must be loaded. Such ID is grabbed using domain, in that way, I can identify what database to use. In this scenario using session solved the problem even this not being the best way.


    Happy new year  (:

Howdy, Stranger!

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

In this Discussion