diff options
author | Florian Pritz <bluewind@xinu.at> | 2014-10-10 20:57:15 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2014-10-10 20:57:15 +0200 |
commit | dbb2247b82ab49c50f424c904ac98702507f1a8e (patch) | |
tree | 8de007c3f61f621b02ecb93d4a2730e00d79c613 /application/migrations/007_repurpose_invitations.php | |
parent | ba760ba7280265cb49e38a2b039c42d5bdfd6b9d (diff) | |
parent | c902a13c01583e83fda7f8188130e01f2d3bb141 (diff) |
Merge remote-tracking branch 'rafi/master' into rafi
Diffstat (limited to 'application/migrations/007_repurpose_invitations.php')
-rw-r--r-- | application/migrations/007_repurpose_invitations.php | 70 |
1 files changed, 49 insertions, 21 deletions
diff --git a/application/migrations/007_repurpose_invitations.php b/application/migrations/007_repurpose_invitations.php index d586c2829..024b62984 100644 --- a/application/migrations/007_repurpose_invitations.php +++ b/application/migrations/007_repurpose_invitations.php @@ -5,33 +5,61 @@ class Migration_Repurpose_invitations extends CI_Migration { public function up() { - $this->db->query(" - ALTER TABLE `invitations` - ADD `action` VARCHAR(255) NOT NULL, - ADD `data` TEXT NULL, - ADD INDEX `action` (`action`); - "); + if ($this->db->dbdriver == 'postgre') { + $this->db->query(' + ALTER TABLE "invitations" + ADD "action" character varying(255) NOT NULL, + ADD "data" TEXT NULL; + CREATE INDEX "invitations_action_idx" ON invitations ("action"); + '); - $this->db->query(" - UPDATE `invitations` SET `action` = 'invitation' WHERE `action` = ''; - "); + $this->db->query(' + UPDATE "invitations" SET "action" = \'invitation\' WHERE "action" = \'\' + '); - $this->db->query(" - ALTER TABLE `invitations` RENAME `actions`; - "); + $this->db->query(' + ALTER TABLE "invitations" RENAME TO "actions"; + '); + } else { + + $this->db->query(" + ALTER TABLE `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(" + ALTER TABLE `invitations` RENAME `actions`; + "); + } } public function down() { - $this->db->query(" - ALTER TABLE `actions` RENAME `invitations`; - "); - - $this->db->query(" - ALTER TABLE `invitations` - DROP `action`, - DROP `data`; - "); + if ($this->db->dbdriver == 'postgre') + { + $this->db->query('ALTER TABLE "actions" RENAME TO "invitations"'); + $this->db->query(' + ALTER TABLE "invitations" + DROP "action", + DROP "data"; + '); + + } else { + + $this->db->query('ALTER TABLE `actions` RENAME `invitations`'); + $this->db->query(' + ALTER TABLE `invitations` + DROP `action`, + DROP `data`; + '); + } + } } |