Pass selected DB to migration file
Closed this issue · 2 comments
federicovilla commented
Hi Natanfelles,
thanks a lot for adding DB select form; I need some more help to figure out how to pass the selected DB to the migration file...sorry but I'm a bit lost.
Right now I have the following code in my migration file:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_Create_civil_registrations_table extends CI_Migration {
public function __construct()
{
parent::__construct();
// switch over to Dev DB
$this->dev_db = $this->load->database('dev', TRUE);
$this->myforge = $this->load->dbforge($this->dev_db, TRUE);
}
public function up()
{
$fields = array(
'id' => array(
'type' => 'INT',
'constraint' => 11,
'unsigned' => TRUE,
'auto_increment' => TRUE
),
'registration' => array(
'type' => 'VARCHAR',
'constraint' => 10
)
);
$this->myforge->add_field($fields);
$this->myforge->add_key('id',TRUE);
$this->myforge->add_key('registration');
$this->myforge->create_table('civil_registrations',TRUE);
}
public function down()
{
$this->myforge->drop_table('civil_registrations', TRUE);
}
}
I don't understand how I can get rid of $this->dev_db = $this->load->database('dev', TRUE);
and replace it with the seleceted DB in your controller/view.
Thanks for any help
federicovilla commented
Fixed
natanfelles commented
Hello @federicovilla !
I had not logged in to GitHub for over a week. Now that I'm seeing what I've lost.
If you have not already done, it is always good to give a pass in the CI users guide or search in the forum, there the devs are also always willing to help.