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

class Migration_allow_null_values_userinfo extends CI_Migration {

	public function up()
	{
		$prefix = $this->db->dbprefix;

		if ($this->db->dbdriver == 'postgre') {
			$this->db->query('
				ALTER TABLE "'.$prefix.'users"
					ALTER COLUMN "username" DROP NOT NULL,
					ALTER COLUMN "password" DROP NOT NULL,
					ALTER COLUMN "email" DROP NOT NULL;
				');
		} else {
			$this->db->query('
				ALTER TABLE `'.$prefix.'users`
					CHANGE `username` `username` varchar(32) NULL,
					CHANGE `password` `password` varchar(255) NULL,
					CHANGE `email` `email` varchar(255) NULL;
				');
		}
	}

	public function down()
	{
		throw new \exceptions\ApiException("migration/downgrade-not-supported", "downgrade not supported");
	}
}