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

pull/1225/head
Andreas 2021-10-12 13:20:41 +02:00
rodzic 234ec52f1b
commit 57e5836193
3 zmienionych plików z 15 dodań i 10 usunięć

Wyświetl plik

@ -5,17 +5,18 @@ class Migration_Theme_table extends CI_Migration {
public function up()
{
// create themes table
$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');");
$this->db->query("INSERT INTO themes (name, foldername) values ('Cyborg (Dark)','cyborg');");
$this->db->query("INSERT INTO themes (name, foldername) values ('Darkly (Dark)','darkly');");
$this->db->query("INSERT INTO themes (name, foldername) values ('Default','default');");
$this->db->query("INSERT INTO themes (name, foldername) values ('Superhero (Dark)','superhero');");
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');");
$this->db->query("INSERT INTO themes (name, foldername) values ('Cyborg (Dark)','cyborg');");
$this->db->query("INSERT INTO themes (name, foldername) values ('Darkly (Dark)','darkly');");
$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("");
}
}

Wyświetl plik

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

Wyświetl plik

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