From b172cc2a825063824ec46a66d66d8fbbae5de642 Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Sat, 17 Apr 2021 17:23:37 +0200 Subject: [PATCH] fix: reset login_policy views (to ensure defaults) (#1605) * fix: reset login_policy views (to ensure defaults) * fix: migration 1.37 --- .../V1.37__current_sequence_table.sql | 24 ++++--------------- .../cockroach/V1.38__reset_login_policies.sql | 9 +++++++ 2 files changed, 14 insertions(+), 19 deletions(-) create mode 100644 migrations/cockroach/V1.38__reset_login_policies.sql diff --git a/migrations/cockroach/V1.37__current_sequence_table.sql b/migrations/cockroach/V1.37__current_sequence_table.sql index 860b0a8622..875713dab2 100644 --- a/migrations/cockroach/V1.37__current_sequence_table.sql +++ b/migrations/cockroach/V1.37__current_sequence_table.sql @@ -4,28 +4,14 @@ DELETE FROM authz.current_sequences WHERE aggregate_type <> ''; DELETE FROM adminapi.current_sequences WHERE aggregate_type <> ''; DELETE FROM notification.current_sequences WHERE aggregate_type <> ''; -BEGIN; - -ALTER TABLE management.current_sequences DROP CONSTRAINT "primary"; -ALTER TABLE auth.current_sequences DROP CONSTRAINT "primary"; -ALTER TABLE authz.current_sequences DROP CONSTRAINT "primary"; -ALTER TABLE adminapi.current_sequences DROP CONSTRAINT "primary"; -ALTER TABLE notification.current_sequences DROP CONSTRAINT "primary"; - -ALTER TABLE management.current_sequences ADD CONSTRAINT "primary" PRIMARY KEY (view_name); -ALTER TABLE auth.current_sequences ADD CONSTRAINT "primary" PRIMARY KEY (view_name); -ALTER TABLE authz.current_sequences ADD CONSTRAINT "primary" PRIMARY KEY (view_name); -ALTER TABLE adminapi.current_sequences ADD CONSTRAINT "primary" PRIMARY KEY (view_name); -ALTER TABLE notification.current_sequences ADD CONSTRAINT "primary" PRIMARY KEY (view_name); - -COMMIT; - -BEGIN; +ALTER TABLE management.current_sequences ALTER PRIMARY KEY USING COLUMNS(view_name); +ALTER TABLE auth.current_sequences ALTER PRIMARY KEY USING COLUMNS(view_name); +ALTER TABLE authz.current_sequences ALTER PRIMARY KEY USING COLUMNS(view_name); +ALTER TABLE adminapi.current_sequences ALTER PRIMARY KEY USING COLUMNS(view_name); +ALTER TABLE notification.current_sequences ALTER PRIMARY KEY USING COLUMNS(view_name); ALTER TABLE management.current_sequences DROP COLUMN aggregate_type; ALTER TABLE auth.current_sequences DROP COLUMN aggregate_type; ALTER TABLE authz.current_sequences DROP COLUMN aggregate_type; ALTER TABLE adminapi.current_sequences DROP COLUMN aggregate_type; ALTER TABLE notification.current_sequences DROP COLUMN aggregate_type; - -COMMIT; \ No newline at end of file diff --git a/migrations/cockroach/V1.38__reset_login_policies.sql b/migrations/cockroach/V1.38__reset_login_policies.sql new file mode 100644 index 0000000000..0e4055d436 --- /dev/null +++ b/migrations/cockroach/V1.38__reset_login_policies.sql @@ -0,0 +1,9 @@ +BEGIN; + +TRUNCATE auth.login_policies; +TRUNCATE management.login_policies; + +UPDATE auth.current_sequences set current_sequence = 0 where view_name = 'auth.login_policies'; +UPDATE management.current_sequences set current_sequence = 0 where view_name = 'management.login_policies'; + +COMMIT; \ No newline at end of file