CodeIgniter Forums
$sessionDBGroup not working - migration - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: $sessionDBGroup not working - migration (/showthread.php?tid=80379)



$sessionDBGroup not working - migration - LutonDatta - 10-25-2021

My default main database has 47 tables and 65 million rows. So to reduce load on my main database I am trying to use $sessionDBGroup to use separate database to store session related data. Problem is in migration. When I run migration, migration process does not create any table in $sessionDBGroup database. When I load site session library try to read from this $sessionDBGroup. As a result table not exists error happens. When I tested migration process in a fresh new installation, migration process can create 46 tables in my default database group and this is ok because session table should not be in that database instead it should be created in other database group $sessionDBGroup. What should I do to fix it?

app/Config/App.php
PHP Code:
public $sessionDBGroup  'session_db_group'


app/Config/Database.php

PHP Code:
public $defaultGroup 'default';
// Main database group
public $default = [...];
// Database group for session
public $session_db_group = [...]; 



RE: $sessionDBGroup not working - migration - InsiteFX - 10-26-2021

CodeIgniter 4 User Guide - Connecting to the Database


RE: $sessionDBGroup not working - migration - LutonDatta - 10-26-2021

[quote pid="390998" dateline="1635220029"]
Simple solution is, we need to add database group in migration class like below:


PHP Code:
public function __construct(){
        // First assign appropriate DB group
        $this->DBGroup config('App')->sessionDBGroup;
        
        
// Then call parent constructor to the rest
        parent::__construct();
    }
    

[/quote]


RE: $sessionDBGroup not working - migration - kenjis - 10-28-2021

This bug?
https://github.com/codeigniter4/CodeIgniter4/issues/5087