From bdd90ca6b7d6777e283c844b34b06dbba6657b1e Mon Sep 17 00:00:00 2001 From: "witold.brzozowski" Date: Mon, 19 Feb 2024 13:58:56 +0100 Subject: [PATCH 1/2] Fix account name migration --- .../resources/scripts/V3_3_0_1__add_user_account_name.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/resources/scripts/V3_3_0_1__add_user_account_name.sql b/src/main/resources/scripts/V3_3_0_1__add_user_account_name.sql index 8d5881fc..0ae164ec 100644 --- a/src/main/resources/scripts/V3_3_0_1__add_user_account_name.sql +++ b/src/main/resources/scripts/V3_3_0_1__add_user_account_name.sql @@ -1 +1,7 @@ -ALTER TABLE users ADD COLUMN account_name VARCHAR(63) NOT NULL UNIQUE; \ No newline at end of file +ALTER TABLE users ADD COLUMN account_name VARCHAR(63); + +UPDATE users SET account_name = SUBSTRING(mail FROM 1 FOR POSITION('@' IN mail) - 1); + +ALTER TABLE users ALTER COLUMN account_name SET NOT NULL; + +CREATE UNIQUE INDEX users_account_name_index ON users (account_name); \ No newline at end of file From 55631166d24be259fde5bc358b06fc4f398650f5 Mon Sep 17 00:00:00 2001 From: "witold.brzozowski" Date: Mon, 19 Feb 2024 14:32:04 +0100 Subject: [PATCH 2/2] Fix --- .../resources/scripts/V3_3_0_1__add_user_account_name.sql | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/resources/scripts/V3_3_0_1__add_user_account_name.sql b/src/main/resources/scripts/V3_3_0_1__add_user_account_name.sql index 0ae164ec..e60a7de4 100644 --- a/src/main/resources/scripts/V3_3_0_1__add_user_account_name.sql +++ b/src/main/resources/scripts/V3_3_0_1__add_user_account_name.sql @@ -1,7 +1 @@ -ALTER TABLE users ADD COLUMN account_name VARCHAR(63); - -UPDATE users SET account_name = SUBSTRING(mail FROM 1 FOR POSITION('@' IN mail) - 1); - -ALTER TABLE users ALTER COLUMN account_name SET NOT NULL; - -CREATE UNIQUE INDEX users_account_name_index ON users (account_name); \ No newline at end of file +ALTER TABLE users ADD COLUMN account_name VARCHAR(63); \ No newline at end of file