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 --- .../migrations/011_apikeys_add_access_level.php | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'application/migrations/011_apikeys_add_access_level.php') diff --git a/application/migrations/011_apikeys_add_access_level.php b/application/migrations/011_apikeys_add_access_level.php index e0f39317b..29a2f769b 100644 --- a/application/migrations/011_apikeys_add_access_level.php +++ b/application/migrations/011_apikeys_add_access_level.php @@ -5,15 +5,33 @@ class Migration_apikeys_add_access_level extends CI_Migration { public function up() { - $this->db->query(" - alter table `apikeys` add `access_level` varchar(255) default 'apikey'; - "); + if ($this->db->dbdriver == 'postgre') + { + $this->db->query(' + alter table "apikeys" add "access_level" varchar(255) default \'apikey\' + '); + } + else + { + $this->db->query(" + alter table `apikeys` add `access_level` varchar(255) default 'apikey'; + "); + } } public function down() { - $this->db->query(" - alter table `apikeys` drop `access_level`; - "); + if ($this->db->dbdriver == 'postgre') + { + $this->db->query(' + alter table "apikeys" drop "access_level" + '); + } + else + { + $this->db->query(' + alter table `apikeys` drop `access_level` + '); + } } } -- 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/011_apikeys_add_access_level.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'application/migrations/011_apikeys_add_access_level.php') diff --git a/application/migrations/011_apikeys_add_access_level.php b/application/migrations/011_apikeys_add_access_level.php index 29a2f769b..2fdbc7271 100644 --- a/application/migrations/011_apikeys_add_access_level.php +++ b/application/migrations/011_apikeys_add_access_level.php @@ -5,14 +5,11 @@ class Migration_apikeys_add_access_level extends CI_Migration { public function up() { - if ($this->db->dbdriver == 'postgre') - { + if ($this->db->dbdriver == 'postgre') { $this->db->query(' alter table "apikeys" add "access_level" varchar(255) default \'apikey\' '); - } - else - { + } else { $this->db->query(" alter table `apikeys` add `access_level` varchar(255) default 'apikey'; "); @@ -21,14 +18,11 @@ class Migration_apikeys_add_access_level extends CI_Migration { public function down() { - if ($this->db->dbdriver == 'postgre') - { + if ($this->db->dbdriver == 'postgre') { $this->db->query(' alter table "apikeys" drop "access_level" '); - } - else - { + } else { $this->db->query(' alter table `apikeys` drop `access_level` '); -- cgit v1.2.3-24-g4f1b