-- 021_worker_order_notes_by_worker.sql —— 按打手保存工单备注。
--
-- 工单可重新分配，拼单也有多个打手；备注必须按工单和打手独立存储。

CREATE TABLE IF NOT EXISTS worker_work_order_notes (
  work_order_id BIGINT NOT NULL REFERENCES work_orders(id) ON DELETE CASCADE,
  worker_id BIGINT NOT NULL REFERENCES worker_users(id) ON DELETE CASCADE,
  note TEXT NOT NULL DEFAULT '',
  created_at TIMESTAMPTZ NOT NULL,
  updated_at TIMESTAMPTZ NOT NULL,
  PRIMARY KEY (work_order_id, worker_id)
);

COMMENT ON TABLE worker_work_order_notes IS '打手维护的个人工单备注';
