Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding a "Name" Column to "Flows" table #3203

Merged
merged 10 commits into from
May 30, 2024
10 changes: 10 additions & 0 deletions hasura.planx.uk/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@
- creator_id
- data
- id
- name
- settings
- slug
- team_id
Expand All @@ -441,6 +442,7 @@
- creator_id
- data
- id
- name
- settings
- slug
- team_id
Expand Down Expand Up @@ -471,6 +473,7 @@
- creator_id
- data
- id
- name
- settings
- slug
- team_id
Expand All @@ -494,6 +497,7 @@
- creator_id
- data
- id
- name
- settings
- slug
- status
Expand All @@ -512,6 +516,7 @@
- creator_id
- data
- id
- name
- settings
- slug
- status
Expand All @@ -529,6 +534,7 @@
- creator_id
- data
- id
- name
- settings
- slug
- status
Expand All @@ -547,6 +553,7 @@
- creator_id
- data
- id
- name
- settings
- slug
- status
Expand All @@ -566,6 +573,7 @@
- creator_id
- data
- id
- name
- settings
- slug
- status
Expand All @@ -587,6 +595,7 @@
permission:
columns:
- data
- name
- settings
- slug
- status
Expand All @@ -606,6 +615,7 @@
permission:
columns:
- data
- name
- settings
- slug
- status
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
comment on column "public"."flows"."name" is NULL;

ALTER TABLE flows DROP COLUMN name;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
alter table "public"."flows" add column "name" text
null;
comment on column "public"."flows"."name" is 'The name of the flow, entered by the user and used to generate the "slug"';

UPDATE flows
SET name = replace(concat(upper(substring(slug,1,1)),right(slug,-1)),'-',' ')
RODO94 marked this conversation as resolved.
Show resolved Hide resolved
WHERE name IS NULL


12 changes: 8 additions & 4 deletions scripts/seed-database/write/flows.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ CREATE TEMPORARY TABLE sync_flows (
settings jsonb,
copied_from uuid,
analytics_link text,
status text
status text,
name text
);

\copy sync_flows FROM '/tmp/flows.csv' WITH (FORMAT csv, DELIMITER ';');
Expand All @@ -26,7 +27,8 @@ INSERT INTO flows (
settings,
copied_from,
analytics_link,
status
status,
name
)
SELECT
id,
Expand All @@ -38,7 +40,8 @@ SELECT
settings,
copied_from,
NULL,
status
status,
name
FROM sync_flows
ON CONFLICT (id) DO UPDATE
SET
Expand All @@ -50,7 +53,8 @@ SET
settings = EXCLUDED.settings,
copied_from = EXCLUDED.copied_from,
analytics_link = NULL,
status = EXCLUDED.status;
status = EXCLUDED.status,
name = EXCLUDED.name;

-- ensure that original flows.version is overwritten to match new operation inserted below, else sharedb will fail
UPDATE flows SET version = 1;
Expand Down
Loading