diff --git a/userapi/storage/accounts/postgres/accounts_table.go b/userapi/storage/accounts/postgres/accounts_table.go index 4a36c3aa0..254da84c3 100644 --- a/userapi/storage/accounts/postgres/accounts_table.go +++ b/userapi/storage/accounts/postgres/accounts_table.go @@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS account_accounts ( -- Identifies which application service this account belongs to, if any. appservice_id TEXT, -- If the account is currently active - is_active BOOLEAN DEFAULT TRUE + is_deactivated BOOLEAN DEFAULT FALSE -- TODO: -- is_guest, is_admin, upgraded_ts, devices, any email reset stuff? ); @@ -54,13 +54,13 @@ const updatePasswordSQL = "" + "UPDATE account_accounts SET password_hash = $1 WHERE localpart = $2" const deactivateAccountSQL = "" + - "UPDATE account_accounts SET is_active = FALSE WHERE localpart = $1" + "UPDATE account_accounts SET is_deactivated = TRUE WHERE localpart = $1" const selectAccountByLocalpartSQL = "" + "SELECT localpart, appservice_id FROM account_accounts WHERE localpart = $1" const selectPasswordHashSQL = "" + - "SELECT password_hash FROM account_accounts WHERE localpart = $1 AND is_active = TRUE" + "SELECT password_hash FROM account_accounts WHERE localpart = $1 AND is_deactivated = FALSE" const selectNewNumericLocalpartSQL = "" + "SELECT nextval('numeric_username_seq')" diff --git a/userapi/storage/accounts/postgres/deltas/20200929203058_is_active.sql b/userapi/storage/accounts/postgres/deltas/20200929203058_is_active.sql index f0a713eba..32e6e1664 100644 --- a/userapi/storage/accounts/postgres/deltas/20200929203058_is_active.sql +++ b/userapi/storage/accounts/postgres/deltas/20200929203058_is_active.sql @@ -1,9 +1,9 @@ -- +goose Up -- +goose StatementBegin -ALTER TABLE account_accounts ADD COLUMN IF NOT EXISTS is_active BOOLEAN DEFAULT TRUE; +ALTER TABLE account_accounts ADD COLUMN IF NOT EXISTS is_deactivated BOOLEAN DEFAULT FALSE; -- +goose StatementEnd -- +goose Down -- +goose StatementBegin -ALTER TABLE account_accounts DROP COLUMN is_active; +ALTER TABLE account_accounts DROP COLUMN is_deactivated; -- +goose StatementEnd diff --git a/userapi/storage/accounts/sqlite3/accounts_table.go b/userapi/storage/accounts/sqlite3/accounts_table.go index a4c9aa502..d0ea8a8bc 100644 --- a/userapi/storage/accounts/sqlite3/accounts_table.go +++ b/userapi/storage/accounts/sqlite3/accounts_table.go @@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS account_accounts ( -- Identifies which application service this account belongs to, if any. appservice_id TEXT, -- If the account is currently active - is_active BOOLEAN DEFAULT 1 + is_deactivated BOOLEAN DEFAULT 0 -- TODO: -- is_guest, is_admin, upgraded_ts, devices, any email reset stuff? ); @@ -52,13 +52,13 @@ const updatePasswordSQL = "" + "UPDATE account_accounts SET password_hash = $1 WHERE localpart = $2" const deactivateAccountSQL = "" + - "UPDATE account_accounts SET is_active = 0 WHERE localpart = $1" + "UPDATE account_accounts SET is_deactivated = 1 WHERE localpart = $1" const selectAccountByLocalpartSQL = "" + "SELECT localpart, appservice_id FROM account_accounts WHERE localpart = $1" const selectPasswordHashSQL = "" + - "SELECT password_hash FROM account_accounts WHERE localpart = $1 AND is_active = 1" + "SELECT password_hash FROM account_accounts WHERE localpart = $1 AND is_deactivated = 0" const selectNewNumericLocalpartSQL = "" + "SELECT COUNT(localpart) FROM account_accounts" diff --git a/userapi/storage/accounts/sqlite3/deltas/20200929203058_is_active.sql b/userapi/storage/accounts/sqlite3/deltas/20200929203058_is_active.sql index f084dc863..51e9bae3c 100644 --- a/userapi/storage/accounts/sqlite3/deltas/20200929203058_is_active.sql +++ b/userapi/storage/accounts/sqlite3/deltas/20200929203058_is_active.sql @@ -6,7 +6,7 @@ CREATE TABLE account_accounts ( created_ts BIGINT NOT NULL, password_hash TEXT, appservice_id TEXT, - is_active BOOLEAN DEFAULT 1 + is_deactivated BOOLEAN DEFAULT 0 ); INSERT INTO account_accounts (