Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

fix: Update migrations for 0.11.5 #886

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions resources/provider/migrations/postgres/30_v0.11.5.down.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,20 @@ DROP TABLE IF EXISTS aws_xray_groups;

-- Resource: xray.sampling_rules
DROP TABLE IF EXISTS aws_xray_sampling_rules;

-- aws_redshift_snapshots
ALTER TABLE IF EXISTS aws_redshift_snapshots DROP CONSTRAINT aws_redshift_snapshots_cluster_cq_id_fkey;
ALTER TABLE IF EXISTS aws_redshift_snapshots
ADD CONSTRAINT aws_redshift_snapshots_cluster_cq_id_fkey
FOREIGN KEY (cluster_cq_id)
REFERENCES aws_redshift_clusters(cq_id);

-- Resource: rds.instances
TRUNCATE TABLE aws_rds_instances CASCADE;
ALTER TABLE IF EXISTS aws_rds_instances DROP CONSTRAINT aws_rds_instances_pk;
ALTER TABLE IF EXISTS aws_rds_instances ADD CONSTRAINT aws_rds_instances_pk PRIMARY KEY (account_id,id);

-- Resource: ssm.instances
TRUNCATE TABLE aws_ssm_instance_compliance_items CASCADE;
ALTER TABLE IF EXISTS aws_ssm_instance_compliance_items DROP CONSTRAINT aws_ssm_instance_compliance_items_pk;
ALTER TABLE IF EXISTS aws_ssm_instance_compliance_items ADD CONSTRAINT aws_ssm_instance_compliance_items_pk PRIMARY KEY (instance_cq_id,resource_id,id);
18 changes: 18 additions & 0 deletions resources/provider/migrations/postgres/30_v0.11.5.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,21 @@ CREATE TABLE IF NOT EXISTS "aws_xray_sampling_rules" (
CONSTRAINT aws_xray_sampling_rules_pk PRIMARY KEY(arn),
UNIQUE(cq_id)
);

-- aws_redshift_snapshots
ALTER TABLE IF EXISTS aws_redshift_snapshots DROP CONSTRAINT aws_redshift_snapshots_cluster_cq_id_fkey;
ALTER TABLE IF EXISTS aws_redshift_snapshots
ADD CONSTRAINT aws_redshift_snapshots_cluster_cq_id_fkey
FOREIGN KEY (cluster_cq_id)
REFERENCES aws_redshift_clusters(cq_id)
ON DELETE CASCADE;

-- Resource: rds.instances
TRUNCATE TABLE aws_rds_instances CASCADE;
ALTER TABLE IF EXISTS aws_rds_instances DROP CONSTRAINT aws_rds_instances_pk;
ALTER TABLE IF EXISTS aws_rds_instances ADD CONSTRAINT aws_rds_instances_pk PRIMARY KEY (arn);

-- Resource: ssm.instances
TRUNCATE TABLE aws_ssm_instance_compliance_items CASCADE;
ALTER TABLE IF EXISTS aws_ssm_instance_compliance_items DROP CONSTRAINT aws_ssm_instance_compliance_items_pk;
ALTER TABLE IF EXISTS aws_ssm_instance_compliance_items ADD CONSTRAINT aws_ssm_instance_compliance_items_pk PRIMARY KEY (cq_id);
6 changes: 0 additions & 6 deletions resources/provider/migrations/postgres/32_v0.11.6.down.sql

This file was deleted.

7 changes: 0 additions & 7 deletions resources/provider/migrations/postgres/32_v0.11.6.up.sql

This file was deleted.

9 changes: 0 additions & 9 deletions resources/provider/migrations/postgres/33_v0.11.7.down.sql

This file was deleted.

9 changes: 0 additions & 9 deletions resources/provider/migrations/postgres/33_v0.11.7.up.sql

This file was deleted.

17 changes: 17 additions & 0 deletions resources/provider/migrations/timescale/30_v0.11.5.down.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,20 @@ DROP TABLE IF EXISTS aws_xray_groups;

-- Resource: xray.sampling_rules
DROP TABLE IF EXISTS aws_xray_sampling_rules;

-- aws_redshift_snapshots
ALTER TABLE IF EXISTS aws_redshift_snapshots DROP CONSTRAINT aws_redshift_snapshots_cluster_cq_id_fkey;
ALTER TABLE IF EXISTS aws_redshift_snapshots
ADD CONSTRAINT aws_redshift_snapshots_cluster_cq_id_fkey
FOREIGN KEY (cq_fetch_date, cluster_cq_id)
REFERENCES aws_redshift_clusters(cq_fetch_date, cq_id);

-- Resource: rds.instances
TRUNCATE TABLE aws_rds_instances CASCADE;
ALTER TABLE IF EXISTS aws_rds_instances DROP CONSTRAINT aws_rds_instances_pk;
ALTER TABLE IF EXISTS aws_rds_instances ADD CONSTRAINT aws_rds_instances_pk PRIMARY KEY (cq_fetch_date,account_id,id);

-- Resource: ssm.instances
TRUNCATE TABLE aws_ssm_instance_compliance_items CASCADE;
ALTER TABLE IF EXISTS aws_ssm_instance_compliance_items DROP CONSTRAINT aws_ssm_instance_compliance_items_pk;
ALTER TABLE IF EXISTS aws_ssm_instance_compliance_items ADD CONSTRAINT aws_ssm_instance_compliance_items_pk PRIMARY KEY (cq_fetch_date,instance_cq_id,resource_id,id);
18 changes: 18 additions & 0 deletions resources/provider/migrations/timescale/30_v0.11.5.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,21 @@ CREATE TABLE IF NOT EXISTS "aws_xray_sampling_rules" (
UNIQUE(cq_fetch_date,cq_id)
);
SELECT setup_tsdb_parent('aws_xray_sampling_rules');

-- aws_redshift_snapshots
ALTER TABLE IF EXISTS aws_redshift_snapshots DROP CONSTRAINT aws_redshift_snapshots_cluster_cq_id_fkey;
ALTER TABLE IF EXISTS aws_redshift_snapshots
ADD CONSTRAINT aws_redshift_snapshots_cluster_cq_id_fkey
FOREIGN KEY (cq_fetch_date, cluster_cq_id)
REFERENCES aws_redshift_clusters(cq_fetch_date, cq_id)
ON DELETE CASCADE;

-- Resource: rds.instances
TRUNCATE TABLE aws_rds_instances CASCADE;
ALTER TABLE IF EXISTS aws_rds_instances DROP CONSTRAINT aws_rds_instances_pk;
ALTER TABLE IF EXISTS aws_rds_instances ADD CONSTRAINT aws_rds_instances_pk PRIMARY KEY (cq_fetch_date,arn);

-- Resource: ssm.instances
TRUNCATE TABLE aws_ssm_instance_compliance_items CASCADE;
ALTER TABLE IF EXISTS aws_ssm_instance_compliance_items DROP CONSTRAINT aws_ssm_instance_compliance_items_pk;
ALTER TABLE IF EXISTS aws_ssm_instance_compliance_items ADD CONSTRAINT aws_ssm_instance_compliance_items_pk PRIMARY KEY (cq_fetch_date,cq_id);
6 changes: 0 additions & 6 deletions resources/provider/migrations/timescale/32_v0.11.6.down.sql

This file was deleted.

7 changes: 0 additions & 7 deletions resources/provider/migrations/timescale/32_v0.11.6.up.sql

This file was deleted.

9 changes: 0 additions & 9 deletions resources/provider/migrations/timescale/33_v0.11.7.down.sql

This file was deleted.

9 changes: 0 additions & 9 deletions resources/provider/migrations/timescale/33_v0.11.7.up.sql

This file was deleted.