erd테스트

테이블 (8)

deal_items

  • deal_item_id — BIGSERIAL
  • deal_id — BIGINT — 외래 키 → deals.deal_id — NOT NULL
  • product_id — BIGINT — 외래 키 → products.product_id — NOT NULL
  • quantity_limit — INT

deals

  • deal_id — BIGSERIAL
  • title — VARCHAR(200) — NOT NULL
  • deal_price — BIGINT — NOT NULL
  • discount_rate — NUMERIC(5,2)
  • total_stock — INT — NOT NULL
  • remaining_stock — INT
  • start_time — TIMESTAMP — NOT NULL
  • end_time — TIMESTAMP — NOT NULL
  • status — VARCHAR(20) — NOT NULL
  • created_at — TIMESTAMP — NOT NULL

order_status_history

  • history_id — BIGSERIAL
  • order_id — BIGINT — 외래 키 → orders.order_id — NOT NULL
  • from_status — VARCHAR(30)
  • to_status — VARCHAR(30) — NOT NULL
  • changed_by — VARCHAR(50)
  • reason — TEXT
  • created_at — TIMESTAMP — NOT NULL

orders

  • order_id — BIGSERIAL
  • order_number — VARCHAR(30) — NOT NULL
  • user_id — BIGINT — 외래 키 → users.user_id — NOT NULL
  • deal_id — BIGINT — 외래 키 → deals.deal_id — NOT NULL
  • product_id — BIGINT — 외래 키 → products.product_id — NOT NULL
  • quantity — INT — NOT NULL
  • unit_price — BIGINT — NOT NULL
  • total_price — BIGINT — NOT NULL
  • status — VARCHAR(30) — NOT NULL
  • created_at — TIMESTAMP — NOT NULL
  • updated_at — TIMESTAMP

payments

  • payment_id — BIGSERIAL
  • order_id — BIGINT — 외래 키 → orders.order_id — NOT NULL
  • user_id — BIGINT — 외래 키 → users.user_id — NOT NULL
  • pg_transaction_id — VARCHAR(100)
  • amount — BIGINT — NOT NULL
  • method — VARCHAR(30)
  • status — VARCHAR(20) — NOT NULL
  • paid_at — TIMESTAMP
  • created_at — TIMESTAMP — NOT NULL

products

  • product_id — BIGSERIAL
  • name — VARCHAR(200) — NOT NULL
  • description — TEXT
  • original_price — BIGINT — NOT NULL
  • category — VARCHAR(50)
  • image_url — TEXT
  • status — VARCHAR(20) — NOT NULL
  • created_at — TIMESTAMP — NOT NULL

stock_reservations

  • reservation_id — BIGSERIAL
  • deal_id — BIGINT — 외래 키 → deals.deal_id — NOT NULL
  • order_id — BIGINT — 외래 키 → orders.order_id
  • user_id — BIGINT — 외래 키 → users.user_id — NOT NULL
  • quantity — INT — NOT NULL
  • status — VARCHAR(20) — NOT NULL
  • expires_at — TIMESTAMP
  • created_at — TIMESTAMP — NOT NULL

users

  • user_id — BIGSERIAL
  • email — VARCHAR(255) — NOT NULL
  • password_hash — VARCHAR(255) — NOT NULL
  • name — VARCHAR(100) — NOT NULL
  • phone — VARCHAR(20)
  • role — VARCHAR(20) — NOT NULL
  • status — VARCHAR(20) — NOT NULL
  • created_at — TIMESTAMP — NOT NULL
  • updated_at — TIMESTAMP