diff options
author | Rafael Bodill <rafi@sortex.co.il> | 2014-09-19 17:47:01 +0200 |
---|---|---|
committer | Rafael Bodill <rafi@sortex.co.il> | 2014-09-19 17:47:01 +0200 |
commit | 0b62a117ca8d34331406a07dc52aa937ff76ace1 (patch) | |
tree | 318a5c84cdb11d27017d1cadd1dd517618682fd9 /application/migrations/001_add_files.php | |
parent | d2c309aee8189a5d6c2a3fcb0a05ea694d7b646e (diff) | |
parent | 75b0a939c7ce24014a8db95a3355d2a7ffdfe3a9 (diff) |
Merge branch 'pgsql_migrations'
* pgsql_migrations:
Optimizing multipaste tables
apikeys.created should be timestamp with default now()
No column based encoding. Reverting dbforge migration
Correcting bracket style for 'if'
Migrations support for PostgreSQL
Diffstat (limited to 'application/migrations/001_add_files.php')
-rw-r--r-- | application/migrations/001_add_files.php | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/application/migrations/001_add_files.php b/application/migrations/001_add_files.php index f1f16ea3a..70efbb520 100644 --- a/application/migrations/001_add_files.php +++ b/application/migrations/001_add_files.php @@ -5,19 +5,38 @@ 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() |