nefone
Новичок
Есть миграция для CodeIgniter 3 по созданию таблицы с месяцами года:
Подскажите, как лучше добавить внешний ключ к столбцу 'id'? может у dbforge есть методы? или только руками писать SQL запрос?
PHP:
public function up()
{
//Drop table if is exists
$this->dbforge->drop_table('mounths');
$this->dbfogre->add_field(array(
'id' => array(
'type' => 'INT',
'auto_increment' => TRUE,
),
'name' => array(
'type' => 'VARCHAR',
'constraint' => '50',
'null' => FALSE,
)
));
$this->dbforge->add_key('id', TRUE);
//TODO: Добавить внешний ключ.
$this->dbforge->create_table('mounths');
//TODO: Dumping data for table 'mounths'
}