summaryrefslogtreecommitdiffstats
path: root/application/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'application/migrations')
-rw-r--r--application/migrations/001_add_files.php27
-rw-r--r--application/migrations/002_add_users.php46
-rw-r--r--application/migrations/003_add_referrers.php33
-rw-r--r--application/migrations/004_add_filesize.php22
-rw-r--r--application/migrations/005_drop_file_password.php21
-rw-r--r--application/migrations/006_add_username_index.php21
-rw-r--r--application/migrations/007_repurpose_invitations.php37
-rw-r--r--application/migrations/008_add_profiles.php31
-rw-r--r--application/migrations/009_add_apikeys.php24
-rw-r--r--application/migrations/010_files_innodb.php16
10 files changed, 278 insertions, 0 deletions
diff --git a/application/migrations/001_add_files.php b/application/migrations/001_add_files.php
new file mode 100644
index 000000000..f1f16ea3a
--- /dev/null
+++ b/application/migrations/001_add_files.php
@@ -0,0 +1,27 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+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;
+ ");
+ }
+
+ public function down()
+ {
+ $this->dbforge->drop_table('files');
+ }
+}
diff --git a/application/migrations/002_add_users.php b/application/migrations/002_add_users.php
new file mode 100644
index 000000000..5675c77e9
--- /dev/null
+++ b/application/migrations/002_add_users.php
@@ -0,0 +1,46 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_Add_users extends CI_Migration {
+
+ public function up()
+ {
+ $this->db->query("
+ CREATE TABLE IF NOT EXISTS `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',
+ `user_agent` varchar(120) NOT NULL,
+ `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',
+ ADD INDEX (`user`)
+ ");
+ }
+
+ public function down()
+ {
+ $this->dbforge->drop_table('users');
+ $this->dbforge->drop_table('ci_sessions');
+ $this->db->query("
+ ALTER TABLE `files`
+ DROP `user`
+ ");
+ }
+}
diff --git a/application/migrations/003_add_referrers.php b/application/migrations/003_add_referrers.php
new file mode 100644
index 000000000..524e92ff0
--- /dev/null
+++ b/application/migrations/003_add_referrers.php
@@ -0,0 +1,33 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_Add_referrers extends CI_Migration {
+
+ public function up()
+ {
+ $this->db->query("
+ CREATE TABLE `invitations` (
+ `user` int(8) unsigned NOT NULL,
+ `key` varchar(16) CHARACTER SET ascii NOT NULL,
+ `date` int(11) unsigned NOT NULL,
+ PRIMARY KEY (`key`),
+ KEY `user` (`user`),
+ KEY `date` (`date`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
+ ");
+ $this->db->query("
+ ALTER TABLE `users`
+ ADD `referrer` INT(8) UNSIGNED NOT NULL DEFAULT '0'
+ ");
+ }
+
+ public function down()
+ {
+ $this->db->query("
+ ALTER TABLE `users`
+ DROP `referrer`
+ ");
+ $this->dbforge->drop_table('invitations');
+
+ }
+}
diff --git a/application/migrations/004_add_filesize.php b/application/migrations/004_add_filesize.php
new file mode 100644
index 000000000..d7a70223d
--- /dev/null
+++ b/application/migrations/004_add_filesize.php
@@ -0,0 +1,22 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_Add_filesize extends CI_Migration {
+
+ public function up()
+ {
+ $this->db->query("
+ ALTER TABLE `files`
+ ADD `filesize` INT UNSIGNED NOT NULL
+ ");
+ }
+
+ public function down()
+ {
+ $this->db->query("
+ ALTER TABLE `files`
+ DROP `filesize`
+ ");
+
+ }
+}
diff --git a/application/migrations/005_drop_file_password.php b/application/migrations/005_drop_file_password.php
new file mode 100644
index 000000000..bf03490a8
--- /dev/null
+++ b/application/migrations/005_drop_file_password.php
@@ -0,0 +1,21 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_Drop_file_password extends CI_Migration {
+
+ public function up()
+ {
+ $this->db->query("
+ ALTER TABLE `files`
+ DROP `password`;
+ ");
+ }
+
+ public function down()
+ {
+ $this->db->query("
+ ALTER TABLE `files`
+ ADD `password` varchar(40) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL;
+ ");
+ }
+}
diff --git a/application/migrations/006_add_username_index.php b/application/migrations/006_add_username_index.php
new file mode 100644
index 000000000..ea5e3ebc0
--- /dev/null
+++ b/application/migrations/006_add_username_index.php
@@ -0,0 +1,21 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_Add_username_index extends CI_Migration {
+
+ public function up()
+ {
+ $this->db->query("
+ ALTER TABLE `users`
+ ADD UNIQUE `username` (`username`);
+ ");
+ }
+
+ public function down()
+ {
+ $this->db->query("
+ ALTER TABLE `users`
+ DROP INDEX `username`;
+ ");
+ }
+}
diff --git a/application/migrations/007_repurpose_invitations.php b/application/migrations/007_repurpose_invitations.php
new file mode 100644
index 000000000..36d3007e8
--- /dev/null
+++ b/application/migrations/007_repurpose_invitations.php
@@ -0,0 +1,37 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_Repurpose_invitations extends CI_Migration {
+
+ public function up()
+ {
+ $this->db->query("
+ ALTER TABLE `invitations`
+ ADD `action` VARCHAR(255) NOT NULL,
+ ADD `data` TEXT NULL,
+ ADD INDEX `action` (`action`);
+ ");
+
+ $this->db->query("
+ UPDATE `invitations` SET `action` = 'invitation' WHERE `action` = '';
+ ");
+
+ $this->db->query("
+ RENAME TABLE `invitations` TO `actions` ;
+ ");
+
+ }
+
+ public function down()
+ {
+ $this->db->query("
+ RENAME TABLE `actions` TO `invitations` ;
+ ");
+
+ $this->db->query("
+ ALTER TABLE `invitations`
+ DROP `action`,
+ DROP `data`;
+ ");
+ }
+}
diff --git a/application/migrations/008_add_profiles.php b/application/migrations/008_add_profiles.php
new file mode 100644
index 000000000..3fea33c08
--- /dev/null
+++ b/application/migrations/008_add_profiles.php
@@ -0,0 +1,31 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_Add_profiles extends CI_Migration {
+
+ public function up()
+ {
+ $this->db->query("
+ CREATE TABLE `profiles` (
+ `user` int(8) unsigned NOT NULL,
+ `upload_id_limits` varchar(255) COLLATE utf8_bin NOT NULL,
+ PRIMARY KEY (`user`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
+ ");
+
+ $this->db->query("
+ ALTER TABLE `files` CHANGE `id` `id` VARCHAR( 255 );
+ ");
+
+ }
+
+ public function down()
+ {
+ $this->db->query("
+ DROP TABLE `profiles`;
+ ");
+ $this->db->query("
+ ALTER TABLE `files` CHANGE `id` `id` VARCHAR( 6 );
+ ");
+ }
+}
diff --git a/application/migrations/009_add_apikeys.php b/application/migrations/009_add_apikeys.php
new file mode 100644
index 000000000..8e88260a8
--- /dev/null
+++ b/application/migrations/009_add_apikeys.php
@@ -0,0 +1,24 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_Add_apikeys extends CI_Migration {
+
+ public function up()
+ {
+ $this->db->query("
+ CREATE TABLE `apikeys` (
+ `key` varchar(64) COLLATE utf8_bin NOT NULL,
+ `user` int(8) unsigned NOT NULL,
+ `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `comment` varchar(255) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
+ PRIMARY KEY (`key`),
+ KEY `user` (`user`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
+ ");
+ }
+
+ public function down()
+ {
+ $this->dbforge->drop_table('apikeys');
+ }
+}
diff --git a/application/migrations/010_files_innodb.php b/application/migrations/010_files_innodb.php
new file mode 100644
index 000000000..b32f94724
--- /dev/null
+++ b/application/migrations/010_files_innodb.php
@@ -0,0 +1,16 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_files_innodb extends CI_Migration {
+
+ public function up()
+ {
+ $this->db->query("
+ ALTER TABLE `files` ENGINE = InnoDB;
+ ");
+ }
+
+ public function down()
+ {
+ }
+}