summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-08-20 23:09:47 +0200
committerFlorian Pritz <bluewind@xinu.at>2016-08-20 23:09:47 +0200
commit342e2b1cd341599b734ec581a6c47019b09ac97b (patch)
treec5c4249f7c1ff42d9bb8dcce9dd2b32636a51baf
parent4b0f4e75dacd7232d43dd983d58d5d8f9ac9fc8b (diff)
Migration 18: Allow user info to be nulled
This allows us to safely delete users without breaking referrer information. Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--application/config/migration.php2
-rw-r--r--application/migrations/018_allow_null_values_userinfo.php31
2 files changed, 32 insertions, 1 deletions
diff --git a/application/config/migration.php b/application/config/migration.php
index e96af5a41..659907cb8 100644
--- a/application/config/migration.php
+++ b/application/config/migration.php
@@ -21,7 +21,7 @@ $config['migration_enabled'] = true;
| be upgraded / downgraded to.
|
*/
-$config['migration_version'] = 17;
+$config['migration_version'] = 18;
/*
diff --git a/application/migrations/018_allow_null_values_userinfo.php b/application/migrations/018_allow_null_values_userinfo.php
new file mode 100644
index 000000000..1497dd0d4
--- /dev/null
+++ b/application/migrations/018_allow_null_values_userinfo.php
@@ -0,0 +1,31 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_allow_null_values_userinfo extends CI_Migration {
+
+ public function up()
+ {
+ $prefix = $this->db->dbprefix;
+
+ if ($this->db->dbdriver == 'postgre') {
+ $this->db->query('
+ ALTER TABLE "'.$prefix.'users"
+ ALTER COLUMN "username" DROP NOT NULL,
+ ALTER COLUMN "password" DROP NOT NULL,
+ ALTER COLUMN "email" DROP NOT NULL;
+ ');
+ } else {
+ $this->db->query('
+ ALTER TABLE `'.$prefix.'users`
+ CHANGE `username` `username` varchar(32) NULL,
+ CHANGE `password` `password` varchar(255) NULL,
+ CHANGE `email` `email` varchar(255) NULL;
+ ');
+ }
+ }
+
+ public function down()
+ {
+ throw new \exceptions\ApiException("migration/downgrade-not-supported", "downgrade not supported");
+ }
+}