summaryrefslogtreecommitdiffstats
path: root/application/migrations/001_add_files.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2014-10-19 23:04:20 +0200
committerFlorian Pritz <bluewind@xinu.at>2014-10-19 23:04:41 +0200
commitc8d9d70f60ccc8d77180627852810453375c91fd (patch)
tree72cdbe776fce9dccefb13610913ff24dcd3d92e4 /application/migrations/001_add_files.php
parent111c356f7833d1619f0da75d019c390a424d6445 (diff)
parent1abe7372404a9d65f3b59eda2d83e628267b366d (diff)
Merge postgresql support
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.php42
1 files changed, 29 insertions, 13 deletions
diff --git a/application/migrations/001_add_files.php b/application/migrations/001_add_files.php
index f1f16ea3a..30f567325 100644
--- a/application/migrations/001_add_files.php
+++ b/application/migrations/001_add_files.php
@@ -5,19 +5,35 @@ class Migration_Add_files extends CI_Migration {
public function up()
{
- $this->db->query("
- CREATE TABLE IF NOT EXISTS `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,
- `password` varchar(40) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
- `date` int(11) unsigned NOT NULL,
- `mimetype` varchar(255) CHARACTER SET ascii NOT NULL,
- PRIMARY KEY (`id`),
- KEY `date` (`date`),
- KEY `hash` (`hash`,`id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
- ");
+ if ($this->db->dbdriver == 'postgre') {
+ $this->db->query('
+ CREATE TABLE IF NOT EXISTS "files" (
+ "hash" varchar(32) NOT NULL,
+ "id" varchar(6) NOT NULL,
+ "filename" varchar(256) NOT NULL,
+ "password" varchar(40) DEFAULT NULL,
+ "date" integer NOT NULL,
+ "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");
+ ');
+ } else {
+ $this->db->query("
+ CREATE TABLE IF NOT EXISTS `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,
+ `password` varchar(40) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
+ `date` int(11) unsigned NOT NULL,
+ `mimetype` varchar(255) CHARACTER SET ascii NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `date` (`date`),
+ KEY `hash` (`hash`,`id`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+ ");
+ }
}
public function down()