summaryrefslogtreecommitdiffstats
path: root/application/migrations/007_repurpose_invitations.php
blob: d586c2829bebd9e6a11ab2edb82a482026e37f3b (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
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

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`);
		");

		$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`;
		");
	}
}