summaryrefslogtreecommitdiffstats
path: root/application/migrations/007_repurpose_invitations.php
blob: 36d3007e8deb92f5ee47e374e4f120ba7e870c92 (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("
			RENAME TABLE `invitations` TO `actions` ;
		");

	}

	public function down()
	{
		$this->db->query("
			RENAME TABLE `actions` TO `invitations` ;
		");

		$this->db->query("
			ALTER TABLE `invitations`
				DROP `action`,
				DROP `data`;
		");
	}
}