From 41bc9b3e1beac571788dd7c01d2a1d3e8550c049 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Thu, 28 Mar 2024 15:22:01 +0000 Subject: [PATCH] Make sure that sstv images table doesnt already exist --- .../migrations/175_add_sstv_images_table.php | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/application/migrations/175_add_sstv_images_table.php b/application/migrations/175_add_sstv_images_table.php index 657b53e3..b9eb62a1 100644 --- a/application/migrations/175_add_sstv_images_table.php +++ b/application/migrations/175_add_sstv_images_table.php @@ -1,37 +1,41 @@ dbforge->add_field(array( - 'id' => array( - 'type' => 'INT', - 'constraint' => 5, - 'unsigned' => TRUE, - 'auto_increment' => TRUE - ), - 'qsoid' => array( - 'type' => 'VARCHAR', - 'constraint' => '250', - ), - 'filename' => array( - 'type' => 'VARCHAR', - 'constraint' => '250', - ), - 'modified' => array( - 'type' => 'timestamp', - 'null' => TRUE, - ), - )); - $this->dbforge->add_key('id', TRUE); - $this->dbforge->create_table('sstv_images'); + // if sstv_images table doesn't exist + if (!$this->db->table_exists('sstv_images')) { + $this->dbforge->add_field(array( + 'id' => array( + 'type' => 'INT', + 'constraint' => 5, + 'unsigned' => TRUE, + 'auto_increment' => TRUE + ), + 'qsoid' => array( + 'type' => 'VARCHAR', + 'constraint' => '250', + ), + 'filename' => array( + 'type' => 'VARCHAR', + 'constraint' => '250', + ), + 'modified' => array( + 'type' => 'timestamp', + 'null' => TRUE, + ), + )); + $this->dbforge->add_key('id', TRUE); + $this->dbforge->create_table('sstv_images'); + } } public function down() { echo "not possible"; } -} \ No newline at end of file +}