CI Migration Library and dynamic config values |
Hi everyone! Yesterday, I was working on a project's migrations and I might found a little thing with CI's migrations and config classes.
I have, in config/migration.php file, defined the base directory for my migrations (APPPATH/database/migrations) but, as this project must handle different projects (multi-tenant app), I notice two situations when trying to create different migrations for each new project: 1. I use $this->config->set_item() to update the migration path dynamically, but the system doesn't seem to really update it as I run $this->migration->latest() right after and the path used is always the one defined on the config file. It's like the change is never reflected on the Migration library properties. Probably it's because the moment when the config values are loaded is on the library construct method, an I'm loading the migration library on the controller's construct method, which precedes everything else on my code. 2. On the Migration library construct method, there's a check for the existance of the migrations table but, at this point, my app's code has yet to use $this->db->db_select() method to change the database to migrate which, by default, will always check for it on the master db and that's not what I intend. In your opinion, what's the best approach to handle this situations? P.s: if you find any typo, I'm sorry. English is not my mother language!
Best regards,
José Postiga Senior Backend Developer
04-02-2016, 06:49 AM
(This post was last modified: 04-02-2016, 06:51 AM by josepostiga. Edit Reason: Typo )
Just for future reference, I've managed to handle this situations by extending the core Migration Library and making a few changes regarding the configuration getters and setters. The final class goes like this:
PHP Code: <?php
Best regards,
José Postiga Senior Backend Developer |
Welcome Guest, Not a member yet? Register Sign In |