From c389246f23d5dd3c64bc4057c2d5e8d7118ffdde Mon Sep 17 00:00:00 2001 From: sparkyx Date: Tue, 5 Aug 2025 08:46:16 +0200 Subject: [PATCH] Integrate SQL script 21 --- include/constant.php | 4 +-- include/sql/patch/ac-upgrade20.sql | 35 ++++++++++++++++++++++++ sql/ac_upgrade.sql | 30 -------------------- unit-test/include/class/followupTest.php | 3 +- 4 files changed, 38 insertions(+), 34 deletions(-) create mode 100644 include/sql/patch/ac-upgrade20.sql diff --git a/include/constant.php b/include/constant.php index 6dc63bfe2..059cdd261 100644 --- a/include/constant.php +++ b/include/constant.php @@ -25,7 +25,7 @@ global $version_noalyss; // version -define('NOALYSS_VERSION', 9311 ); +define('NOALYSS_VERSION', 9312 ); // Database schema version define("DBVERSION", 203); @@ -34,7 +34,7 @@ define("DBVERSION", 203); define("MONO_DATABASE", 25); // Version schema of account_repository database -define("DBVERSIONREPO", 20); +define("DBVERSIONREPO", 21); /* * Include path */ diff --git a/include/sql/patch/ac-upgrade20.sql b/include/sql/patch/ac-upgrade20.sql new file mode 100644 index 000000000..bc8c97f66 --- /dev/null +++ b/include/sql/patch/ac-upgrade20.sql @@ -0,0 +1,35 @@ +begin; + +ALTER TABLE public.ac_users ADD use_auth_method int2 DEFAULT 0 NULL; +COMMENT ON COLUMN public.ac_users.use_auth_method IS '0 = plain text, 1 = OTP , digit sent by email, 2=freeOTP'; +ALTER TABLE public.ac_users ADD use_otp_secret text NULL; +COMMENT ON COLUMN public.ac_users.use_otp_secret IS 'string base32 generated for OTP'; +ALTER TABLE public.ac_users ADD CONSTRAINT ac_users_unique UNIQUE (use_otp_secret); +update public.ac_users set use_auth_method=0; +ALTER TABLE public.ac_users ALTER COLUMN use_auth_method SET NOT NULL; + + + +CREATE TABLE public.otp_send_secret ( + os_id int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, -- PK + os_timestamp timestamptz DEFAULT now() NOT NULL, -- Timestamp of the email sent + os_request text NULL, -- Unique identifier when request to scan qrcode + use_id int4 NOT NULL, -- FK to ac_users + os_code varchar(8) NULL, + os_valid_time timestamp NOT NULL, + CONSTRAINT otp_send_secret_pk PRIMARY KEY (os_id), + CONSTRAINT otp_send_secret_unique UNIQUE (use_id) +); +COMMENT ON TABLE public.otp_send_secret IS 'sent to user for scanning a QRCODE for FreeOTP +or digit to connect, depends of ac_users use_auth_method.'; + +-- Column comments + +COMMENT ON COLUMN public.otp_send_secret.os_id IS 'PK'; +COMMENT ON COLUMN public.otp_send_secret.os_timestamp IS 'Timestamp of the email sent'; +COMMENT ON COLUMN public.otp_send_secret.os_request IS 'Unique identifier when request to scan qrcode'; +COMMENT ON COLUMN public.otp_send_secret.os_code IS 'contains code sent by email'; +COMMENT ON COLUMN public.otp_send_secret.use_id IS 'FK to ac_users'; + +select upgrade_repo(21); +commit; \ No newline at end of file diff --git a/sql/ac_upgrade.sql b/sql/ac_upgrade.sql index 25ec82709..e69de29bb 100644 --- a/sql/ac_upgrade.sql +++ b/sql/ac_upgrade.sql @@ -1,30 +0,0 @@ -ALTER TABLE public.ac_users ADD use_auth_method int2 DEFAULT 0 NULL; -COMMENT ON COLUMN public.ac_users.use_auth_method IS '0 = plain text, 1 = OTP , digit sent by email, 2=freeOTP'; -ALTER TABLE public.ac_users ADD use_otp_secret text NULL; -COMMENT ON COLUMN public.ac_users.use_otp_secret IS 'string base32 generated for OTP'; -ALTER TABLE public.ac_users ADD CONSTRAINT ac_users_unique UNIQUE (use_otp_secret); -update public.ac_users set use_auth_method=0; -ALTER TABLE public.ac_users ALTER COLUMN use_auth_method SET NOT NULL; - - - -CREATE TABLE public.otp_send_secret ( - os_id int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, -- PK - os_timestamp timestamptz DEFAULT now() NOT NULL, -- Timestamp of the email sent - os_request text NULL, -- Unique identifier when request to scan qrcode - use_id int4 NOT NULL, -- FK to ac_users - os_code varchar(8) NULL, - os_valid_time timestamp NOT NULL, - CONSTRAINT otp_send_secret_pk PRIMARY KEY (os_id), - CONSTRAINT otp_send_secret_unique UNIQUE (use_id) -); -COMMENT ON TABLE public.otp_send_secret IS 'sent to user for scanning a QRCODE for FreeOTP -or digit to connect, depends of ac_users use_auth_method.'; - --- Column comments - -COMMENT ON COLUMN public.otp_send_secret.os_id IS 'PK'; -COMMENT ON COLUMN public.otp_send_secret.os_timestamp IS 'Timestamp of the email sent'; -COMMENT ON COLUMN public.otp_send_secret.os_request IS 'Unique identifier when request to scan qrcode'; -COMMENT ON COLUMN public.otp_send_secret.os_code IS 'contains code sent by email'; -COMMENT ON COLUMN public.otp_send_secret.use_id IS 'FK to ac_users'; \ No newline at end of file diff --git a/unit-test/include/class/followupTest.php b/unit-test/include/class/followupTest.php index e1ba124d4..46aad8c41 100644 --- a/unit-test/include/class/followupTest.php +++ b/unit-test/include/class/followupTest.php @@ -213,5 +213,4 @@ class FollowupTest extends TestCase $this->assertTrue( ! empty($a_row->agc_comment_raw) , 'comment raw not saved'); $cn->exec_sql("delete from action_gestion where ag_title like 'phpunit%'"); - } -} \ No newline at end of file + }} \ No newline at end of file