summaryrefslogtreecommitdiffstats
path: root/application/migrations/007_repurpose_invitations.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/migrations/007_repurpose_invitations.php')
-rw-r--r--application/migrations/007_repurpose_invitations.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/application/migrations/007_repurpose_invitations.php b/application/migrations/007_repurpose_invitations.php
new file mode 100644
index 000000000..0bc39c64b
--- /dev/null
+++ b/application/migrations/007_repurpose_invitations.php
@@ -0,0 +1,68 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_Repurpose_invitations extends CI_Migration {
+
+ public function up()
+ {
+ $prefix = $this->db->dbprefix;
+
+ if ($this->db->dbdriver == 'postgre') {
+ $this->db->query('
+ ALTER TABLE "'.$prefix.'invitations"
+ ADD "action" character varying(255) NOT NULL,
+ ADD "data" TEXT NULL;
+ CREATE INDEX "'.$prefix.'invitations_action_idx" ON '.$prefix.'invitations ("action");
+ ');
+
+ $this->db->query('
+ UPDATE "'.$prefix.'invitations" SET "action" = \'invitation\' WHERE "action" = \'\'
+ ');
+
+ $this->db->query('
+ ALTER TABLE "'.$prefix.'invitations" RENAME TO '.$prefix.'actions;
+ ');
+
+ } else {
+
+ $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 `'.$prefix.'invitations` SET `action` = \'invitation\' WHERE `action` = \'\';
+ ');
+
+ $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 "'.$prefix.'actions" RENAME TO "'.$prefix.'invitations"');
+ $this->db->query('
+ ALTER TABLE "'.$prefix.'invitations"
+ DROP "action",
+ DROP "data";
+ ');
+
+ } else {
+
+ $this->db->query('ALTER TABLE `'.$prefix.'actions` RENAME `'.$prefix.'invitations`');
+ $this->db->query('
+ ALTER TABLE `'.$prefix.'invitations`
+ DROP `action`,
+ DROP `data`;
+ ');
+ }
+
+ }
+}