diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-02-03 23:30:13 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-02-03 23:31:58 +0100 |
commit | 6f1258fbf27b05092ed0712c7d20bafda42074ea (patch) | |
tree | 611425933e21b900e656879bfb25902d7ce3ca2b /application/migrations/007_repurpose_invitations.php | |
parent | 46fe1f6db8395381c71e2e7fba3d1c2d979cbfbc (diff) |
Support database table prefixes
This also cleans up some inconsistencies with quotes.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/migrations/007_repurpose_invitations.php')
-rw-r--r-- | application/migrations/007_repurpose_invitations.php | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/application/migrations/007_repurpose_invitations.php b/application/migrations/007_repurpose_invitations.php index fb40e8179..ed9b136a0 100644 --- a/application/migrations/007_repurpose_invitations.php +++ b/application/migrations/007_repurpose_invitations.php @@ -5,56 +5,60 @@ class Migration_Repurpose_invitations extends CI_Migration { public function up() { + $prefix = $this->db->dbprefix; + if ($this->db->dbdriver == 'postgre') { $this->db->query(' - ALTER TABLE "invitations" + ALTER TABLE "'.$prefix.'invitations" ADD "action" character varying(255) NOT NULL, ADD "data" TEXT NULL; - CREATE INDEX "invitations_action_idx" ON invitations ("action"); + CREATE INDEX "invitations_action_idx" ON '.$prefix.'invitations ("action"); '); $this->db->query(' - UPDATE "invitations" SET "action" = \'invitation\' WHERE "action" = \'\' + UPDATE "'.$prefix.'invitations" SET "action" = \'invitation\' WHERE "action" = \'\' '); $this->db->query(' - ALTER TABLE "invitations" RENAME TO "actions"; + ALTER TABLE "'.$prefix.'invitations" RENAME TO "actions"; '); } else { - $this->db->query(" - ALTER TABLE `invitations` + $this->db->query(' + ALTER TABLE `'.$prefix.'invitations` ADD `action` VARCHAR(255) NOT NULL, ADD `data` TEXT NULL, ADD INDEX `action` (`action`); - "); + '); - $this->db->query(" - UPDATE `invitations` SET `action` = 'invitation' WHERE `action` = ''; - "); + $this->db->query(' + UPDATE `'.$prefix.'invitations` SET `action` = \'invitation\' WHERE `action` = \'\'; + '); - $this->db->query(" - ALTER TABLE `invitations` RENAME `actions`; - "); + $this->db->query(' + ALTER TABLE `'.$prefix.'invitations` RENAME `'.$prefix.'actions`; + '); } } public function down() { + $prefix = $this->db->dbprefix; + if ($this->db->dbdriver == 'postgre') { - $this->db->query('ALTER TABLE "actions" RENAME TO "invitations"'); + $this->db->query('ALTER TABLE "'.$prefix.'actions" RENAME TO "'.$prefix.'invitations"'); $this->db->query(' - ALTER TABLE "invitations" + ALTER TABLE "'.$prefix.'invitations" DROP "action", DROP "data"; '); } else { - $this->db->query('ALTER TABLE `actions` RENAME `invitations`'); + $this->db->query('ALTER TABLE `'.$prefix.'actions` RENAME `'.$prefix.'invitations`'); $this->db->query(' - ALTER TABLE `invitations` + ALTER TABLE `'.$prefix.'invitations` DROP `action`, DROP `data`; '); |