Files
streamline/drizzle/0021_code_sidecars.sql
2026-11-16 17:26:44 -08:00

101 lines
3.4 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 附加仓产物(FE / 以后的后端等)。交付仓仍是 tasks/features 上的 repo_key + mr_url,
-- 释义固定为 android/ios 客户端仓;附加仓不得再占用那两列。
--
-- 存量:曾经把 tt_im_monorepo 或开发任务 URL 写进原字段的行,抬进本表并把原字段扳回
-- 交付仓释义。没有这类占用的行不插附加记录 —— 涉及集以之后各次运行的 repoList 为准。
CREATE TABLE IF NOT EXISTS "code_sidecars" (
"target_kind" text NOT NULL,
"target_id" text NOT NULL,
"repo_key" text NOT NULL,
"branch_name" text,
"channel" text NOT NULL,
"url" text,
"failure_reason" text,
"updated_at" bigint NOT NULL,
PRIMARY KEY ("target_kind", "target_id", "repo_key")
);
CREATE INDEX IF NOT EXISTS code_sidecars_target_idx
ON "code_sidecars" ("target_kind", "target_id");
INSERT INTO "code_sidecars" (
"target_kind", "target_id", "repo_key", "branch_name", "channel", "url", "failure_reason", "updated_at"
)
SELECT
'bug',
t.id,
'tt-im-monorepo',
t.branch_name,
'bits-dev-task',
CASE
WHEN t.mr_url LIKE '%/develop/detail/%' OR t.mr_url LIKE '%devops_space_type=server_fe%' THEN t.mr_url
ELSE NULL
END,
CASE
WHEN t.failure_reason LIKE 'MR 提交%' AND (t.failure_reason LIKE '%开发任务%' OR t.failure_reason LIKE '%tt_im_monorepo%')
THEN t.failure_reason
ELSE NULL
END,
COALESCE(t.status_changed_at, t.created_at)
FROM "tasks" t
WHERE t.repo_key = 'tt-im-monorepo'
OR COALESCE(t.mr_url, '') LIKE '%/develop/detail/%'
OR COALESCE(t.mr_url, '') LIKE '%devops_space_type=server_fe%'
ON CONFLICT DO NOTHING;
INSERT INTO "code_sidecars" (
"target_kind", "target_id", "repo_key", "branch_name", "channel", "url", "failure_reason", "updated_at"
)
SELECT
'feature',
f.id,
'tt-im-monorepo',
f.branch_name,
'bits-dev-task',
CASE
WHEN f.mr_url LIKE '%/develop/detail/%' OR f.mr_url LIKE '%devops_space_type=server_fe%' THEN f.mr_url
ELSE NULL
END,
CASE
WHEN f.failure_reason LIKE 'MR 提交%' AND (f.failure_reason LIKE '%开发任务%' OR f.failure_reason LIKE '%tt_im_monorepo%')
THEN f.failure_reason
ELSE NULL
END,
COALESCE(f.status_changed_at, f.created_at)
FROM "features" f
WHERE f.repo_key = 'tt-im-monorepo'
OR COALESCE(f.mr_url, '') LIKE '%/develop/detail/%'
OR COALESCE(f.mr_url, '') LIKE '%devops_space_type=server_fe%'
ON CONFLICT DO NOTHING;
-- 旧卫星 first-hit 写成 sidecar key,等价于交付仓没命中。写成 platform 默认仓会
-- 谎称分支在客户端仓上,自动建 MR 就会变成「source branch not found」。
UPDATE "tasks"
SET "repo_key" = 'unpushed'
WHERE "repo_key" = 'tt-im-monorepo';
UPDATE "features"
SET "repo_key" = 'unpushed'
WHERE "repo_key" = 'tt-im-monorepo';
UPDATE "tasks"
SET "mr_url" = NULL, "mr_state" = NULL, "mr_merged_at" = NULL, "mr_synced_at" = NULL
WHERE "mr_url" LIKE '%/develop/detail/%'
OR "mr_url" LIKE '%devops_space_type=server_fe%';
UPDATE "features"
SET "mr_url" = NULL
WHERE "mr_url" LIKE '%/develop/detail/%'
OR "mr_url" LIKE '%devops_space_type=server_fe%';
UPDATE "tasks"
SET "failure_reason" = NULL
WHERE "failure_reason" LIKE 'MR 提交%'
AND ("failure_reason" LIKE '%开发任务%' OR "failure_reason" LIKE '%tt_im_monorepo%');
UPDATE "features"
SET "failure_reason" = NULL
WHERE "failure_reason" LIKE 'MR 提交%'
AND ("failure_reason" LIKE '%开发任务%' OR "failure_reason" LIKE '%tt_im_monorepo%');