summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--INSTALL2
-rw-r--r--application/config/migration.php82
-rw-r--r--application/controllers/file.php6
-rw-r--r--application/migrations/001_add_files.php27
-rw-r--r--db.sql13
5 files changed, 75 insertions, 55 deletions
diff --git a/INSTALL b/INSTALL
index 17bf4d0b0..71b48ff3d 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,6 +1,6 @@
-* Import db.sql into your database.
* Copy all files from system/application/config/example to
system/application/config
* Change them to fit your needs
+* The necessary database tables are created automatically when accessing your pastebin
* Copy htaccess.txt to .htaccess if you want shorter URLs
(also change the config setting)
diff --git a/application/config/migration.php b/application/config/migration.php
index afa264562..9a3034565 100644
--- a/application/config/migration.php
+++ b/application/config/migration.php
@@ -1,41 +1,41 @@
-<?php defined('BASEPATH') OR exit('No direct script access allowed');
-/*
-|--------------------------------------------------------------------------
-| Enable/Disable Migrations
-|--------------------------------------------------------------------------
-|
-| Migrations are disabled by default but should be enabled
-| whenever you intend to do a schema migration.
-|
-*/
-$config['migration_enabled'] = FALSE;
-
-
-/*
-|--------------------------------------------------------------------------
-| Migrations version
-|--------------------------------------------------------------------------
-|
-| This is used to set migration version that the file system should be on.
-| If you run $this->migration->latest() this is the version that schema will
-| be upgraded / downgraded to.
-|
-*/
-$config['migration_version'] = 0;
-
-
-/*
-|--------------------------------------------------------------------------
-| Migrations Path
-|--------------------------------------------------------------------------
-|
-| Path to your migrations folder.
-| Typically, it will be within your application path.
-| Also, writing permission is required within the migrations path.
-|
-*/
-$config['migration_path'] = APPPATH . 'migrations/';
-
-
-/* End of file migration.php */
-/* Location: ./application/config/migration.php */ \ No newline at end of file
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+/*
+|--------------------------------------------------------------------------
+| Enable/Disable Migrations
+|--------------------------------------------------------------------------
+|
+| Migrations are disabled by default but should be enabled
+| whenever you intend to do a schema migration.
+|
+*/
+$config['migration_enabled'] = true;
+
+
+/*
+|--------------------------------------------------------------------------
+| Migrations version
+|--------------------------------------------------------------------------
+|
+| This is used to set migration version that the file system should be on.
+| If you run $this->migration->latest() this is the version that schema will
+| be upgraded / downgraded to.
+|
+*/
+$config['migration_version'] = 1;
+
+
+/*
+|--------------------------------------------------------------------------
+| Migrations Path
+|--------------------------------------------------------------------------
+|
+| Path to your migrations folder.
+| Typically, it will be within your application path.
+| Also, writing permission is required within the migrations path.
+|
+*/
+$config['migration_path'] = APPPATH . 'migrations/';
+
+
+/* End of file migration.php */
+/* Location: ./application/config/migration.php */
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 814464ade..470383504 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -12,6 +12,12 @@ class File extends CI_Controller {
function __construct()
{
parent::__construct();
+
+ $this->load->library('migration');
+ if ( ! $this->migration->current()) {
+ show_error($this->migration->error_string());
+ }
+
mb_internal_encoding('UTF-8');
$this->load->helper(array('form', 'filebin'));
$this->load->model('file_mod');
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/db.sql b/db.sql
deleted file mode 100644
index fc2c191ea..000000000
--- a/db.sql
+++ /dev/null
@@ -1,13 +0,0 @@
-SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-
-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;