diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index eaf09ef72b..e8c8717c4b 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -418,6 +418,7 @@ - creator_id - data - id + - name - settings - slug - team_id @@ -441,6 +442,7 @@ - creator_id - data - id + - name - settings - slug - team_id @@ -471,6 +473,7 @@ - creator_id - data - id + - name - settings - slug - team_id @@ -494,6 +497,7 @@ - creator_id - data - id + - name - settings - slug - status @@ -512,6 +516,7 @@ - creator_id - data - id + - name - settings - slug - status @@ -529,6 +534,7 @@ - creator_id - data - id + - name - settings - slug - status @@ -547,6 +553,7 @@ - creator_id - data - id + - name - settings - slug - status @@ -566,6 +573,7 @@ - creator_id - data - id + - name - settings - slug - status @@ -587,6 +595,7 @@ permission: columns: - data + - name - settings - slug - status @@ -606,6 +615,7 @@ permission: columns: - data + - name - settings - slug - status diff --git a/hasura.planx.uk/migrations/1716902907392_alter_table_public_flows_add_column_name/down.sql b/hasura.planx.uk/migrations/1716902907392_alter_table_public_flows_add_column_name/down.sql new file mode 100644 index 0000000000..3ec5c863e5 --- /dev/null +++ b/hasura.planx.uk/migrations/1716902907392_alter_table_public_flows_add_column_name/down.sql @@ -0,0 +1,3 @@ +comment on column "public"."flows"."name" is NULL; + +ALTER TABLE flows DROP COLUMN name; \ No newline at end of file diff --git a/hasura.planx.uk/migrations/1716902907392_alter_table_public_flows_add_column_name/up.sql b/hasura.planx.uk/migrations/1716902907392_alter_table_public_flows_add_column_name/up.sql new file mode 100644 index 0000000000..349ee9274e --- /dev/null +++ b/hasura.planx.uk/migrations/1716902907392_alter_table_public_flows_add_column_name/up.sql @@ -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)),'-',' ') +WHERE name IS NULL + + diff --git a/scripts/seed-database/write/flows.sql b/scripts/seed-database/write/flows.sql index 93a01f5910..6244bdfe91 100644 --- a/scripts/seed-database/write/flows.sql +++ b/scripts/seed-database/write/flows.sql @@ -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 ';'); @@ -26,7 +27,8 @@ INSERT INTO flows ( settings, copied_from, analytics_link, - status + status, + name ) SELECT id, @@ -38,7 +40,8 @@ SELECT settings, copied_from, NULL, - status + status, + name FROM sync_flows ON CONFLICT (id) DO UPDATE SET @@ -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;