diff options
author | Florian Pritz <bluewind@xinu.at> | 2014-10-19 23:04:20 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2014-10-19 23:04:41 +0200 |
commit | c8d9d70f60ccc8d77180627852810453375c91fd (patch) | |
tree | 72cdbe776fce9dccefb13610913ff24dcd3d92e4 /application/migrations/006_add_username_index.php | |
parent | 111c356f7833d1619f0da75d019c390a424d6445 (diff) | |
parent | 1abe7372404a9d65f3b59eda2d83e628267b366d (diff) |
Merge postgresql support
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/migrations/006_add_username_index.php')
-rw-r--r-- | application/migrations/006_add_username_index.php | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/application/migrations/006_add_username_index.php b/application/migrations/006_add_username_index.php index ea5e3ebc0..5b8c3584f 100644 --- a/application/migrations/006_add_username_index.php +++ b/application/migrations/006_add_username_index.php @@ -5,17 +5,27 @@ class Migration_Add_username_index extends CI_Migration { public function up() { - $this->db->query(" - ALTER TABLE `users` - ADD UNIQUE `username` (`username`); - "); + if ($this->db->dbdriver == 'postgre') { + $this->db->query(' + CREATE UNIQUE INDEX "users_username_idx" ON "users" ("username") + '); + } else { + $this->db->query(" + ALTER TABLE `users` + ADD UNIQUE `username` (`username`); + "); + } } public function down() { - $this->db->query(" - ALTER TABLE `users` - DROP INDEX `username`; - "); + if ($this->db->dbdriver == 'postgre') { + $this->db->query('DROP INDEX "users_username_idx"'); + } else { + $this->db->query(" + ALTER TABLE `users` + DROP INDEX `username`; + "); + } } } |