diff --git a/system/modules/admin/install/migrations/20190117125821-AdminAddMigrationMessageTextColumns.php b/system/modules/admin/install/migrations/20190117125821-AdminAddMigrationMessageTextColumns.php index aa2ea6373..a855baf3c 100644 --- a/system/modules/admin/install/migrations/20190117125821-AdminAddMigrationMessageTextColumns.php +++ b/system/modules/admin/install/migrations/20190117125821-AdminAddMigrationMessageTextColumns.php @@ -1,28 +1,39 @@ addColumnToTable('migration', 'pretext', 'string', ['default' => null, 'null' => true]); - $this->addColumnToTable('migration', 'posttext', 'string', ['default' => null, 'null' => true]); - $this->addColumnToTable('migration', 'description', 'string', ['default' => null, 'null' => true]); + public function up() + { + + if ($this->hasTable('migration') && !$this->table("migration")->hasColumn("pretext")) { + $this->addColumnToTable('migration', 'pretext', 'string', ['default' => null, 'null' => true]); + $this->addColumnToTable('migration', 'posttext', 'string', ['default' => null, 'null' => true]); + $this->addColumnToTable('migration', 'description', 'string', ['default' => null, 'null' => true]); + } } - public function down() { - $this->removeColumnFromTable('migration', 'pretext'); - $this->removeColumnFromTable('migration', 'posttext'); - $this->removeColumnFromTable('migration', 'description'); + public function down() + { + if ($this->hasTable('migration') && $this->table("migration")->hasColumn("pretext")) { + $this->removeColumnFromTable('migration', 'pretext'); + $this->removeColumnFromTable('migration', 'posttext'); + $this->removeColumnFromTable('migration', 'description'); + } } - public function preText() { + public function preText() + { return ""; } - public function postText() { + public function postText() + { return ""; } - public function description() { + public function description() + { return ""; } } diff --git a/system/modules/admin/install/migrations/20240218223900-InboxRemoveTable.php b/system/modules/admin/install/migrations/20240218223900-InboxRemoveTable.php index b196444cf..78d96aa50 100644 --- a/system/modules/admin/install/migrations/20240218223900-InboxRemoveTable.php +++ b/system/modules/admin/install/migrations/20240218223900-InboxRemoveTable.php @@ -1,4 +1,5 @@ dropTable('inbox_message'); //Clear out the related user roles - $this->w->db->delete('user_role')->where('role', 'inbox_sender')->execute(); - $this->w->db->delete('user_role')->where('role', 'inbox_reader')->execute(); + if ($this->hasTable('user_role')) { + $this->w->db->delete('user_role')->where('role', 'inbox_sender')->execute(); + $this->w->db->delete('user_role')->where('role', 'inbox_reader')->execute(); + } } - public function down(): void - { - } + public function down(): void {} - public function description() { + public function description() + { return 'Remove inbox table and roles'; } } diff --git a/system/modules/admin/install/migrations/20240911010101-AdminStableMigrationSchema.php b/system/modules/admin/install/migrations/20240911010101-AdminStableMigrationSchema.php new file mode 100644 index 000000000..b2fc56cf6 --- /dev/null +++ b/system/modules/admin/install/migrations/20240911010101-AdminStableMigrationSchema.php @@ -0,0 +1,34 @@ +addColumnToTable('migration', 'pretext', 'string', ['default' => null, 'null' => true]); + $this->addColumnToTable('migration', 'posttext', 'string', ['default' => null, 'null' => true]); + $this->addColumnToTable('migration', 'description', 'string', ['default' => null, 'null' => true]); + } + + public function down() + { + $this->removeColumnFromTable('migration', 'pretext'); + $this->removeColumnFromTable('migration', 'posttext'); + $this->removeColumnFromTable('migration', 'description'); + } + + public function preText() + { + return ""; + } + + public function postText() + { + return ""; + } + + public function description() + { + return ""; + } +} diff --git a/system/modules/admin/models/MigrationService.php b/system/modules/admin/models/MigrationService.php index ddf8e54d4..6f4c1a1e2 100644 --- a/system/modules/admin/models/MigrationService.php +++ b/system/modules/admin/models/MigrationService.php @@ -549,7 +549,8 @@ public function installInitialMigration() { $filenames = [ "AdminInitialMigration" => "20151030134124-AdminInitialMigration.php", - "AdminMigrationSeed" => "20170123091600-AdminMigrationSeed.php" + "AdminMigrationSeed" => "20170123091600-AdminMigrationSeed.php", + "AdminStableMigrationSchema" => "20240911010101-AdminStableMigrationSchema.php", ]; $directory = SYSTEM_MODULE_DIRECTORY . DS . "admin" . DS . MIGRATION_DIRECTORY;