From bdf16e6fbbcaa0a07b5249123cc1723f65883d0a Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 20 Sep 2018 22:50:09 +0200 Subject: [PATCH] migration: 20180920202100_rename_password_link_to_user_activation.php --- ...ename_password_link_to_user_activation.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/migrations/20180920202100_rename_password_link_to_user_activation.php diff --git a/app/migrations/20180920202100_rename_password_link_to_user_activation.php b/app/migrations/20180920202100_rename_password_link_to_user_activation.php new file mode 100644 index 0000000..65e41f5 --- /dev/null +++ b/app/migrations/20180920202100_rename_password_link_to_user_activation.php @@ -0,0 +1,32 @@ +table('password_link') + ->rename('user_activation') + ->changeColumn('public_id', 'string', [ + 'limit' => 40 + ]) + ->addColumn('used', 'integer', [ + 'limit' => 1, + 'default' => 0, + 'after' => 'user_id' + ])->save(); + + $this->table('user_activation') + ->renameColumn('public_id', 'activation_key') + ->save(); + + // Set used = 1 on all rows where password = null + $this->getQueryBuilder() + ->update('user_activation') + ->set('used', 1) + ->where('password IS NULL OR LENGTH(password) < 1') + ->execute(); + } +}