Welcome Guest, Not a member yet? Register   Sign In
protected $DBGroup = 'ywl_data';
#1

(This post was last modified: 10-09-2019, 01:04 AM by ciadmin.)

Hi,

I have some DBgroups declared in App/Config/Database:

// localhost
public $ywl_config = [
'DSN'      => '',
'hostname' => 'localhost',
'username' => 'yachtworklist',
'password' => 'REDACTED',
'database' => 'ywl_config',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug'  => (ENVIRONMENT !== 'production'),
'cacheOn'  => false,
'cacheDir' => '',
'charset'  => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre'  => '',
'encrypt'  => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port'    => 3306,
];

public $ywl_data = [
'DSN'      => '',
'hostname' => 'localhost',
'username' => 'yachtworklist',
'password' => 'REDACTED',
'database' => 'ywl_data',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug'  => (ENVIRONMENT !== 'production'),
'cacheOn'  => false,
'cacheDir' => '',
'charset'  => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre'  => '',
'encrypt'  => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port'    => 3306,
];


and I want that each migration file call their DataBase, but all of migrations files call DataBase defined in $defaultGroup

class BoatDecks extends Migration
{
protected $DBGroup = 'ywl_data'; // doesn't work!!!!

public function up()
{
$this->forge->addField([
'id' => [
'type' => 'SERIAL'
],
'id_boat' => [
'type' => 'INT',
'constraint' => '4'
],
'deck_name' => [
'type' => 'VARCHAR',
'constraint' => '25'
]
]);

$this->forge->addField("created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP()");
$this->forge->addField("updated_at TIMESTAMP NULL");
$this->forge->addField("deleted_at TIMESTAMP NULL");
$this->forge->addKey('id', TRUE);
$this->forge->createTable('ywl_data_boat_decks');
}

//--------------------------------------------------------------------

public function down()
{
$this->forge->dropTable('ywl_data_boat_decks');
}
}


thank's!
Reply
#2

Were you using the framework from the last develop branch? This was fixed literally 10 hours ago: https://github.com/codeigniter4/CodeIgniter4/pull/2303
Reply
#3

Uauhhhhhh!!!

it works perfectly, thanks a lot!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB