summaryrefslogtreecommitdiffstats
path: root/application/migrations/007_repurpose_invitations.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2014-10-19 23:04:20 +0200
committerFlorian Pritz <bluewind@xinu.at>2014-10-19 23:04:41 +0200
commitc8d9d70f60ccc8d77180627852810453375c91fd (patch)
tree72cdbe776fce9dccefb13610913ff24dcd3d92e4 /application/migrations/007_repurpose_invitations.php
parent111c356f7833d1619f0da75d019c390a424d6445 (diff)
parent1abe7372404a9d65f3b59eda2d83e628267b366d (diff)
Merge postgresql support
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.php69
1 files changed, 48 insertions, 21 deletions
diff --git a/application/migrations/007_repurpose_invitations.php b/application/migrations/007_repurpose_invitations.php
index d586c2829..fb40e8179 100644
--- a/application/migrations/007_repurpose_invitations.php
+++ b/application/migrations/007_repurpose_invitations.php
@@ -5,33 +5,60 @@ 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`;
+ ');
+ }
+
}
}