Files
Wyndham-RSVN-0918/database/postgresql/smoke_transaction.sql
鲨鱼辣椒 31849411a8
Some checks failed
verify / booking-verify (push) Has been cancelled
建立5178独立项目基线
2026-09-08 15:03:45 +08:00

129 lines
2.9 KiB
PL/PgSQL

\set ON_ERROR_STOP on
BEGIN;
INSERT INTO th_hotel_booking.source_message (
hotel_id,
provider,
channel,
external_message_id,
external_conversation_id,
message_sha256,
subject,
source_schema_version
) VALUES (
'HOTEL-SMOKE',
'SMOKE_TEST',
'EMAIL',
'smoke-message-v001',
'smoke-conversation-v001',
repeat('a', 64),
'Transactional schema smoke test',
'smoke-v1'
) RETURNING id \gset smoke_source_
INSERT INTO th_hotel_booking.processing_run (
source_message_id,
revision_number,
run_status,
catalog_version,
parser_version,
input_fingerprint
) VALUES (
:smoke_source_id,
1,
'TASKS_CREATED',
'booking-catalog-v20260808',
'booking-email-parser-v0.1',
repeat('b', 64)
) RETURNING id \gset smoke_run_
INSERT INTO th_hotel_booking.booking_fact (
processing_run_id,
source_event_index,
order_ref,
event_type,
booking_type,
names_payload,
room_items_payload,
recognition_payload
) VALUES (
:smoke_run_id,
0,
'SMOKE-ORDER-1',
'NEW_BOOKING',
'GROUP',
'["SMOKE-NAME"]'::jsonb,
'[{"room_type_code":"RM3","room_count":5}]'::jsonb,
'{"selection_status":"STRICT_CURRENT_CANDIDATE"}'::jsonb
);
INSERT INTO th_hotel_booking.order_task (
hotel_id,
source_message_id,
processing_run_id,
order_ref,
idempotency_key,
task_status,
target_booking_type
) VALUES (
'HOTEL-SMOKE',
:smoke_source_id,
:smoke_run_id,
'SMOKE-ORDER-1',
'smoke-idempotency-v001',
'OPEN',
'GROUP'
) RETURNING id \gset smoke_task_
INSERT INTO th_hotel_booking.task_card (
order_task_id,
source_event_index,
card_type,
event_type,
task_subtype,
card_status,
review_status,
display_payload
) VALUES (
:smoke_task_id,
0,
'ROOM_INFORMATION',
'NEW_BOOKING',
'new_group_block',
'REVIEW_REQUIRED',
'PENDING',
'{"room_information":{"booking_type":"GROUP"}}'::jsonb
) RETURNING id \gset smoke_card_
INSERT INTO th_hotel_booking.confirmation_action (
order_task_id,
task_card_id,
action_type,
field_overrides,
reason,
actor_id
) VALUES (
:smoke_task_id,
:smoke_card_id,
'RESOLVE_REVIEW',
'[{"field_pointer":"/room_information/final_values/group_code","value":"SMOKE-GROUP"}]'::jsonb,
'Rollback-only schema smoke test',
'codex-smoke'
);
SELECT
count(*) AS joined_smoke_rows
FROM th_hotel_booking.source_message sm
JOIN th_hotel_booking.processing_run pr ON pr.source_message_id = sm.id
JOIN th_hotel_booking.order_task ot ON ot.processing_run_id = pr.id
JOIN th_hotel_booking.task_card tc ON tc.order_task_id = ot.id
JOIN th_hotel_booking.confirmation_action ca ON ca.task_card_id = tc.id
WHERE sm.id = :smoke_source_id;
ROLLBACK;
SELECT count(*) AS persisted_smoke_rows
FROM th_hotel_booking.source_message
WHERE external_message_id = 'smoke-message-v001';