diff --git a/application/migrations/071_create_station_logbook_table.php b/application/migrations/071_create_station_logbook_table.php index 762ef81b..452ec50b 100644 --- a/application/migrations/071_create_station_logbook_table.php +++ b/application/migrations/071_create_station_logbook_table.php @@ -11,38 +11,40 @@ class Migration_create_station_logbook_table extends CI_Migration { public function up() { - $this->dbforge->add_field(array( - 'logbook_id' => array( - 'type' => 'BIGINT', - 'constraint' => 20, - 'unsigned' => TRUE, - 'auto_increment' => TRUE, - 'unique' => TRUE - ), + if (!$this->db->table_exists('station_logbooks')) { + $this->dbforge->add_field(array( + 'logbook_id' => array( + 'type' => 'BIGINT', + 'constraint' => 20, + 'unsigned' => TRUE, + 'auto_increment' => TRUE, + 'unique' => TRUE + ), - 'user_id' => array( - 'type' => 'BIGINT', - 'constraint' => 20, - 'unsigned' => TRUE, - 'auto_increment' => FALSE - ), - - 'logbook_name' => array( - 'type' => 'VARCHAR', - 'constraint' => '191', - 'null' => TRUE - ), + 'user_id' => array( + 'type' => 'BIGINT', + 'constraint' => 20, + 'unsigned' => TRUE, + 'auto_increment' => FALSE + ), + + 'logbook_name' => array( + 'type' => 'VARCHAR', + 'constraint' => '191', + 'null' => TRUE + ), - 'modified' => array( - 'type' => 'timestamp', - 'null' => TRUE, - ) - )); + 'modified' => array( + 'type' => 'timestamp', + 'null' => TRUE, + ) + )); - $this->dbforge->add_key('logbook_id', TRUE); - $this->dbforge->add_key('user_id', TRUE); + $this->dbforge->add_key('logbook_id', TRUE); + $this->dbforge->add_key('user_id', TRUE); - $this->dbforge->create_table('station_logbooks'); + $this->dbforge->create_table('station_logbooks'); + } } public function down() diff --git a/application/migrations/072_create_station_logbook_relationship_table.php b/application/migrations/072_create_station_logbook_relationship_table.php index 02ed7a4b..8f487af0 100644 --- a/application/migrations/072_create_station_logbook_relationship_table.php +++ b/application/migrations/072_create_station_logbook_relationship_table.php @@ -11,40 +11,42 @@ class Migration_create_station_logbook_relationship_table extends CI_Migration { public function up() { - $this->dbforge->add_field(array( - 'logbook_relation_id' => array( - 'type' => 'BIGINT', - 'constraint' => 20, - 'unsigned' => TRUE, - 'auto_increment' => TRUE, - 'unique' => TRUE - ), + if (!$this->db->table_exists('station_logbooks_relationship')) { + $this->dbforge->add_field(array( + 'logbook_relation_id' => array( + 'type' => 'BIGINT', + 'constraint' => 20, + 'unsigned' => TRUE, + 'auto_increment' => TRUE, + 'unique' => TRUE + ), - 'station_logbook_id' => array( - 'type' => 'BIGINT', - 'constraint' => 20, - 'unsigned' => TRUE, - 'auto_increment' => FALSE - ), + 'station_logbook_id' => array( + 'type' => 'BIGINT', + 'constraint' => 20, + 'unsigned' => TRUE, + 'auto_increment' => FALSE + ), - 'station_location_id' => array( - 'type' => 'BIGINT', - 'constraint' => 20, - 'unsigned' => TRUE, - 'auto_increment' => FALSE - ), + 'station_location_id' => array( + 'type' => 'BIGINT', + 'constraint' => 20, + 'unsigned' => TRUE, + 'auto_increment' => FALSE + ), - 'modified' => array( - 'type' => 'timestamp', - 'null' => TRUE, - ) - )); + 'modified' => array( + 'type' => 'timestamp', + 'null' => TRUE, + ) + )); - $this->dbforge->add_key('logbook_relation_id', TRUE); - $this->dbforge->add_key('station_logbook_id', TRUE); - $this->dbforge->add_key('station_location_id', TRUE); + $this->dbforge->add_key('logbook_relation_id', TRUE); + $this->dbforge->add_key('station_logbook_id', TRUE); + $this->dbforge->add_key('station_location_id', TRUE); - $this->dbforge->create_table('station_logbooks_relationship'); + $this->dbforge->create_table('station_logbooks_relationship'); + } } public function down()