Welcome Guest, Not a member yet? Register   Sign In
$sessionDBGroup not working - migration
#1

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 = [...]; 
Reply
#2

CodeIgniter 4 User Guide - Connecting to the Database
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

[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]
Reply
#4

This bug?
https://github.com/codeigniter4/CodeIgni...ssues/5087
Reply




Theme © iAndrew 2016 - Forum software by © MyBB