diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-02-15 11:11:49 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-02-15 11:11:49 +0100 |
commit | 45c16c802720faf9de6c3028ba41753c5edba974 (patch) | |
tree | e20148091cf0f9b6ff11efe65a76cfe1d1bad24c /application/migrations/002_add_users.php | |
parent | 9535ede862e01d834ebdd553184b1f6544b06d2c (diff) | |
parent | 01226a9afd760a920e9cb3377913ee296f0ab2ca (diff) |
Merge branch 'api-rework' into working
Diffstat (limited to 'application/migrations/002_add_users.php')
-rw-r--r-- | application/migrations/002_add_users.php | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/application/migrations/002_add_users.php b/application/migrations/002_add_users.php index 322415d9b..5ccef6669 100644 --- a/application/migrations/002_add_users.php +++ b/application/migrations/002_add_users.php @@ -5,9 +5,11 @@ class Migration_Add_users extends CI_Migration { public function up() { + $prefix = $this->db->dbprefix; + if ($this->db->dbdriver == 'postgre') { $this->db->query(' - CREATE TABLE IF NOT EXISTS "users" ( + CREATE TABLE IF NOT EXISTS "'.$prefix.'users" ( "id" serial PRIMARY KEY, "username" character varying(32) NOT NULL, "password" character varying(60) NOT NULL, @@ -16,7 +18,7 @@ class Migration_Add_users extends CI_Migration { '); $this->db->query(' - CREATE TABLE IF NOT EXISTS "ci_sessions" ( + CREATE TABLE IF NOT EXISTS "'.$prefix.'ci_sessions" ( "session_id" character varying(40) NOT NULL DEFAULT 0, "ip_address" character varying(16) NOT NULL DEFAULT 0, "user_agent" character varying(120) NOT NULL, @@ -24,43 +26,43 @@ class Migration_Add_users extends CI_Migration { "user_data" text NOT NULL, PRIMARY KEY ("session_id") ); - CREATE INDEX "ci_sessions_last_activity_idx" ON "ci_sessions" ("last_activity"); + CREATE INDEX "ci_sessions_last_activity_idx" ON "'.$prefix.'ci_sessions" ("last_activity"); '); $this->db->query(' - ALTER TABLE "files" ADD "user" integer NOT NULL DEFAULT 0; - CREATE INDEX "user_idx" ON "files" ("user"); + ALTER TABLE "'.$prefix.'files" ADD "user" integer NOT NULL DEFAULT 0; + CREATE INDEX "user_idx" ON "'.$prefix.'files" ("user"); '); } else { - $this->db->query(" - CREATE TABLE IF NOT EXISTS `users` ( + $this->db->query(' + CREATE TABLE IF NOT EXISTS `'.$prefix.'users` ( `id` int(8) UNSIGNED NOT NULL AUTO_INCREMENT, `username` varchar(32) COLLATE ascii_general_ci NOT NULL, `password` varchar(60) COLLATE ascii_general_ci NOT NULL, `email` varchar(255) COLLATE ascii_general_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - "); + '); - $this->db->query(" - CREATE TABLE IF NOT EXISTS `ci_sessions` ( - `session_id` varchar(40) NOT NULL DEFAULT '0', - `ip_address` varchar(16) NOT NULL DEFAULT '0', + $this->db->query(' + CREATE TABLE IF NOT EXISTS `'.$prefix.'ci_sessions` ( + `session_id` varchar(40) NOT NULL DEFAULT 0, + `ip_address` varchar(16) NOT NULL DEFAULT 0, `user_agent` varchar(120) NOT NULL, - `last_activity` int(10) unsigned NOT NULL DEFAULT '0', + `last_activity` int(10) unsigned NOT NULL DEFAULT 0, `user_data` text NOT NULL, PRIMARY KEY (`session_id`), KEY `last_activity_idx` (`last_activity`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - "); + '); - $this->db->query(" - ALTER TABLE `files` - ADD `user` INT(8) UNSIGNED NOT NULL DEFAULT '0', + $this->db->query(' + ALTER TABLE `'.$prefix.'files` + ADD `user` INT(8) UNSIGNED NOT NULL DEFAULT 0, ADD INDEX (`user`) - "); + '); } } @@ -69,9 +71,9 @@ class Migration_Add_users extends CI_Migration { $this->dbforge->drop_table('users'); $this->dbforge->drop_table('ci_sessions'); if ($this->db->dbdriver == 'postgre') { - $this->db->query('ALTER TABLE "files" DROP "user"'); + $this->db->query('ALTER TABLE "'.$prefix.'files" DROP "user"'); } else { - $this->db->query('ALTER TABLE `files` DROP `user`'); + $this->db->query('ALTER TABLE `'.$prefix.'files` DROP `user`'); } } } |