@sentry/junior 0.316.0 → 0.318.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{admin-QYiDMnsu.js → admin-UOHix_5P.js} +1 -1
- package/dist/{agent-runner-Cr5Fhjf-.js → agent-runner-DeYymwh2.js} +13494 -13135
- package/dist/{reporting-window-C4dbzDiR.js → agent-status-BA5x3Xtp.js} +33 -1
- package/dist/{agent-update-delivery-BY13DPSD.js → agent-update-delivery-DH8bx7jU.js} +5 -5
- package/dist/api/schema.d.ts +600 -130
- package/dist/api/schema.js +6 -6
- package/dist/api.js +228 -214
- package/dist/{app-BhvzRD__.d.ts → app-DKAOuaoC.d.ts} +33 -18
- package/dist/app.d.ts +1 -1
- package/dist/app.js +193 -177
- package/dist/{thread-context-fiMNylbg.js → auth-pause-state-f9hJM_zO.js} +6 -59
- package/dist/catalog-runtime-BfdAnztW.js +6 -0
- package/dist/{change-record-Bqsa5ZXE.d.ts → change-record-BzJgLsv7.d.ts} +60 -1
- package/dist/{adapter-context-Bref7aPI.js → channel-access-A0de5lRv.js} +2 -42
- package/dist/{chat-core-engine-3dtlMku3.js → chat-core-engine-D3Wd7f5n.js} +6 -5
- package/dist/{child-message--2G3Ft26.js → child-message-peFWLcCZ.js} +2 -6
- package/dist/cli/chat.js +38 -30
- package/dist/cli/check.js +5 -5
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +5 -4
- package/dist/cli/snapshot-create.js +4 -2
- package/dist/cli/upgrade.js +5 -3
- package/dist/context-BKF_5zzI.js +1833 -0
- package/dist/{continue-in-slack-DbQUFe_F.js → continue-in-slack-YxwMQVeR.js} +3 -3
- package/dist/{conversation-feed-B84pMjHo.js → conversation-feed-Cj7IuBtM.js} +3 -3
- package/dist/{proxy-path-BTmXDjfx.js → conversation-privacy-Cr_dNW1p.js} +2 -16
- package/dist/{conversation-turn-DzEpTIaf.js → conversation-turn-Bru4w_FD.js} +196 -80
- package/dist/{create-DUJBXr6E.js → create-Btl1y1rq.js} +12 -11
- package/dist/{credential-sync-JH_K9Adg.js → credential-sync-DTarZ63K.js} +20 -15
- package/dist/{db-DhzvUY23.js → db-of6e3sGt.js} +20724 -27256
- package/dist/{deployment-BhvrhQeh.js → deployment-C0qXa0FD.js} +17 -15
- package/dist/{engine-context-C9Nal48K.js → engine-context-C_QL_bMQ.js} +304 -56
- package/dist/{html-B_12WjKT.js → html-9_pS9SjY.js} +6 -2
- package/dist/instrumentation.js +15 -7
- package/dist/{job-runner-DO8nslyY.js → job-runner-B2XEvpif.js} +392 -26
- package/dist/{lineage-D3AZAJVe.js → lineage-nh4z9iQN.js} +1 -1
- package/dist/{list-B0zsb5Cp.js → list-HRP3TIRl.js} +238 -550
- package/dist/{logging-B8KEJegM.js → logging-BnOG0qz2.js} +4 -50
- package/dist/{session-stop-DponjDUZ.js → mailbox-turn-Byrry9o1.js} +4807 -7102
- package/dist/{list-mkB_GU8R.js → markers-CTTtJqYn.js} +171 -124
- package/dist/{message-B5fKDYzz.js → message-BRUuLgrY.js} +13 -24
- package/dist/{model-input-CuMWy37l.js → model-input-CFC62mf-.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +21 -7
- package/dist/{oauth-callback-server-B3Vvlydo.js → oauth-callback-server-CjnnUr4o.js} +2 -2
- package/dist/{oauth-relay-6ERrGPbA.js → oauth-relay-BvHFH0fV.js} +2 -2
- package/dist/{package-discovery-BI6T_RkD.js → package-discovery-DD9vencX.js} +1 -50
- package/dist/{plugins-BXMdNdyA.js → plugins-D_Ru4CWc.js} +1 -1
- package/dist/profile-iHw1uu32.js +4657 -0
- package/dist/{transcript-CCi7323k.js → prompt-DEkStuxG.js} +92 -98
- package/dist/proxy-path-BHYoKZdq.js +15 -0
- package/dist/registry-Cl7Labpe.js +3279 -0
- package/dist/reports-C1d9azyV.js +195 -0
- package/dist/{resolve-D5JVvv6A.js → resolve-DC6zBuDV.js} +9 -29
- package/dist/{result-CS_7mo8a.js → result-DxewDuXb.js} +27 -118
- package/dist/run-conversation-Cz2ubZK-.js +337 -0
- package/dist/{runner-BzAES5W3.js → runner-99YxVN_r.js} +10 -18
- package/dist/{sandbox-egress-signals-Dwhk2Q5F.js → sandbox-egress-signals-CgoX5CTI.js} +1 -1
- package/dist/{schema-z5-wA6N4.js → schema-BTojNBr5.js} +48 -86
- package/dist/sender-actors-77zTQbSG.js +84 -0
- package/dist/{service-account-D6AsAtc1.js → service-account-YDCPSByj.js} +3 -1
- package/dist/{skills-DgJ9GBPR.js → skills-CleC0Hze.js} +6 -5
- package/dist/{slack-conversation-unfurl-Dq71EkhM.js → slack-conversation-unfurl-BNQLC12R.js} +7 -6
- package/dist/{spawn-BJWpdwhQ.js → spawn-DuZfodPa.js} +5 -5
- package/dist/{system-prompt-table-iIgpmslr.js → system-prompt-table-Ci6Ck4gk.js} +88 -69
- package/dist/{task-runner-BJae4JwE.js → task-runner-BJ9Up3bG.js} +30 -53
- package/dist/topics-BoCkoPJJ.js +21 -0
- package/dist/turn-membership-VT7XZh-L.js +856 -0
- package/dist/{turn-wake-BjDW7x-5.js → turn-wake-C7HeLHAM.js} +3 -4
- package/dist/{media-BebquhET.js → types-DCzTAA63.js} +629 -593
- package/dist/user-customization-CvfuY9Eo.js +93 -0
- package/dist/users-Cb9c1k9q.js +181 -0
- package/dist/{validation-D5WmmmhX.js → validation-BiUmWPhy.js} +1 -1
- package/dist/{version-CBQoanXb.js → version-VEXiEcZu.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{worker-Cyb4kF17.js → worker-ChWYQdhm.js} +5 -4
- package/migrations/20261126025226_drop_agent_invocations/migration.sql +6 -0
- package/migrations/20261126025226_drop_agent_invocations/snapshot.json +9 -0
- package/migrations/20261126033000_space_conversations_lead_children/migration.sql +155 -0
- package/migrations/20261126033000_space_conversations_lead_children/snapshot.json +9 -0
- package/migrations/20261126144620_drop_user_message_time_index/migration.sql +1 -0
- package/migrations/20261126144620_drop_user_message_time_index/snapshot.json +38 -0
- package/migrations/20261126153100_inbox_item_subjects/migration.sql +140 -0
- package/migrations/20261126153100_inbox_item_subjects/snapshot.json +9 -0
- package/migrations/20261126153103_inbox_item_subjects_not_null/migration.sql +12 -0
- package/migrations/20261126153103_inbox_item_subjects_not_null/snapshot.json +9 -0
- package/migrations/20261126153105_inbox_item_subject_indexes/migration.sql +1 -0
- package/migrations/20261126153105_inbox_item_subject_indexes/snapshot.json +9 -0
- package/migrations/20261126153108_automation_run_conversation_index/migration.sql +1 -0
- package/migrations/20261126153108_automation_run_conversation_index/snapshot.json +9 -0
- package/migrations/20261126153159_inbox_item_subjects_schema/migration.sql +4 -0
- package/migrations/20261126153159_inbox_item_subjects_schema/snapshot.json +437 -0
- package/migrations/20261126153259_inbox_questions/migration.sql +76 -0
- package/migrations/20261126153259_inbox_questions/snapshot.json +9 -0
- package/migrations/20261126153301_inbox_questions_valid/migration.sql +3 -0
- package/migrations/20261126153301_inbox_questions_valid/snapshot.json +9 -0
- package/migrations/20261126153343_inbox_questions_schema/migration.sql +5 -0
- package/migrations/20261126153343_inbox_questions_schema/snapshot.json +407 -0
- package/migrations/20261126154025_inbox_item_owners/migration.sql +74 -0
- package/migrations/20261126154025_inbox_item_owners/snapshot.json +9 -0
- package/migrations/20261126154048_inbox_item_open_subject_key_index/migration.sql +1 -0
- package/migrations/20261126154048_inbox_item_open_subject_key_index/snapshot.json +9 -0
- package/migrations/20261126154051_drop_inbox_item_owner_indexes/migration.sql +7 -0
- package/migrations/20261126154051_drop_inbox_item_owner_indexes/snapshot.json +9 -0
- package/migrations/20261126154121_inbox_item_owners_schema/migration.sql +8 -0
- package/migrations/20261126154121_inbox_item_owners_schema/snapshot.json +311 -0
- package/migrations/20261126175601_conversation_event_turn/migration.sql +5 -0
- package/migrations/20261126175601_conversation_event_turn/snapshot.json +103 -0
- package/migrations/20261126175614_conversation_event_turn_index/migration.sql +1 -0
- package/migrations/20261126175614_conversation_event_turn_index/snapshot.json +62 -0
- package/migrations/20261126230028_merge_leaves/migration.sql +2 -0
- package/migrations/20261126230028_merge_leaves/snapshot.json +12 -0
- package/migrations/20261126231932_space_lead_holds_name/migration.sql +46 -0
- package/migrations/20261126231932_space_lead_holds_name/snapshot.json +58 -0
- package/migrations/20261127001022_merge_leaves/migration.sql +2 -0
- package/migrations/20261127001022_merge_leaves/snapshot.json +12 -0
- package/migrations/20261127002500_turn_discarded_usage/migration.sql +2 -0
- package/migrations/20261127002500_turn_discarded_usage/snapshot.json +73 -0
- package/package.json +5 -5
- package/dist/people-CUtFApfL.js +0 -81
- package/dist/start-conversation-B-LIqqNi.js +0 -162
- package/dist/turn-session-routing-D15orfwy.js +0 -1309
- package/dist/user-customization-B27StpVQ.js +0 -9
- package/dist/web-message-id-C6P83ans.js +0 -10
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
ALTER TABLE "junior_inbox_items" ADD COLUMN "subject_kind" text;--> statement-breakpoint
|
|
2
|
+
-- Each item gets its subject. The kind comes from the old key prefix. The
|
|
3
|
+
-- subject kind and id now name the item. New code still gets a dedupe key,
|
|
4
|
+
-- and the other old columns and checks stay, so the release before this
|
|
5
|
+
-- one can still read and write every row after a rollback
|
|
6
|
+
-- (20261126154025_inbox_item_owners). A later release drops them.
|
|
7
|
+
-- A GitHub pull request has one item for all of its asks, and its id is
|
|
8
|
+
-- GitHub's id of the pull request, read from the code change records by the
|
|
9
|
+
-- repository and number in the old key, or else by the number and the owner
|
|
10
|
+
-- Conversation, after a repository rename. A plugin item uses its subject
|
|
11
|
+
-- link as the id when it had one. An agent's item is a question, and its
|
|
12
|
+
-- old key is its id, so two questions about one object stay two items. Its
|
|
13
|
+
-- old subject link, in `subject_url` or else in `subject_id`, becomes its
|
|
14
|
+
-- first evidence link. A notice keeps no request, so its link stays in
|
|
15
|
+
-- `subject_url`, and its question reads it from there
|
|
16
|
+
-- (20261126153259_inbox_questions).
|
|
17
|
+
-- `automation_id` needs no copy:
|
|
18
|
+
-- the run of the owner Conversation names the same Automation.
|
|
19
|
+
--
|
|
20
|
+
-- Old workers still add items without a subject while this release rolls
|
|
21
|
+
-- out, so a trigger gives each such row its subject by the same rules. The
|
|
22
|
+
-- backfill below fires the same trigger.
|
|
23
|
+
--
|
|
24
|
+
-- New code stores each http(s) evidence link as `URL.href`, so a link
|
|
25
|
+
-- matches the same link that another item cites. Postgres has no URL
|
|
26
|
+
-- parser, so this function makes only the common changes of `URL.href`: it
|
|
27
|
+
-- lowercases the scheme and host, and gives a bare origin its `/`. It goes
|
|
28
|
+
-- with the legacy trigger.
|
|
29
|
+
CREATE OR REPLACE FUNCTION "junior_inbox_items_web_link"(link text)
|
|
30
|
+
RETURNS text
|
|
31
|
+
LANGUAGE sql
|
|
32
|
+
IMMUTABLE
|
|
33
|
+
AS $function$
|
|
34
|
+
SELECT lower(origin) || CASE WHEN rest = '' OR left(rest, 1) IN ('?', '#') THEN '/' || rest ELSE rest END
|
|
35
|
+
FROM (SELECT substring(link from '^[A-Za-z][A-Za-z0-9+.-]*://[^/?#]*') AS origin) AS parts,
|
|
36
|
+
LATERAL (SELECT substr(link, length(origin) + 1) AS rest) AS tail
|
|
37
|
+
$function$;--> statement-breakpoint
|
|
38
|
+
CREATE OR REPLACE FUNCTION "junior_inbox_items_legacy_subject"()
|
|
39
|
+
RETURNS trigger
|
|
40
|
+
LANGUAGE plpgsql
|
|
41
|
+
AS $function$
|
|
42
|
+
DECLARE
|
|
43
|
+
github_ref text := CASE
|
|
44
|
+
WHEN NEW."dedupe_key" ~ '^plugin:github:(pull-request-action|pull-request-ready|pull-request-review-requested|merge-conflict):[^#]+#[0-9]+$'
|
|
45
|
+
THEN regexp_replace(NEW."dedupe_key", '^plugin:github:[a-z-]+:', '')
|
|
46
|
+
END;
|
|
47
|
+
github_id text;
|
|
48
|
+
-- An agent item kept its link in `subject_url`, or else in `subject_id`.
|
|
49
|
+
legacy_link text := "junior_inbox_items_web_link"(CASE
|
|
50
|
+
WHEN NEW."subject_url" ~* '^https?://' THEN NEW."subject_url"
|
|
51
|
+
WHEN NEW."subject_id" ~* '^https?://' THEN NEW."subject_id"
|
|
52
|
+
END);
|
|
53
|
+
BEGIN
|
|
54
|
+
IF github_ref IS NOT NULL THEN
|
|
55
|
+
SELECT c."provider_id" INTO github_id
|
|
56
|
+
FROM "junior_code_changes" c
|
|
57
|
+
JOIN "junior_code_repositories" r ON r."id" = c."repository_id"
|
|
58
|
+
WHERE c."provider" = 'github'
|
|
59
|
+
AND lower(r."name") = lower(split_part(github_ref, '#', 1))
|
|
60
|
+
AND c."number" = split_part(github_ref, '#', 2)::integer
|
|
61
|
+
LIMIT 1;
|
|
62
|
+
-- A renamed repository no longer matches the name in the key. Then the
|
|
63
|
+
-- change with that number that the owner Conversation opened names the
|
|
64
|
+
-- id, when only one change matches.
|
|
65
|
+
IF github_id IS NULL AND NEW."owner_kind" = 'conversation' THEN
|
|
66
|
+
SELECT min(c."provider_id") INTO github_id
|
|
67
|
+
FROM "junior_code_changes" c
|
|
68
|
+
WHERE c."provider" = 'github'
|
|
69
|
+
AND c."number" = split_part(github_ref, '#', 2)::integer
|
|
70
|
+
AND c."conversation_ids" @> ARRAY[NEW."owner_id"]
|
|
71
|
+
HAVING count(*) = 1;
|
|
72
|
+
END IF;
|
|
73
|
+
END IF;
|
|
74
|
+
NEW."subject_kind" := CASE
|
|
75
|
+
WHEN NEW."owner_kind" = 'automation' THEN 'automation'
|
|
76
|
+
WHEN NEW."dedupe_key" LIKE 'plugin:github:merge-conflict:%' THEN 'github:merge_conflict'
|
|
77
|
+
WHEN github_ref IS NOT NULL THEN 'github:pull_request'
|
|
78
|
+
WHEN NEW."dedupe_key" LIKE 'plugin:%' THEN split_part(NEW."dedupe_key", ':', 2) || ':item'
|
|
79
|
+
WHEN NEW."dedupe_key" LIKE 'reply:%' THEN 'reply'
|
|
80
|
+
WHEN NEW."dedupe_key" LIKE 'todo:%' THEN 'todo'
|
|
81
|
+
ELSE 'question'
|
|
82
|
+
END;
|
|
83
|
+
NEW."subject_id" := CASE
|
|
84
|
+
WHEN NEW."owner_kind" = 'automation' THEN NEW."owner_id"
|
|
85
|
+
WHEN NEW."dedupe_key" LIKE 'reply:%' THEN NEW."owner_id"
|
|
86
|
+
WHEN NEW."dedupe_key" LIKE 'todo:%' THEN substr(NEW."dedupe_key", length('todo:') + 1)
|
|
87
|
+
WHEN github_ref IS NOT NULL THEN coalesce(github_id, NEW."subject_url", github_ref)
|
|
88
|
+
WHEN NEW."dedupe_key" LIKE 'plugin:%' THEN coalesce(NEW."subject_url", NEW."subject_id", substr(NEW."dedupe_key", length('plugin:' || split_part(NEW."dedupe_key", ':', 2) || ':') + 1))
|
|
89
|
+
ELSE coalesce(NEW."dedupe_key", 'ask:' || NEW."id"::text)
|
|
90
|
+
END;
|
|
91
|
+
-- Every item's http(s) evidence links get the form that new code stores,
|
|
92
|
+
-- also a closed item's, so the duplicate check below sees its old link.
|
|
93
|
+
IF jsonb_typeof(NEW."request"->'evidence') = 'array' THEN
|
|
94
|
+
NEW."request" := jsonb_set(NEW."request", '{evidence}', (SELECT coalesce(jsonb_agg(CASE WHEN entry->>'url' ~* '^https?://' THEN jsonb_set(entry, '{url}', to_jsonb("junior_inbox_items_web_link"(entry->>'url'))) ELSE entry END ORDER BY position), '[]'::jsonb) FROM jsonb_array_elements(NEW."request"->'evidence') WITH ORDINALITY AS evidence(entry, position)));
|
|
95
|
+
END IF;
|
|
96
|
+
-- A question reads what it is about from its evidence links, so its old
|
|
97
|
+
-- subject link becomes its first evidence link. A notice keeps no request,
|
|
98
|
+
-- because the old kind check still holds, so its link stays in
|
|
99
|
+
-- `subject_url`.
|
|
100
|
+
IF NEW."subject_kind" = 'question' AND NEW."kind" = 'notice' AND legacy_link IS NOT NULL THEN
|
|
101
|
+
NEW."subject_url" := legacy_link;
|
|
102
|
+
ELSIF NEW."subject_kind" = 'question'
|
|
103
|
+
AND legacy_link IS NOT NULL
|
|
104
|
+
AND NOT coalesce(NEW."request"->'evidence', '[]'::jsonb) @> jsonb_build_array(jsonb_build_object('url', legacy_link))
|
|
105
|
+
THEN
|
|
106
|
+
NEW."request" := jsonb_set(coalesce(NEW."request", '{}'::jsonb), '{evidence}', jsonb_build_array(jsonb_build_object('label', left(coalesce(nullif(NEW."subject_title", ''), legacy_link), 120), 'url', legacy_link)) || coalesce(NEW."request"->'evidence', '[]'::jsonb));
|
|
107
|
+
END IF;
|
|
108
|
+
RETURN NEW;
|
|
109
|
+
END;
|
|
110
|
+
$function$;--> statement-breakpoint
|
|
111
|
+
CREATE TRIGGER "junior_inbox_items_legacy_subject" BEFORE INSERT OR UPDATE ON "junior_inbox_items" FOR EACH ROW WHEN (NEW."subject_kind" IS NULL) EXECUTE FUNCTION "junior_inbox_items_legacy_subject"();--> statement-breakpoint
|
|
112
|
+
-- junior:bounded-backfill: every row needs its subject before the next migration sets NOT NULL, so the update runs once over the whole Inbox item table. That table holds only asks and notices for people, and the update writes each row once. The same write gives the evidence links of every row the stored form.
|
|
113
|
+
UPDATE "junior_inbox_items" SET "subject_kind" = NULL;--> statement-breakpoint
|
|
114
|
+
-- junior:bounded-backfill: before the unique open subject index below, the older of two open items that now share a subject closes. It reads only the open items and closes the few duplicates, such as the review and merge asks of one pull request.
|
|
115
|
+
UPDATE "junior_inbox_items" AS "item" SET "status" = 'dismissed', "closed_at" = now(), "close_reason" = 'A newer item asks about the same subject.', "updated_at" = now() WHERE "item"."status" = 'open' AND EXISTS (SELECT 1 FROM "junior_inbox_items" AS "newer" WHERE "newer"."status" = 'open' AND coalesce("newer"."provider", '') = coalesce("item"."provider", '') AND coalesce("newer"."provider_tenant_id", '') = coalesce("item"."provider_tenant_id", '') AND "newer"."subject_kind" = "item"."subject_kind" AND "newer"."subject_id" = "item"."subject_id" AND ("newer"."updated_at", "newer"."id") > ("item"."updated_at", "item"."id"));--> statement-breakpoint
|
|
116
|
+
-- junior:bounded-backfill: a snooze of a closed duplicate moves to the item that stays open, so that item stays hidden. It reads only the snoozes of the few duplicates. A person who also snoozed the open item keeps that snooze: its wake time is in the timer store, not here.
|
|
117
|
+
UPDATE "junior_inbox_snoozes" AS "snooze" SET "inbox_item_id" = "move"."open_id" FROM (SELECT DISTINCT ON ("snooze"."user_id", "open"."id") "snooze"."id", "open"."id" AS "open_id" FROM "junior_inbox_snoozes" AS "snooze" JOIN "junior_inbox_items" AS "item" ON "item"."id" = "snooze"."inbox_item_id" JOIN "junior_inbox_items" AS "open" ON "open"."status" = 'open' AND coalesce("open"."provider", '') = coalesce("item"."provider", '') AND coalesce("open"."provider_tenant_id", '') = coalesce("item"."provider_tenant_id", '') AND "open"."subject_kind" = "item"."subject_kind" AND "open"."subject_id" = "item"."subject_id" WHERE "snooze"."state" = 'snoozed' AND "item"."status" = 'dismissed' AND "item"."close_reason" = 'A newer item asks about the same subject.' AND NOT EXISTS (SELECT 1 FROM "junior_inbox_snoozes" AS "kept" WHERE "kept"."inbox_item_id" = "open"."id" AND "kept"."user_id" = "snooze"."user_id" AND "kept"."state" = 'snoozed') ORDER BY "snooze"."user_id", "open"."id", "snooze"."created_at" DESC) AS "move" WHERE "snooze"."id" = "move"."id";--> statement-breakpoint
|
|
118
|
+
-- junior:bounded-backfill: the assignees of a closed duplicate join the item that stays open, so they keep their ask. It reads only the assignees of the few duplicates. An open item with no assignees asks everyone, so it gets none.
|
|
119
|
+
INSERT INTO "junior_inbox_item_assignees" ("item_id", "user_id") SELECT DISTINCT "open"."id", "assignee"."user_id" FROM "junior_inbox_item_assignees" AS "assignee" JOIN "junior_inbox_items" AS "item" ON "item"."id" = "assignee"."item_id" JOIN "junior_inbox_items" AS "open" ON "open"."status" = 'open' AND coalesce("open"."provider", '') = coalesce("item"."provider", '') AND coalesce("open"."provider_tenant_id", '') = coalesce("item"."provider_tenant_id", '') AND "open"."subject_kind" = "item"."subject_kind" AND "open"."subject_id" = "item"."subject_id" WHERE "item"."status" = 'dismissed' AND "item"."close_reason" = 'A newer item asks about the same subject.' AND EXISTS (SELECT 1 FROM "junior_inbox_item_assignees" AS "kept" WHERE "kept"."item_id" = "open"."id") ON CONFLICT DO NOTHING;--> statement-breakpoint
|
|
120
|
+
-- junior:bounded-backfill: the sent pushes of a closed duplicate clear, as for any closed item, so the devices close it. It reads only the deliveries of the few duplicates.
|
|
121
|
+
UPDATE "junior_inbox_item_deliveries" AS "delivery" SET "status" = 'cleared', "updated_at" = now() FROM "junior_inbox_items" AS "item" WHERE "item"."id" = "delivery"."item_id" AND "delivery"."status" = 'sent' AND "item"."status" = 'dismissed' AND "item"."close_reason" = 'A newer item asks about the same subject.';--> statement-breakpoint
|
|
122
|
+
-- The subject now names an open item. The index is built here, in the
|
|
123
|
+
-- transaction that closed the duplicates, so an old worker cannot add a
|
|
124
|
+
-- second open item for a subject while this release rolls out. That insert
|
|
125
|
+
-- fails instead. It reads only the open items.
|
|
126
|
+
-- squawk-ignore require-concurrent-index-creation
|
|
127
|
+
CREATE UNIQUE INDEX "junior_inbox_items_open_subject_uidx" ON "junior_inbox_items" USING btree (coalesce("provider", ''),coalesce("provider_tenant_id", ''),"subject_kind","subject_id") WHERE "junior_inbox_items"."status" = 'open';--> statement-breakpoint
|
|
128
|
+
-- NOT VALID: the backfill gave every row its subject, and the checks still
|
|
129
|
+
-- hold for every new write. The next migration validates the NOT NULL checks without a
|
|
130
|
+
-- lock that blocks reads, then sets NOT NULL.
|
|
131
|
+
ALTER TABLE "junior_inbox_items" ADD CONSTRAINT "junior_inbox_items_subject_kind_not_null" CHECK ("subject_kind" IS NOT NULL) NOT VALID;--> statement-breakpoint
|
|
132
|
+
ALTER TABLE "junior_inbox_items" ADD CONSTRAINT "junior_inbox_items_subject_id_not_null" CHECK ("subject_id" IS NOT NULL) NOT VALID;
|
|
133
|
+
-- The snapshot no longer has subject_title, subject_url, subject_title_parts,
|
|
134
|
+
-- automation_id, its foreign key, junior_inbox_items_automation_idx, or
|
|
135
|
+
-- junior_inbox_items_open_dedupe_uidx. That index still lets an old worker
|
|
136
|
+
-- add only one open item per dedupe key, because a question it adds gets
|
|
137
|
+
-- the item's id as its subject (20261126153259_inbox_questions). They
|
|
138
|
+
-- stay in the database for one release, because old workers still name them
|
|
139
|
+
-- in every insert while this migration runs. The next release drops them
|
|
140
|
+
-- with the trigger above.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- VALIDATE CONSTRAINT takes only SHARE UPDATE EXCLUSIVE, so reads and writes
|
|
2
|
+
-- keep going during the scan. SET NOT NULL then reads the valid checks and
|
|
3
|
+
-- skips its own scan. The previous migration added the two checks, so no
|
|
4
|
+
-- release uses them.
|
|
5
|
+
ALTER TABLE "junior_inbox_items" VALIDATE CONSTRAINT "junior_inbox_items_subject_kind_not_null";--> statement-breakpoint
|
|
6
|
+
ALTER TABLE "junior_inbox_items" VALIDATE CONSTRAINT "junior_inbox_items_subject_id_not_null";--> statement-breakpoint
|
|
7
|
+
ALTER TABLE "junior_inbox_items" ALTER COLUMN "subject_kind" SET NOT NULL;--> statement-breakpoint
|
|
8
|
+
ALTER TABLE "junior_inbox_items" ALTER COLUMN "subject_id" SET NOT NULL;--> statement-breakpoint
|
|
9
|
+
-- squawk-ignore ban-drop-constraint -- unused since 0.315.0
|
|
10
|
+
ALTER TABLE "junior_inbox_items" DROP CONSTRAINT "junior_inbox_items_subject_kind_not_null";--> statement-breakpoint
|
|
11
|
+
-- squawk-ignore ban-drop-constraint -- unused since 0.315.0
|
|
12
|
+
ALTER TABLE "junior_inbox_items" DROP CONSTRAINT "junior_inbox_items_subject_id_not_null";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_inbox_items_subject_kind_idx" ON "junior_inbox_items" USING btree ("subject_kind","status");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_automation_runs_conversation_idx" ON "junior_automation_runs" USING btree ("conversation_id");
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- This migration does not change the database. The four migrations before
|
|
2
|
+
-- it change `junior_inbox_items` by hand, because data moves between their
|
|
3
|
+
-- statements. This snapshot records the schema that they leave, so
|
|
4
|
+
-- `drizzle-kit generate` does not write their changes again.
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "diff",
|
|
3
|
+
"version": "10",
|
|
4
|
+
"dialect": "postgres",
|
|
5
|
+
"id": "296b2a4a-6fdc-43b4-9e8e-812247ee04e0",
|
|
6
|
+
"prevIds": ["9adf29c7-813a-42e4-920d-f95fa91eb136"],
|
|
7
|
+
"footprints": [
|
|
8
|
+
{
|
|
9
|
+
"statementType": "drop_fk",
|
|
10
|
+
"statementTarget": ["table", "public", "junior_inbox_items"],
|
|
11
|
+
"writes": [
|
|
12
|
+
"s|fk|public.junior_inbox_items.junior_inbox_items_automation_id_junior_automations_id_fk",
|
|
13
|
+
"n|fk|public.junior_inbox_items.junior_inbox_items_automation_id_junior_automations_id_fk",
|
|
14
|
+
"e|fk|public.junior_inbox_items.junior_inbox_items_automation_id_junior_automations_id_fk",
|
|
15
|
+
"n|con|public.junior_inbox_items.junior_inbox_items_automation_id_junior_automations_id_fk"
|
|
16
|
+
],
|
|
17
|
+
"reads": [
|
|
18
|
+
"n|tbl|public.junior_inbox_items",
|
|
19
|
+
"n|sch|public",
|
|
20
|
+
"e|col|public.junior_inbox_items.automation_id"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"statementType": "drop_index",
|
|
25
|
+
"statementTarget": [
|
|
26
|
+
"index",
|
|
27
|
+
"public",
|
|
28
|
+
"junior_inbox_items",
|
|
29
|
+
"junior_inbox_items_open_dedupe_uidx"
|
|
30
|
+
],
|
|
31
|
+
"writes": [
|
|
32
|
+
"s|idx|public.junior_inbox_items_open_dedupe_uidx",
|
|
33
|
+
"n|idx|public.junior_inbox_items_open_dedupe_uidx",
|
|
34
|
+
"e|idx|public.junior_inbox_items_open_dedupe_uidx",
|
|
35
|
+
"n|rel|public.junior_inbox_items_open_dedupe_uidx"
|
|
36
|
+
],
|
|
37
|
+
"reads": [
|
|
38
|
+
"e|tbl|public.junior_inbox_items",
|
|
39
|
+
"n|sch|public",
|
|
40
|
+
"e|col|public.junior_inbox_items.dedupe_key"
|
|
41
|
+
],
|
|
42
|
+
"sharedWrites": []
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"statementType": "drop_index",
|
|
46
|
+
"statementTarget": [
|
|
47
|
+
"index",
|
|
48
|
+
"public",
|
|
49
|
+
"junior_inbox_items",
|
|
50
|
+
"junior_inbox_items_automation_idx"
|
|
51
|
+
],
|
|
52
|
+
"writes": [
|
|
53
|
+
"s|idx|public.junior_inbox_items_automation_idx",
|
|
54
|
+
"n|idx|public.junior_inbox_items_automation_idx",
|
|
55
|
+
"e|idx|public.junior_inbox_items_automation_idx",
|
|
56
|
+
"n|rel|public.junior_inbox_items_automation_idx"
|
|
57
|
+
],
|
|
58
|
+
"reads": [
|
|
59
|
+
"e|tbl|public.junior_inbox_items",
|
|
60
|
+
"n|sch|public",
|
|
61
|
+
"e|col|public.junior_inbox_items.automation_id",
|
|
62
|
+
"e|col|public.junior_inbox_items.status"
|
|
63
|
+
],
|
|
64
|
+
"sharedWrites": []
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"statementType": "add_column",
|
|
68
|
+
"statementTarget": [
|
|
69
|
+
"column",
|
|
70
|
+
"public",
|
|
71
|
+
"junior_inbox_items",
|
|
72
|
+
"subject_kind"
|
|
73
|
+
],
|
|
74
|
+
"writes": [
|
|
75
|
+
"s|col|public.junior_inbox_items.subject_kind",
|
|
76
|
+
"n|col|public.junior_inbox_items.subject_kind",
|
|
77
|
+
"e|col|public.junior_inbox_items.subject_kind"
|
|
78
|
+
],
|
|
79
|
+
"reads": ["n|tbl|public.junior_inbox_items", "n|sch|public"]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"statementType": "drop_column",
|
|
83
|
+
"statementTarget": [
|
|
84
|
+
"column",
|
|
85
|
+
"public",
|
|
86
|
+
"junior_inbox_items",
|
|
87
|
+
"dedupe_key"
|
|
88
|
+
],
|
|
89
|
+
"writes": [
|
|
90
|
+
"s|col|public.junior_inbox_items.dedupe_key",
|
|
91
|
+
"n|col|public.junior_inbox_items.dedupe_key",
|
|
92
|
+
"e|col|public.junior_inbox_items.dedupe_key"
|
|
93
|
+
],
|
|
94
|
+
"reads": ["n|tbl|public.junior_inbox_items", "n|sch|public"]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"statementType": "drop_column",
|
|
98
|
+
"statementTarget": [
|
|
99
|
+
"column",
|
|
100
|
+
"public",
|
|
101
|
+
"junior_inbox_items",
|
|
102
|
+
"subject_title"
|
|
103
|
+
],
|
|
104
|
+
"writes": [
|
|
105
|
+
"s|col|public.junior_inbox_items.subject_title",
|
|
106
|
+
"n|col|public.junior_inbox_items.subject_title",
|
|
107
|
+
"e|col|public.junior_inbox_items.subject_title"
|
|
108
|
+
],
|
|
109
|
+
"reads": ["n|tbl|public.junior_inbox_items", "n|sch|public"]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"statementType": "drop_column",
|
|
113
|
+
"statementTarget": [
|
|
114
|
+
"column",
|
|
115
|
+
"public",
|
|
116
|
+
"junior_inbox_items",
|
|
117
|
+
"subject_url"
|
|
118
|
+
],
|
|
119
|
+
"writes": [
|
|
120
|
+
"s|col|public.junior_inbox_items.subject_url",
|
|
121
|
+
"n|col|public.junior_inbox_items.subject_url",
|
|
122
|
+
"e|col|public.junior_inbox_items.subject_url"
|
|
123
|
+
],
|
|
124
|
+
"reads": ["n|tbl|public.junior_inbox_items", "n|sch|public"]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"statementType": "drop_column",
|
|
128
|
+
"statementTarget": [
|
|
129
|
+
"column",
|
|
130
|
+
"public",
|
|
131
|
+
"junior_inbox_items",
|
|
132
|
+
"automation_id"
|
|
133
|
+
],
|
|
134
|
+
"writes": [
|
|
135
|
+
"s|col|public.junior_inbox_items.automation_id",
|
|
136
|
+
"n|col|public.junior_inbox_items.automation_id",
|
|
137
|
+
"e|col|public.junior_inbox_items.automation_id"
|
|
138
|
+
],
|
|
139
|
+
"reads": ["n|tbl|public.junior_inbox_items", "n|sch|public"]
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"statementType": "drop_column",
|
|
143
|
+
"statementTarget": [
|
|
144
|
+
"column",
|
|
145
|
+
"public",
|
|
146
|
+
"junior_inbox_items",
|
|
147
|
+
"subject_title_parts"
|
|
148
|
+
],
|
|
149
|
+
"writes": [
|
|
150
|
+
"s|col|public.junior_inbox_items.subject_title_parts",
|
|
151
|
+
"n|col|public.junior_inbox_items.subject_title_parts",
|
|
152
|
+
"e|col|public.junior_inbox_items.subject_title_parts"
|
|
153
|
+
],
|
|
154
|
+
"reads": ["n|tbl|public.junior_inbox_items", "n|sch|public"]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"statementType": "alter_column",
|
|
158
|
+
"statementTarget": [
|
|
159
|
+
"column",
|
|
160
|
+
"public",
|
|
161
|
+
"junior_inbox_items",
|
|
162
|
+
"subject_id"
|
|
163
|
+
],
|
|
164
|
+
"writes": ["s|colprop|public.junior_inbox_items.subject_id.notNull"],
|
|
165
|
+
"reads": [
|
|
166
|
+
"n|tbl|public.junior_inbox_items",
|
|
167
|
+
"n|sch|public",
|
|
168
|
+
"n|col|public.junior_inbox_items.subject_id"
|
|
169
|
+
],
|
|
170
|
+
"sqlHash": "81846c94ece0abee"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"statementType": "create_index",
|
|
174
|
+
"statementTarget": [
|
|
175
|
+
"index",
|
|
176
|
+
"public",
|
|
177
|
+
"junior_automation_runs",
|
|
178
|
+
"junior_automation_runs_conversation_idx"
|
|
179
|
+
],
|
|
180
|
+
"writes": [
|
|
181
|
+
"s|idx|public.junior_automation_runs_conversation_idx",
|
|
182
|
+
"n|idx|public.junior_automation_runs_conversation_idx",
|
|
183
|
+
"e|idx|public.junior_automation_runs_conversation_idx",
|
|
184
|
+
"n|rel|public.junior_automation_runs_conversation_idx"
|
|
185
|
+
],
|
|
186
|
+
"reads": [
|
|
187
|
+
"n|tbl|public.junior_automation_runs",
|
|
188
|
+
"n|sch|public",
|
|
189
|
+
"n|col|public.junior_automation_runs.conversation_id"
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"statementType": "create_index",
|
|
194
|
+
"statementTarget": [
|
|
195
|
+
"index",
|
|
196
|
+
"public",
|
|
197
|
+
"junior_inbox_items",
|
|
198
|
+
"junior_inbox_items_open_subject_uidx"
|
|
199
|
+
],
|
|
200
|
+
"writes": [
|
|
201
|
+
"s|idx|public.junior_inbox_items_open_subject_uidx",
|
|
202
|
+
"n|idx|public.junior_inbox_items_open_subject_uidx",
|
|
203
|
+
"e|idx|public.junior_inbox_items_open_subject_uidx",
|
|
204
|
+
"n|rel|public.junior_inbox_items_open_subject_uidx"
|
|
205
|
+
],
|
|
206
|
+
"reads": [
|
|
207
|
+
"n|tbl|public.junior_inbox_items",
|
|
208
|
+
"n|sch|public",
|
|
209
|
+
"n|col|public.junior_inbox_items.subject_kind",
|
|
210
|
+
"n|col|public.junior_inbox_items.subject_id"
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"statementType": "create_index",
|
|
215
|
+
"statementTarget": [
|
|
216
|
+
"index",
|
|
217
|
+
"public",
|
|
218
|
+
"junior_inbox_items",
|
|
219
|
+
"junior_inbox_items_subject_kind_idx"
|
|
220
|
+
],
|
|
221
|
+
"writes": [
|
|
222
|
+
"s|idx|public.junior_inbox_items_subject_kind_idx",
|
|
223
|
+
"n|idx|public.junior_inbox_items_subject_kind_idx",
|
|
224
|
+
"e|idx|public.junior_inbox_items_subject_kind_idx",
|
|
225
|
+
"n|rel|public.junior_inbox_items_subject_kind_idx"
|
|
226
|
+
],
|
|
227
|
+
"reads": [
|
|
228
|
+
"n|tbl|public.junior_inbox_items",
|
|
229
|
+
"n|sch|public",
|
|
230
|
+
"n|col|public.junior_inbox_items.subject_kind",
|
|
231
|
+
"n|col|public.junior_inbox_items.status"
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"statementType": "add_check",
|
|
236
|
+
"statementTarget": ["table", "public", "junior_inbox_items"],
|
|
237
|
+
"writes": [
|
|
238
|
+
"s|ck|public.junior_inbox_items.junior_inbox_items_kind_check",
|
|
239
|
+
"n|ck|public.junior_inbox_items.junior_inbox_items_kind_check",
|
|
240
|
+
"e|ck|public.junior_inbox_items.junior_inbox_items_kind_check",
|
|
241
|
+
"n|con|public.junior_inbox_items.junior_inbox_items_kind_check"
|
|
242
|
+
],
|
|
243
|
+
"reads": [
|
|
244
|
+
"n|tbl|public.junior_inbox_items",
|
|
245
|
+
"n|sch|public",
|
|
246
|
+
"n|col|public.junior_inbox_items.kind",
|
|
247
|
+
"n|col|public.junior_inbox_items.request",
|
|
248
|
+
"n|col|public.junior_inbox_items.answer",
|
|
249
|
+
"n|col|public.junior_inbox_items.subject_kind"
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"statementType": "add_check",
|
|
254
|
+
"statementTarget": ["table", "public", "junior_inbox_items"],
|
|
255
|
+
"writes": [
|
|
256
|
+
"s|ck|public.junior_inbox_items.junior_inbox_items_owner_check",
|
|
257
|
+
"n|ck|public.junior_inbox_items.junior_inbox_items_owner_check",
|
|
258
|
+
"e|ck|public.junior_inbox_items.junior_inbox_items_owner_check",
|
|
259
|
+
"n|con|public.junior_inbox_items.junior_inbox_items_owner_check"
|
|
260
|
+
],
|
|
261
|
+
"reads": [
|
|
262
|
+
"n|tbl|public.junior_inbox_items",
|
|
263
|
+
"n|sch|public",
|
|
264
|
+
"n|col|public.junior_inbox_items.owner_kind",
|
|
265
|
+
"n|col|public.junior_inbox_items.subject_kind"
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
"deltas": [
|
|
270
|
+
{
|
|
271
|
+
"op": "create",
|
|
272
|
+
"row": {
|
|
273
|
+
"schema": "public",
|
|
274
|
+
"table": "junior_inbox_items",
|
|
275
|
+
"name": "subject_kind",
|
|
276
|
+
"type": "text",
|
|
277
|
+
"typeSchema": null,
|
|
278
|
+
"notNull": true,
|
|
279
|
+
"dimensions": 0,
|
|
280
|
+
"default": null,
|
|
281
|
+
"generated": null,
|
|
282
|
+
"identity": null,
|
|
283
|
+
"entityType": "columns"
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"op": "create",
|
|
288
|
+
"row": {
|
|
289
|
+
"schema": "public",
|
|
290
|
+
"table": "junior_automation_runs",
|
|
291
|
+
"name": "junior_automation_runs_conversation_idx",
|
|
292
|
+
"nameExplicit": true,
|
|
293
|
+
"columns": [
|
|
294
|
+
{
|
|
295
|
+
"value": "conversation_id",
|
|
296
|
+
"isExpression": false,
|
|
297
|
+
"asc": true,
|
|
298
|
+
"nullsFirst": false,
|
|
299
|
+
"opclass": null
|
|
300
|
+
}
|
|
301
|
+
],
|
|
302
|
+
"isUnique": false,
|
|
303
|
+
"where": null,
|
|
304
|
+
"with": "",
|
|
305
|
+
"method": "btree",
|
|
306
|
+
"entityType": "indexes"
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"op": "create",
|
|
311
|
+
"row": {
|
|
312
|
+
"schema": "public",
|
|
313
|
+
"table": "junior_inbox_items",
|
|
314
|
+
"name": "junior_inbox_items_open_subject_uidx",
|
|
315
|
+
"nameExplicit": true,
|
|
316
|
+
"columns": [
|
|
317
|
+
{
|
|
318
|
+
"value": "coalesce(\"provider\", '')",
|
|
319
|
+
"isExpression": true,
|
|
320
|
+
"asc": true,
|
|
321
|
+
"nullsFirst": false,
|
|
322
|
+
"opclass": null
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"value": "coalesce(\"provider_tenant_id\", '')",
|
|
326
|
+
"isExpression": true,
|
|
327
|
+
"asc": true,
|
|
328
|
+
"nullsFirst": false,
|
|
329
|
+
"opclass": null
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"value": "subject_kind",
|
|
333
|
+
"isExpression": false,
|
|
334
|
+
"asc": true,
|
|
335
|
+
"nullsFirst": false,
|
|
336
|
+
"opclass": null
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"value": "subject_id",
|
|
340
|
+
"isExpression": false,
|
|
341
|
+
"asc": true,
|
|
342
|
+
"nullsFirst": false,
|
|
343
|
+
"opclass": null
|
|
344
|
+
}
|
|
345
|
+
],
|
|
346
|
+
"isUnique": true,
|
|
347
|
+
"where": "\"status\" = 'open'",
|
|
348
|
+
"with": "",
|
|
349
|
+
"method": "btree",
|
|
350
|
+
"entityType": "indexes"
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
"op": "create",
|
|
355
|
+
"row": {
|
|
356
|
+
"schema": "public",
|
|
357
|
+
"table": "junior_inbox_items",
|
|
358
|
+
"name": "junior_inbox_items_subject_kind_idx",
|
|
359
|
+
"nameExplicit": true,
|
|
360
|
+
"columns": [
|
|
361
|
+
{
|
|
362
|
+
"value": "subject_kind",
|
|
363
|
+
"isExpression": false,
|
|
364
|
+
"asc": true,
|
|
365
|
+
"nullsFirst": false,
|
|
366
|
+
"opclass": null
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"value": "status",
|
|
370
|
+
"isExpression": false,
|
|
371
|
+
"asc": true,
|
|
372
|
+
"nullsFirst": false,
|
|
373
|
+
"opclass": null
|
|
374
|
+
}
|
|
375
|
+
],
|
|
376
|
+
"isUnique": false,
|
|
377
|
+
"where": null,
|
|
378
|
+
"with": "",
|
|
379
|
+
"method": "btree",
|
|
380
|
+
"entityType": "indexes"
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
"op": "drop",
|
|
385
|
+
"key": "columns\u0000[\"public\",\"junior_inbox_items\",\"dedupe_key\"]"
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"op": "drop",
|
|
389
|
+
"key": "columns\u0000[\"public\",\"junior_inbox_items\",\"subject_title\"]"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"op": "drop",
|
|
393
|
+
"key": "columns\u0000[\"public\",\"junior_inbox_items\",\"subject_url\"]"
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
"op": "drop",
|
|
397
|
+
"key": "columns\u0000[\"public\",\"junior_inbox_items\",\"automation_id\"]"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"op": "drop",
|
|
401
|
+
"key": "columns\u0000[\"public\",\"junior_inbox_items\",\"subject_title_parts\"]"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"op": "drop",
|
|
405
|
+
"key": "indexes\u0000[\"public\",\"junior_inbox_items_open_dedupe_uidx\"]"
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"op": "drop",
|
|
409
|
+
"key": "indexes\u0000[\"public\",\"junior_inbox_items_automation_idx\"]"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"op": "drop",
|
|
413
|
+
"key": "fks\u0000[\"public\",\"junior_inbox_items\",\"junior_inbox_items_automation_id_junior_automations_id_fk\"]"
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
"op": "alter",
|
|
417
|
+
"key": "columns\u0000[\"public\",\"junior_inbox_items\",\"subject_id\"]",
|
|
418
|
+
"set": {
|
|
419
|
+
"notNull": true
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"op": "alter",
|
|
424
|
+
"key": "checks\u0000[\"public\",\"junior_inbox_items\",\"junior_inbox_items_kind_check\"]",
|
|
425
|
+
"set": {
|
|
426
|
+
"value": "(\"kind\" = 'notice' and \"request\" -> 'question' is null and \"answer\" is null) or (\"kind\" = 'action' and (\"request\" -> 'question' is not null or (\"subject_kind\" not in ('question', 'reply') and \"answer\" is null)))"
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
"op": "alter",
|
|
431
|
+
"key": "checks\u0000[\"public\",\"junior_inbox_items\",\"junior_inbox_items_owner_check\"]",
|
|
432
|
+
"set": {
|
|
433
|
+
"value": "(\"owner_kind\" = 'automation') = (\"subject_kind\" = 'automation')"
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
]
|
|
437
|
+
}
|