From 60a31107b488d0e7ba832d94a8326a9bf40aeef0 Mon Sep 17 00:00:00 2001 From: John Clary Date: Thu, 17 Aug 2023 11:21:17 -0400 Subject: [PATCH] deletes construction inspection work type --- .../down.sql | 23 +++++++++++++++++++ .../up.sql | 1 + 2 files changed, 24 insertions(+) create mode 100644 moped-database/migrations/1692285495049_delete_work_type_construction_inspection/down.sql create mode 100644 moped-database/migrations/1692285495049_delete_work_type_construction_inspection/up.sql diff --git a/moped-database/migrations/1692285495049_delete_work_type_construction_inspection/down.sql b/moped-database/migrations/1692285495049_delete_work_type_construction_inspection/down.sql new file mode 100644 index 0000000000..9ae44f6cdb --- /dev/null +++ b/moped-database/migrations/1692285495049_delete_work_type_construction_inspection/down.sql @@ -0,0 +1,23 @@ +INSERT INTO moped_work_types (name, key) VALUES + ('Construction Inspection', 'construction_inspection'); + +-- add as allowed work type for signal components +-- see 1691442787520_refresh-component-work-types +WITH inserts_todo AS ( + SELECT + id AS work_type_id, + component_id + FROM ( + values('construction_inspection')) AS data (work_type_key) + LEFT JOIN moped_components ON TRUE + LEFT JOIN moped_work_types mwt ON data.work_type_key = mwt.key + WHERE + moped_components.is_deleted = FALSE + AND lower(moped_components.component_name) = 'signal' + AND(lower(moped_components.component_subtype) = 'traffic' + OR lower(moped_components.component_subtype) = 'phb') +) INSERT INTO moped_component_work_types (work_type_id, component_id) +SELECT + * +FROM + inserts_todo; diff --git a/moped-database/migrations/1692285495049_delete_work_type_construction_inspection/up.sql b/moped-database/migrations/1692285495049_delete_work_type_construction_inspection/up.sql new file mode 100644 index 0000000000..cbaf5c2eee --- /dev/null +++ b/moped-database/migrations/1692285495049_delete_work_type_construction_inspection/up.sql @@ -0,0 +1 @@ +DELETE FROM moped_work_types WHERE KEY = 'construction_inspection';