feat(F-111): completed feature

This commit is contained in:
chattie
2026-08-21 10:10:35 +02:00
parent 18f605591b
commit b87f4f0c85
13 changed files with 331 additions and 26 deletions

View File

@@ -0,0 +1,25 @@
/**
* Order history log. Every shipping/tracking change and admin state transition
* is recorded so the order detail can show a full audit trail.
* @param {import('node-pg-migrate').MigrationBuilder} pgm
*/
export const up = (pgm) => {
pgm.sql(`
CREATE TABLE IF NOT EXISTS orders_order_history (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
order_id uuid NOT NULL REFERENCES orders_orders(id) ON DELETE CASCADE,
event_type text NOT NULL,
message text NOT NULL,
tracking_number text NULL,
actor_email text NULL,
created_at timestamptz NOT NULL DEFAULT now()
)
`);
pgm.sql(
`CREATE INDEX IF NOT EXISTS idx_orders_order_history_order ON orders_order_history (order_id, created_at)`,
);
};
export const down = (pgm) => {
pgm.sql(`DROP TABLE IF EXISTS orders_order_history`);
};