[Migrations] Added checks to see if things exists. Done to avoid trouble when swapping branches.

这个提交包含在:
Andreas 2021-10-12 13:20:41 +02:00
父节点 234ec52f1b
当前提交 57e5836193
共有 3 个文件被更改,包括 15 次插入10 次删除

查看文件

@ -5,6 +5,7 @@ class Migration_Theme_table extends CI_Migration {
public function up()
{
// create themes table
if (!$this->db->table_exists('themes')) {
$this->db->query("create table themes (id integer not null auto_increment, name varchar(256) not null, foldername varchar(256) not null, primary key (id)) ENGINE=myisam DEFAULT CHARSET=utf8;");
$this->db->query("INSERT INTO themes (name, foldername) values ('Blue','blue');");
$this->db->query("INSERT INTO themes (name, foldername) values ('Cosmo','cosmo');");
@ -13,9 +14,9 @@ class Migration_Theme_table extends CI_Migration {
$this->db->query("INSERT INTO themes (name, foldername) values ('Default','default');");
$this->db->query("INSERT INTO themes (name, foldername) values ('Superhero (Dark)','superhero');");
}
}
public function down(){
$this->db->query("");
}
}

查看文件

@ -9,8 +9,10 @@ class Migration_add_userid_to_notes extends CI_Migration
'user_id BIGINT(20) DEFAULT NULL',
);
if (!$this->db->field_exists('user_id', 'notes')) {
$this->dbforge->add_column('notes', $fields);
}
}
public function down()
{

查看文件

@ -10,8 +10,10 @@ class Migration_add_userid_to_hardware extends CI_Migration {
'user_id BIGINT(20) DEFAULT NULL',
);
if (!$this->db->field_exists('user_id', 'cat')) {
$this->dbforge->add_column('cat', $fields);
}
}
public function down()
{