Skip to content

Commit

Permalink
feat: Add is_statutory_application_type to Seed scripts (#4202)
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 authored Jan 27, 2025
1 parent 8ea6987 commit de76aa6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion scripts/seed-database/container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ done
psql --quiet ${REMOTE_PG} --command="\\copy (SELECT id, team_id, staging_bops_submission_url, staging_bops_secret, has_planning_data, staging_govpay_secret, staging_file_api_key, power_automate_webhook_url, staging_power_automate_api_key FROM team_integrations) TO '/tmp/team_integrations.csv' (FORMAT csv, DELIMITER ';');"
echo team_integrations downloaded

psql --quiet ${REMOTE_PG} --command="\\copy (SELECT DISTINCT ON (flow_id) id, data, flow_id, summary, publisher_id, created_at, has_send_component FROM published_flows ORDER BY flow_id, created_at DESC) TO '/tmp/published_flows.csv' (FORMAT csv, DELIMITER ';');"
psql --quiet ${REMOTE_PG} --command="\\copy (SELECT DISTINCT ON (flow_id) id, data, flow_id, summary, publisher_id, created_at, has_send_component, is_statutory_application_type FROM published_flows ORDER BY flow_id, created_at DESC) TO '/tmp/published_flows.csv' (FORMAT csv, DELIMITER ';');"
echo published_flows downloaded

if [[ ${RESET} == "reset_flows" ]]; then
Expand Down
19 changes: 11 additions & 8 deletions scripts/seed-database/write/published_flows.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ CREATE TEMPORARY TABLE sync_published_flows (
summary text,
publisher_id int,
created_at timestamptz,
has_send_component boolean
has_send_component boolean,
is_statutory_application_type boolean
);

/* Ensure columns here are kept in sync with container.sh */
\copy sync_published_flows (id, data, flow_id, summary, publisher_id, created_at, has_send_component) FROM '/tmp/published_flows.csv' (FORMAT csv, DELIMITER ';');
\copy sync_published_flows (id, data, flow_id, summary, publisher_id, created_at, has_send_component, is_statutory_application_type) FROM '/tmp/published_flows.csv' (FORMAT csv, DELIMITER ';');

INSERT INTO published_flows (
id,
Expand All @@ -19,22 +19,25 @@ INSERT INTO published_flows (
summary,
publisher_id,
created_at,
has_send_component
)
has_send_component,
is_statutory_application_type
)
SELECT
id,
data,
flow_id,
summary,
publisher_id,
created_at,
has_send_component
FROM sync_published_flows
has_send_component,
is_statutory_application_type
FROM sync_published_flows
ON CONFLICT (id) DO UPDATE
SET
data = EXCLUDED.data,
flow_id = EXCLUDED.flow_id,
summary = EXCLUDED.summary,
publisher_id = EXCLUDED.publisher_id,
created_at = EXCLUDED.created_at,
has_send_component = EXCLUDED.has_send_component;
has_send_component = EXCLUDED.has_send_component,
is_statutory_application_type = EXCLUDED.is_statutory_application_type;

0 comments on commit de76aa6

Please sign in to comment.