Files
ShiErFeng/shierfeng-fastapi-backend/sql/checks/20261008_prod_material_flow_baseline.sql
T

37 lines
2.6 KiB
SQL

-- 只读:在持续停写期间,于迁移前/后各执行一次,保存到权限600的文件后 cmp。
-- 只选择用户提供结构中的原字段,新增列不参与比较。覆盖正式及测试数据,不输出密码/Token。
-- JSON_ARRAY 保持 NULL 与空字符串差异并转义换行;按主键排序,避免行序造成假差异。
-- 文件包含业务信息,只留在受控生产备份位置,不上传聊天、不提交仓库。
SELECT 'biz_tunnel', JSON_ARRAY(tunnel_id, test_batch_id, site_id, tunnel_code, tunnel_name,
current_trace_no, current_trace_started_at, status, create_by, create_time, update_by, update_time, remark)
FROM biz_tunnel ORDER BY tunnel_id;
SELECT 'biz_pallet_inventory', JSON_ARRAY(pallet_id, test_batch_id, active_filling_id, warehouse_id,
site_id, current_line_id, flow_state, remaining_packages, last_event_id, version, updated_at)
FROM biz_pallet_inventory ORDER BY pallet_id;
SELECT 'biz_usage_record', JSON_ARRAY(usage_id, test_batch_id, usage_no, pallet_id, active_filling_id,
site_id, line_id, used_packages, remaining_packages_after, idempotency_key, request_hash, operator_id, occurred_at)
FROM biz_usage_record ORDER BY usage_id;
SELECT 'biz_return_item', JSON_ARRAY(return_item_id, test_batch_id, return_id, pallet_id,
active_filling_id_snapshot, remaining_packages_snapshot, create_by, create_time)
FROM biz_return_item ORDER BY return_item_id;
SELECT 'biz_pallet_event', JSON_ARRAY(event_id, test_batch_id, pallet_id, event_seq, event_type,
source_type, source_id, before_state, after_state, before_warehouse_id, before_site_id,
before_line_id, after_warehouse_id, after_site_id, after_line_id, before_remaining_packages,
after_remaining_packages, operator_id, occurred_at, idempotency_key, request_hash)
FROM biz_pallet_event ORDER BY event_id;
SELECT 'biz_filling_record', JSON_ARRAY(filling_id, test_batch_id, filling_no, pallet_id, warehouse_id,
strain_id, strain_code_snapshot, strain_name_snapshot, batch_no, production_date, expiry_date,
package_spec, initial_packages, active_slot, closed_at, idempotency_key, request_hash, operator_id,
operated_at, create_by, create_time, update_by, update_time, remark)
FROM biz_filling_record ORDER BY filling_id;
SELECT 'biz_shipment_order', JSON_ARRAY(shipment_id, test_batch_id, shipment_no, source_warehouse_id,
target_site_id, status, confirm_idempotency_key, confirm_request_hash, confirmed_by, confirmed_at,
create_by, create_time, update_by, update_time, remark)
FROM biz_shipment_order ORDER BY shipment_id;