[Migrations] Added checks to see if things exists. Done to avoid trouble when swapping branches.
这个提交包含在:
		
							父节点
							
								
									234ec52f1b
								
							
						
					
					
						当前提交
						57e5836193
					
				
					共有  3 个文件被更改,包括 15 次插入 和 10 次删除
				
			
		|  | @ -5,17 +5,18 @@ class Migration_Theme_table extends CI_Migration { | ||||||
| 	public function up() | 	public function up() | ||||||
| 	{ | 	{ | ||||||
| 		// create themes table
 | 		// 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;"); | 		if (!$this->db->table_exists('themes')) { | ||||||
| 		$this->db->query("INSERT INTO themes (name, foldername) values ('Blue','blue');"); | 			$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 ('Cosmo','cosmo');"); | 			$this->db->query("INSERT INTO themes (name, foldername) values ('Blue','blue');"); | ||||||
| 		$this->db->query("INSERT INTO themes (name, foldername) values ('Cyborg (Dark)','cyborg');"); | 			$this->db->query("INSERT INTO themes (name, foldername) values ('Cosmo','cosmo');"); | ||||||
| 		$this->db->query("INSERT INTO themes (name, foldername) values ('Darkly (Dark)','darkly');"); | 			$this->db->query("INSERT INTO themes (name, foldername) values ('Cyborg (Dark)','cyborg');"); | ||||||
| 		$this->db->query("INSERT INTO themes (name, foldername) values ('Default','default');"); | 			$this->db->query("INSERT INTO themes (name, foldername) values ('Darkly (Dark)','darkly');"); | ||||||
| 		$this->db->query("INSERT INTO themes (name, foldername) values ('Superhero (Dark)','superhero');"); | 			$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(){ | 	public function down(){ | ||||||
| 		$this->db->query(""); | 		$this->db->query(""); | ||||||
| 
 |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -9,7 +9,9 @@ class Migration_add_userid_to_notes extends CI_Migration | ||||||
| 			'user_id BIGINT(20) DEFAULT NULL', | 			'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() | 	public function down() | ||||||
|  |  | ||||||
|  | @ -10,7 +10,9 @@ class Migration_add_userid_to_hardware extends CI_Migration { | ||||||
| 			'user_id BIGINT(20) DEFAULT NULL', | 			'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() | 	public function down() | ||||||
|  |  | ||||||
		正在加载…
	
		在新工单中引用