summaryrefslogtreecommitdiffstats
path: root/application/migrations/001_add_files.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-02-03 23:30:13 +0100
committerFlorian Pritz <bluewind@xinu.at>2015-02-03 23:31:58 +0100
commit6f1258fbf27b05092ed0712c7d20bafda42074ea (patch)
tree611425933e21b900e656879bfb25902d7ce3ca2b /application/migrations/001_add_files.php
parent46fe1f6db8395381c71e2e7fba3d1c2d979cbfbc (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/001_add_files.php')
-rw-r--r--application/migrations/001_add_files.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/application/migrations/001_add_files.php b/application/migrations/001_add_files.php
index 30f567325..dd37d08c3 100644
--- a/application/migrations/001_add_files.php
+++ b/application/migrations/001_add_files.php
@@ -5,9 +5,11 @@ class Migration_Add_files extends CI_Migration {
public function up()
{
+ $prefix = $this->db->dbprefix;
+
if ($this->db->dbdriver == 'postgre') {
$this->db->query('
- CREATE TABLE IF NOT EXISTS "files" (
+ CREATE TABLE IF NOT EXISTS "'.$prefix.'files" (
"hash" varchar(32) NOT NULL,
"id" varchar(6) NOT NULL,
"filename" varchar(256) NOT NULL,
@@ -16,12 +18,12 @@ class Migration_Add_files extends CI_Migration {
"mimetype" varchar(255) NOT NULL,
PRIMARY KEY ("id")
);
- CREATE INDEX "files_date_idx" ON files ("date");
- CREATE INDEX "files_hash_id_idx" ON files ("hash", "id");
+ CREATE INDEX "files_date_idx" ON '.$prefix.'files ("date");
+ CREATE INDEX "files_hash_id_idx" ON '.$prefix.'files ("hash", "id");
');
} else {
- $this->db->query("
- CREATE TABLE IF NOT EXISTS `files` (
+ $this->db->query('
+ CREATE TABLE IF NOT EXISTS `'.$prefix.'files` (
`hash` varchar(32) CHARACTER SET ascii NOT NULL,
`id` varchar(6) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`filename` varchar(256) COLLATE utf8_bin NOT NULL,
@@ -32,7 +34,7 @@ class Migration_Add_files extends CI_Migration {
KEY `date` (`date`),
KEY `hash` (`hash`,`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
- ");
+ ');
}
}