From 33f542487a89da4a8edad934b82aae7484f70ca3 Mon Sep 17 00:00:00 2001 From: Rafael Bodill Date: Thu, 18 Sep 2014 22:02:26 +0300 Subject: Migrations support for PostgreSQL --- application/migrations/005_drop_file_password.php | 30 +++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'application/migrations/005_drop_file_password.php') diff --git a/application/migrations/005_drop_file_password.php b/application/migrations/005_drop_file_password.php index bf03490a8..2be20e550 100644 --- a/application/migrations/005_drop_file_password.php +++ b/application/migrations/005_drop_file_password.php @@ -5,17 +5,31 @@ class Migration_Drop_file_password extends CI_Migration { public function up() { - $this->db->query(" - ALTER TABLE `files` - DROP `password`; - "); + if ($this->db->dbdriver == 'postgre') + { + $this->db->query('ALTER TABLE "files" DROP "password"'); + } + else + { + $this->db->query("ALTER TABLE `files` DROP `password`;"); + } } public function down() { - $this->db->query(" - ALTER TABLE `files` - ADD `password` varchar(40) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL; - "); + if ($this->db->dbdriver == 'postgre') + { + $this->db->query(' + ALTER TABLE "files" + ADD "password" character varying(40) DEFAULT NULL + '); + } + else + { + $this->db->query(" + ALTER TABLE `files` + ADD `password` varchar(40) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL; + "); + } } } -- cgit v1.2.3-24-g4f1b From fe7f15dbfb8020daf96110e86e359ec01558fcb8 Mon Sep 17 00:00:00 2001 From: Rafael Bodill Date: Thu, 18 Sep 2014 22:47:21 +0300 Subject: Correcting bracket style for 'if' --- application/migrations/005_drop_file_password.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'application/migrations/005_drop_file_password.php') diff --git a/application/migrations/005_drop_file_password.php b/application/migrations/005_drop_file_password.php index 2be20e550..e8b7f8952 100644 --- a/application/migrations/005_drop_file_password.php +++ b/application/migrations/005_drop_file_password.php @@ -5,27 +5,21 @@ class Migration_Drop_file_password extends CI_Migration { public function up() { - if ($this->db->dbdriver == 'postgre') - { + if ($this->db->dbdriver == 'postgre') { $this->db->query('ALTER TABLE "files" DROP "password"'); - } - else - { + } else { $this->db->query("ALTER TABLE `files` DROP `password`;"); } } public function down() { - if ($this->db->dbdriver == 'postgre') - { + if ($this->db->dbdriver == 'postgre') { $this->db->query(' ALTER TABLE "files" ADD "password" character varying(40) DEFAULT NULL '); - } - else - { + } else { $this->db->query(" ALTER TABLE `files` ADD `password` varchar(40) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL; -- cgit v1.2.3-24-g4f1b