Skip to content

Commit 30d1d0a

Browse files
committed
schema: Distinct Source Rules Schema Upgrade File
Move the schema upgrades to a distinct schema upgrade file and readd the ck_source_bcrypt_listener_password_hash constraint to these files, initially added in dc4396a.
1 parent 33b2934 commit 30d1d0a

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

schema/mysql/schema.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ CREATE TABLE source (
212212
-- will likely need a distinguishing value for multiple sources of the same type in the future, like for example
213213
-- the Icinga DB environment ID for Icinga 2 sources
214214

215-
-- The column listener_password_hash is type-dependent.
216215
-- This column is required to limit API access for incoming connections to the Listener.
217216
-- The username will be "source-${id}", allowing early verification.
218217
listener_password_hash text,

schema/mysql/upgrades/001.sql renamed to schema/mysql/upgrades/0.2.0-source-rules.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
ALTER TABLE source DROP CONSTRAINT ck_source_icinga2_has_config;
1+
ALTER TABLE source
2+
DROP CONSTRAINT ck_source_icinga2_has_config,
3+
DROP CONSTRAINT ck_source_bcrypt_listener_password_hash;
24
ALTER TABLE source
35
DROP COLUMN icinga2_base_url,
46
DROP COLUMN icinga2_auth_user,
57
DROP COLUMN icinga2_auth_pass,
68
DROP COLUMN icinga2_ca_pem,
79
DROP COLUMN icinga2_common_name,
8-
DROP COLUMN icinga2_insecure_tls;
10+
DROP COLUMN icinga2_insecure_tls,
11+
ADD CONSTRAINT ck_source_bcrypt_listener_password_hash CHECK (
12+
listener_password_hash IS NULL OR listener_password_hash LIKE '$2_$%');
913

1014
ALTER TABLE rule
1115
ADD COLUMN source_id bigint DEFAULT NULL AFTER timeperiod_id,

schema/pgsql/schema.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ CREATE TABLE source (
244244
-- will likely need a distinguishing value for multiple sources of the same type in the future, like for example
245245
-- the Icinga DB environment ID for Icinga 2 sources
246246

247-
-- The column listener_password_hash is type-dependent.
248247
-- This column is required to limit API access for incoming connections to the Listener.
249248
-- The username will be "source-${id}", allowing early verification.
250249
listener_password_hash text,

schema/pgsql/upgrades/001.sql renamed to schema/pgsql/upgrades/0.2.0-source-rules.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
ALTER TABLE source DROP CONSTRAINT ck_source_icinga2_has_config;
1+
ALTER TABLE source
2+
DROP CONSTRAINT ck_source_icinga2_has_config,
3+
DROP CONSTRAINT ck_source_bcrypt_listener_password_hash;
24
ALTER TABLE source
35
DROP COLUMN icinga2_base_url,
46
DROP COLUMN icinga2_auth_user,
57
DROP COLUMN icinga2_auth_pass,
68
DROP COLUMN icinga2_ca_pem,
79
DROP COLUMN icinga2_common_name,
8-
DROP COLUMN icinga2_insecure_tls;
10+
DROP COLUMN icinga2_insecure_tls,
11+
ADD CONSTRAINT ck_source_bcrypt_listener_password_hash CHECK (
12+
listener_password_hash IS NULL OR listener_password_hash LIKE '$2_$%');
913

1014
ALTER TABLE rule
1115
ADD COLUMN source_id bigint DEFAULT NULL,

0 commit comments

Comments
 (0)