summaryrefslogtreecommitdiffstats
path: root/application/migrations/004_add_filesize.php
blob: ca10e7dc37e644c2e8346671225637ede21ad1e5 (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_Add_filesize extends CI_Migration {

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

		if ($this->db->dbdriver == 'postgre') {
			$this->db->query('
				ALTER TABLE "'.$prefix.'files"
				ADD "filesize" integer NOT NULL
			');
		} else {
			$this->db->query('
				ALTER TABLE `'.$prefix.'files`
				ADD `filesize` INT UNSIGNED NOT NULL
			');
		}
	}

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

		if ($this->db->dbdriver == 'postgre') {
			$this->db->query('
				ALTER TABLE "'.$prefix.'files" DROP "filesize"
			');
		} else {
			$this->db->query('
				ALTER TABLE `'.$prefix.'files` DROP `filesize`
			');
		}
	}
}