Cannot auto-migrate after creating DB in new Command (CI4.2) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Cannot auto-migrate after creating DB in new Command (CI4.2) (/showthread.php?tid=85896) |
Cannot auto-migrate after creating DB in new Command (CI4.2) - DocHojo - 12-18-2022 Hi there, I'm trying to do a spark command doing all the following instruction at once: - DROP actual DB - CREATE DB with same name - Migrate - Seed The new Command has the run method as below: PHP Code: public function run(array $params) { The db:drop command has the code below: PHP Code: $name_db = getenv('database.default.database'); Problem is that the migrate command is generating an error, stating that no DB is selected. I tried to reconnect the DB after the drop doing $this->db->connect() but no success. The trick that works for now is to remove only the tables and not the entire DB but it is not the way I want to do it. Any hint on how to make this working? |