Files
danyang-match/tests/e2e/sql/seed_e2e_activity.sql
T

46 lines
2.5 KiB
SQL
Raw Normal View History

-- ============================================================
-- E2E 活动互选前置数据 seed(幂等,本机与 CI 通用)
--
-- 为什么需要:
-- `activity_mutual_connection_consents.activity_id` 有 **FK 到 activities(id)**
-- (实测:约束名 activity_mutual_connection_consents_activity_id_fkey),
-- 而 `activities.organizer_org_id` 又有 FK 到 organizations(id) 且 NOT NULL。
-- 全新库里 organizations / activities 都是**空表** —— 互选 E2E 无活动可挂。
--
-- 为什么不走运营 API 建:
-- 实测 `POST /operator/organizations` 当前**必然 500**
-- (`OrganizationService.createOrganization` 从不给 id 赋值,
-- 而 BaseEntity 用 `@TableId(type = IdType.INPUT)`、organizations.id 无 DB 默认值
-- → `invalid input syntax for type uuid: ""`)。
-- 该缺陷已单独记录,不属本 seed 的职责范围;此处按 E2E 基线数据的既有约定
-- (同目录 seed_e2e_operators.sql)直接落库。
--
-- 幂等:全部 ON CONFLICT DO NOTHING,可重复执行。
-- 固定 UUID:测试按常量引用,不依赖「查库拿 id」。
-- ============================================================
-- type 必须落在生产 chk_org_type 白名单内:
-- women_federation / trade_union / charity_center / volunteer_team / civil_affairs_partner / other
INSERT INTO organizations (id, name, type, status)
VALUES ('e2e00000-0000-0000-0000-0000000000a1', 'E2E 测试机构', 'charity_center', 'active')
ON CONFLICT (id) DO NOTHING;
-- 两个活动:互选用例需要「同一对用户在两个不同活动里各走一次」
-- (唯一约束是 (activity_id, user_a_id, user_b_id),换活动即换记录)。
INSERT INTO activities (
id, title, organizer_org_id, start_at, end_at,
location_name, location_address, total_limit,
need_review, status, created_by, activity_type
) VALUES
('e2e00000-0000-0000-0000-0000000000a2', 'E2E 互选测试活动 A',
'e2e00000-0000-0000-0000-0000000000a1',
NOW() - INTERVAL '1 day', NOW() + INTERVAL '30 day',
'E2E 测试地点', 'E2E 测试地址', 30,
false, 'ongoing', 'e2e00000-0000-0000-0000-000000000001', 'matchmaking'),
('e2e00000-0000-0000-0000-0000000000a3', 'E2E 互选测试活动 B',
'e2e00000-0000-0000-0000-0000000000a1',
NOW() - INTERVAL '1 day', NOW() + INTERVAL '30 day',
'E2E 测试地点', 'E2E 测试地址', 30,
false, 'ongoing', 'e2e00000-0000-0000-0000-000000000001', 'matchmaking')
ON CONFLICT (id) DO NOTHING;