diff --git a/db/migrate/20231010122627_re_seed_rfh_categories.rb b/db/migrate/20231010122627_re_seed_rfh_categories.rb new file mode 100644 index 000000000..affb3d933 --- /dev/null +++ b/db/migrate/20231010122627_re_seed_rfh_categories.rb @@ -0,0 +1,7 @@ +class ReSeedRfhCategories < ActiveRecord::Migration[7.0] + def up + Rake::Task['request_for_help:seed_categories'].invoke + end + + def down; end +end diff --git a/db/schema.rb b/db/schema.rb index 7a9d23ddd..14dc674b9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_19_144709) do +ActiveRecord::Schema[7.0].define(version: 2023_10_10_122627) do create_sequence "evaluation_refs" create_sequence "framework_refs" @@ -340,8 +340,8 @@ t.string "title" t.text "body" t.string "slug" - t.datetime "created_at", default: -> { "CURRENT_TIMESTAMP" }, null: false - t.datetime "updated_at", default: -> { "CURRENT_TIMESTAMP" }, null: false + t.datetime "created_at", precision: nil, default: -> { "CURRENT_TIMESTAMP" }, null: false + t.datetime "updated_at", precision: nil, default: -> { "CURRENT_TIMESTAMP" }, null: false t.string "contentful_id" t.text "sidebar" t.string "breadcrumbs", default: [], array: true @@ -643,6 +643,8 @@ t.jsonb "cc_recipients" t.jsonb "bcc_recipients" t.uuid "template_id" + t.string "ticket_type" + t.uuid "ticket_id" t.index ["in_reply_to_id"], name: "index_support_emails_on_in_reply_to_id" t.index ["template_id"], name: "index_support_emails_on_template_id" end @@ -761,7 +763,7 @@ t.string "ukprn" t.string "telephone_number" t.jsonb "local_authority" - t.datetime "opened_date" + t.datetime "opened_date", precision: nil t.string "number" t.string "rsc_region" t.string "trust_name" @@ -1089,21 +1091,6 @@ FROM support_interactions si_1 WHERE (si_1.event_type = 8)) sir ON ((si.case_id = sir.case_id))); SQL - create_view "support_message_threads", sql_definition: <<-SQL - SELECT DISTINCT ON (se.outlook_conversation_id, se.case_id) se.outlook_conversation_id AS conversation_id, - se.case_id, - ( SELECT jsonb_agg(DISTINCT elems.value) AS jsonb_agg - FROM support_emails se2, - LATERAL jsonb_array_elements(se2.recipients) elems(value) - WHERE ((se2.outlook_conversation_id)::text = (se.outlook_conversation_id)::text)) AS recipients, - se.subject, - ( SELECT se2.sent_at - FROM support_emails se2 - WHERE ((se2.outlook_conversation_id)::text = (se.outlook_conversation_id)::text) - ORDER BY se2.sent_at DESC - LIMIT 1) AS last_updated - FROM support_emails se; - SQL create_view "support_tower_cases", sql_definition: <<-SQL SELECT sc.id, sc.state, @@ -1122,4 +1109,21 @@ LEFT JOIN support_towers tow ON ((cat.support_tower_id = tow.id))) WHERE (sc.state = ANY (ARRAY[0, 1, 3])); SQL + create_view "support_message_threads", sql_definition: <<-SQL + SELECT DISTINCT ON (se.outlook_conversation_id, se.ticket_id) se.outlook_conversation_id AS conversation_id, + se.case_id, + se.ticket_id, + se.ticket_type, + ( SELECT jsonb_agg(DISTINCT elems.value) AS jsonb_agg + FROM support_emails se2, + LATERAL jsonb_array_elements(se2.recipients) elems(value) + WHERE ((se2.outlook_conversation_id)::text = (se.outlook_conversation_id)::text)) AS recipients, + se.subject, + ( SELECT se2.sent_at + FROM support_emails se2 + WHERE ((se2.outlook_conversation_id)::text = (se.outlook_conversation_id)::text) + ORDER BY se2.sent_at DESC + LIMIT 1) AS last_updated + FROM support_emails se; + SQL end