omnix-sopiga/services/template-service/migrations/001_create_orders.up.sql

12 lines
389 B
MySQL
Raw Permalink Normal View History

2026-08-07 12:21:42 +07:00
CREATE TABLE IF NOT EXISTS orders (
id BIGSERIAL PRIMARY KEY,
order_id VARCHAR(64) NOT NULL,
customer_id VARCHAR(64) NOT NULL,
amount NUMERIC(18, 2) NOT NULL,
natural_key VARCHAR(255) NOT NULL UNIQUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_orders_customer_created
ON orders (customer_id, created_at);