-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Since these tables are no longer used, drop them.
- Loading branch information
Showing
3 changed files
with
136 additions
and
39 deletions.
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
database/migrations/000096_rule_evaluation_drop.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
-- Copyright 2024 Stacklok, Inc | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
|
||
BEGIN; | ||
|
||
-- Recreate the tables dropped in the up script. | ||
-- Using DDL generated by Goland. | ||
create table rule_evaluations | ||
( | ||
id uuid default gen_random_uuid() not null | ||
primary key, | ||
entity entities not null, | ||
profile_id uuid not null | ||
references profiles | ||
on delete cascade, | ||
rule_type_id uuid not null | ||
references rule_type | ||
on delete cascade, | ||
repository_id uuid | ||
references repositories | ||
on delete cascade, | ||
artifact_id uuid | ||
references artifacts | ||
on delete cascade, | ||
pull_request_id uuid | ||
references pull_requests | ||
on delete cascade, | ||
rule_name text not null, | ||
rule_instance_id uuid not null | ||
references rule_instances | ||
on delete cascade, | ||
migrated boolean default false not null | ||
); | ||
|
||
alter table rule_evaluations | ||
owner to postgres; | ||
|
||
create unique index rule_evaluations_results_name_lower_idx | ||
on rule_evaluations (profile_id, lower(rule_name), repository_id, | ||
COALESCE(artifact_id, '00000000-0000-0000-0000-000000000000'::uuid), entity, rule_type_id, | ||
COALESCE(pull_request_id, '00000000-0000-0000-0000-000000000000'::uuid)); | ||
|
||
create index rule_evaluations_repository_id_idx | ||
on rule_evaluations (repository_id); | ||
|
||
create table rule_details_eval | ||
( | ||
id uuid default gen_random_uuid() not null | ||
primary key, | ||
rule_eval_id uuid not null | ||
references rule_evaluations | ||
on delete cascade, | ||
status eval_status_types not null, | ||
details text not null, | ||
last_updated timestamp default now() not null | ||
); | ||
|
||
alter table rule_details_eval | ||
owner to postgres; | ||
|
||
create unique index idx_rule_detail_eval_ids | ||
on rule_details_eval (rule_eval_id); | ||
|
||
create table rule_details_remediate | ||
( | ||
id uuid default gen_random_uuid() not null | ||
primary key, | ||
rule_eval_id uuid not null | ||
references rule_evaluations | ||
on delete cascade, | ||
status remediation_status_types not null, | ||
details text not null, | ||
last_updated timestamp default now() not null, | ||
metadata jsonb default '{}'::jsonb not null | ||
); | ||
|
||
alter table rule_details_remediate | ||
owner to postgres; | ||
|
||
create unique index idx_rule_detail_remediate_ids | ||
on rule_details_remediate (rule_eval_id); | ||
|
||
create table rule_details_alert | ||
( | ||
id uuid default gen_random_uuid() not null | ||
primary key, | ||
rule_eval_id uuid not null | ||
references rule_evaluations | ||
on delete cascade, | ||
status alert_status_types not null, | ||
details text not null, | ||
metadata jsonb default '{}'::jsonb not null, | ||
last_updated timestamp default now() not null | ||
); | ||
|
||
alter table rule_details_alert | ||
owner to postgres; | ||
|
||
create unique index idx_rule_detail_alert_ids | ||
on rule_details_alert (rule_eval_id); | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- Copyright 2024 Stacklok, Inc | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
|
||
BEGIN; | ||
|
||
-- Drop these tables, they have been replaced by evaluation_rule_entities and the related tables. | ||
DROP TABLE rule_details_eval; | ||
DROP TABLE rule_details_alert; | ||
DROP TABLE rule_details_remediate; | ||
DROP TABLE rule_evaluations; | ||
|
||
COMMIT; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.