From 342e2b1cd341599b734ec581a6c47019b09ac97b Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 20 Aug 2016 23:09:47 +0200 Subject: Migration 18: Allow user info to be nulled This allows us to safely delete users without breaking referrer information. Signed-off-by: Florian Pritz --- .../migrations/018_allow_null_values_userinfo.php | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 application/migrations/018_allow_null_values_userinfo.php (limited to 'application/migrations') 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 @@ +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"); + } +} -- cgit v1.2.3-24-g4f1b