blob: ecdef305d31d086a33f1c5564f67ec824a32f2a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 "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`;
');
}
}
}
|