From 49ad84d1f11734c3eb81f20d073e4c2d557224f8 Mon Sep 17 00:00:00 2001 From: int2001 Date: Mon, 9 Dec 2024 07:10:57 +0000 Subject: [PATCH] Recreate tle-table with FK --- application/migrations/230_tle_cron.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/application/migrations/230_tle_cron.php b/application/migrations/230_tle_cron.php index a68e702f8..171f72ccd 100644 --- a/application/migrations/230_tle_cron.php +++ b/application/migrations/230_tle_cron.php @@ -3,6 +3,11 @@ defined('BASEPATH') or exit('No direct script access allowed'); class Migration_tle_cron extends CI_Migration { public function up() { + $this->db->query("DROP TABLE tle"); + $this->db->query("CREATE TABLE `tle` (`id` int(6) unsigned NOT NULL AUTO_INCREMENT, `satelliteid` int(6) unsigned NOT NULL, + `tle` text DEFAULT NULL, `updated` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`satelliteid`), UNIQUE KEY `tle_unique_id` (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"); + $this->db->query("ALTER TABLE tle ADD CONSTRAINT tle_satellite_FK FOREIGN KEY (satelliteid) REFERENCES satellite(id) ON DELETE CASCADE"); if ($this->chk4cron('update_update_tle') == 0) { $data = array( array( @@ -18,15 +23,13 @@ class Migration_tle_cron extends CI_Migration { $this->db->insert_batch('cron', $data); } - $this->dbtry("ALTER TABLE tle ADD CONSTRAINT tle_unique_satelliteid UNIQUE (satelliteid);"); - } public function down() { if ($this->chk4cron('update_tle') > 0) { $this->db->query("delete from cron where id='update_update_tle'"); } - $this->dbtry("ALTER TABLE tle DROP INDEX tle_unique_satelliteid;"); + // No way back to tle-table } function chk4cron($cronkey) {