diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-02-03 23:30:13 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-02-03 23:31:58 +0100 |
commit | 6f1258fbf27b05092ed0712c7d20bafda42074ea (patch) | |
tree | 611425933e21b900e656879bfb25902d7ce3ca2b /application/migrations/013_add_multipaste.php | |
parent | 46fe1f6db8395381c71e2e7fba3d1c2d979cbfbc (diff) |
Support database table prefixes
This also cleans up some inconsistencies with quotes.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/migrations/013_add_multipaste.php')
-rw-r--r-- | application/migrations/013_add_multipaste.php | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/application/migrations/013_add_multipaste.php b/application/migrations/013_add_multipaste.php index 539e9d292..6dd9bcb7b 100644 --- a/application/migrations/013_add_multipaste.php +++ b/application/migrations/013_add_multipaste.php @@ -5,31 +5,33 @@ class Migration_add_multipaste extends CI_Migration { public function up() { + $prefix = $this->db->dbprefix; + if ($this->db->dbdriver == 'postgre') { $this->db->query(' - CREATE TABLE "multipaste" ( + CREATE TABLE "'.$prefix.'multipaste" ( "url_id" varchar(255) NOT NULL PRIMARY KEY, "multipaste_id" serial UNIQUE, "user_id" integer NOT NULL, "date" integer NOT NULL ); - CREATE INDEX "multipaste_user_idx" ON "multipaste" ("user_id"); + CREATE INDEX "'.$prefix.'multipaste_user_idx" ON "'.$prefix.'multipaste" ("user_id"); '); $this->db->query(' - CREATE TABLE "multipaste_file_map" ( - "multipaste_id" integer NOT NULL REFERENCES "multipaste" ("multipaste_id") ON DELETE CASCADE ON UPDATE CASCADE, - "file_url_id" varchar(255) NOT NULL REFERENCES "files"("id") ON DELETE CASCADE ON UPDATE CASCADE, + CREATE TABLE "'.$prefix.'multipaste_file_map" ( + "multipaste_id" integer NOT NULL REFERENCES "'.$prefix.'multipaste" ("multipaste_id") ON DELETE CASCADE ON UPDATE CASCADE, + "file_url_id" varchar(255) NOT NULL REFERENCES "'.$prefix.'files"("id") ON DELETE CASCADE ON UPDATE CASCADE, "sort_order" serial PRIMARY KEY, UNIQUE ("multipaste_id", "file_url_id") ); - CREATE INDEX "multipaste_file_map_file_idx" ON "multipaste_file_map" ("file_url_id"); + CREATE INDEX "'.$prefix.'multipaste_file_map_file_idx" ON "'.$prefix.'multipaste_file_map" ("file_url_id"); '); } else { $this->db->query(' - CREATE TABLE `multipaste` ( + CREATE TABLE `'.$prefix.'multipaste` ( `url_id` varchar(255) NOT NULL, `multipaste_id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, @@ -40,15 +42,15 @@ class Migration_add_multipaste extends CI_Migration { ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); $this->db->query(' - CREATE TABLE `multipaste_file_map` ( + CREATE TABLE `'.$prefix.'multipaste_file_map` ( `multipaste_id` int(11) NOT NULL, `file_url_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `sort_order` int(10) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`sort_order`), UNIQUE KEY `multipaste_id` (`multipaste_id`,`file_url_id`), KEY `multipaste_file_map_ibfk_2` (`file_url_id`), - CONSTRAINT `multipaste_file_map_ibfk_1` FOREIGN KEY (`multipaste_id`) REFERENCES `multipaste` (`multipaste_id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `multipaste_file_map_ibfk_2` FOREIGN KEY (`file_url_id`) REFERENCES `files` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `'.$prefix.'multipaste_file_map_ibfk_1` FOREIGN KEY (`multipaste_id`) REFERENCES `'.$prefix.'multipaste` (`multipaste_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `'.$prefix.'multipaste_file_map_ibfk_2` FOREIGN KEY (`file_url_id`) REFERENCES `'.$prefix.'files` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;'); } } |