e-commerce

Tables (32)

carriers

  • id — BIGSERIAL — Primary key — NOT NULL
  • name — VARCHAR(100) — NOT NULL
  • code — VARCHAR(30) — NOT NULL

categories

  • id — BIGSERIAL — Primary key — NOT NULL
  • parent_id — BIGINT — Foreign key → categories.id
  • code — VARCHAR(50) — NOT NULL
  • name — VARCHAR(100) — NOT NULL

claim_evidences

  • id — BIGSERIAL — Primary key — NOT NULL
  • claim_id — BIGINT — Foreign key → claims.id — NOT NULL
  • file_url — VARCHAR(500) — NOT NULL
  • evidence_type — VARCHAR(30) — NOT NULL
  • created_at — TIMESTAMP — NOT NULL

claim_histories

  • id — BIGSERIAL — Primary key — NOT NULL
  • claim_id — BIGINT — Foreign key → claims.id — NOT NULL
  • status — VARCHAR(30) — NOT NULL
  • changed_at — TIMESTAMP — NOT NULL
  • note — TEXT

claim_items

  • id — BIGSERIAL — Primary key — NOT NULL
  • claim_id — BIGINT — Foreign key → claims.id — NOT NULL
  • order_item_id — BIGINT — Foreign key → order_items.id — NOT NULL
  • quantity — INTEGER — NOT NULL
  • replacement_variant_id — BIGINT — Foreign key → product_variants.id
  • inspection_result — VARCHAR(50)

claims

  • id — BIGSERIAL — Primary key — NOT NULL
  • order_id — BIGINT — Foreign key → orders.id — NOT NULL
  • type — VARCHAR(30) — NOT NULL
  • reason — VARCHAR(50) — NOT NULL
  • reason_detail — TEXT
  • responsibility — VARCHAR(30)
  • status — VARCHAR(30) — NOT NULL
  • requested_at — TIMESTAMP — NOT NULL
  • completed_at — TIMESTAMP
  • return_shipping_fee — NUMERIC(14,2)

coupons

  • id — BIGSERIAL — Primary key — NOT NULL
  • name — VARCHAR(100) — NOT NULL
  • type — VARCHAR(30) — NOT NULL
  • discount_amount — NUMERIC(14,2)
  • discount_rate — NUMERIC(5,2)
  • expired_at — TIMESTAMP

customer_addresses

  • id — BIGSERIAL — Primary key — NOT NULL
  • customer_id — BIGINT — Foreign key → customers.id — NOT NULL
  • recipient_name — VARCHAR(100) — NOT NULL
  • postal_code — VARCHAR(10) — NOT NULL
  • address — VARCHAR(255) — NOT NULL
  • address_detail — VARCHAR(255)
  • is_default — BOOLEAN — NOT NULL

customer_coupons

  • id — BIGSERIAL — Primary key — NOT NULL
  • customer_id — BIGINT — Foreign key → customers.id — NOT NULL
  • coupon_id — BIGINT — Foreign key → coupons.id — NOT NULL
  • status — VARCHAR(30) — NOT NULL
  • issued_at — TIMESTAMP — NOT NULL
  • used_at — TIMESTAMP
  • expires_at — TIMESTAMP

customer_grade_histories

  • id — BIGSERIAL — Primary key — NOT NULL
  • customer_id — BIGINT — Foreign key → customers.id — NOT NULL
  • grade_id — BIGINT — Foreign key → customer_grades.id — NOT NULL
  • changed_at — TIMESTAMP — NOT NULL

customer_grades

  • id — BIGSERIAL — Primary key — NOT NULL
  • code — VARCHAR(30) — NOT NULL
  • name — VARCHAR(100) — NOT NULL

customers

  • id — BIGSERIAL — Primary key — NOT NULL
  • grade_id — BIGINT — Foreign key → customer_grades.id — NOT NULL
  • name — VARCHAR(100) — NOT NULL
  • email — VARCHAR(255) — NOT NULL
  • phone — VARCHAR(30)
  • status — VARCHAR(30) — NOT NULL
  • created_at — TIMESTAMP — NOT NULL

inventories

  • id — BIGSERIAL — Primary key — NOT NULL
  • variant_id — BIGINT — Foreign key → product_variants.id — NOT NULL
  • warehouse_id — BIGINT — Foreign key → warehouses.id — NOT NULL
  • quantity — INTEGER — NOT NULL
  • reserved_quantity — INTEGER — NOT NULL
  • updated_at — TIMESTAMP — NOT NULL

order_discounts

  • id — BIGSERIAL — Primary key — NOT NULL
  • order_id — BIGINT — Foreign key → orders.id — NOT NULL
  • order_item_id — BIGINT — Foreign key → order_items.id
  • customer_coupon_id — BIGINT — Foreign key → customer_coupons.id
  • discount_type — VARCHAR(30) — NOT NULL
  • amount — NUMERIC(14,2) — NOT NULL

order_items

  • id — BIGSERIAL — Primary key — NOT NULL
  • order_id — BIGINT — Foreign key → orders.id — NOT NULL
  • variant_id — BIGINT — Foreign key → product_variants.id — NOT NULL
  • quantity — INTEGER — NOT NULL
  • unit_price — NUMERIC(14,2) — NOT NULL
  • product_name — VARCHAR(255) — NOT NULL
  • status — VARCHAR(30) — NOT NULL

order_status_histories

  • id — BIGSERIAL — Primary key — NOT NULL
  • order_id — BIGINT — Foreign key → orders.id — NOT NULL
  • status — VARCHAR(30) — NOT NULL
  • changed_at — TIMESTAMP — NOT NULL

orders

  • id — BIGSERIAL — Primary key — NOT NULL
  • customer_id — BIGINT — Foreign key → customers.id — NOT NULL
  • order_number — VARCHAR(60) — NOT NULL
  • status — VARCHAR(30) — NOT NULL
  • ordered_at — TIMESTAMP — NOT NULL
  • total_amount — NUMERIC(14,2) — NOT NULL
  • shipping_fee — NUMERIC(14,2) — NOT NULL
  • recipient_name — VARCHAR(100) — NOT NULL
  • shipping_address — VARCHAR(500) — NOT NULL
  • postal_code — VARCHAR(10) — NOT NULL

payment_transactions

  • id — BIGSERIAL — Primary key — NOT NULL
  • payment_id — BIGINT — Foreign key → payments.id — NOT NULL
  • transaction_type — VARCHAR(30) — NOT NULL
  • amount — NUMERIC(14,2) — NOT NULL
  • status — VARCHAR(30) — NOT NULL
  • occurred_at — TIMESTAMP — NOT NULL
  • provider_transaction_id — VARCHAR(100)

payments

  • id — BIGSERIAL — Primary key — NOT NULL
  • order_id — BIGINT — Foreign key → orders.id — NOT NULL
  • method — VARCHAR(30) — NOT NULL
  • amount — NUMERIC(14,2) — NOT NULL
  • status — VARCHAR(30) — NOT NULL
  • paid_at — TIMESTAMP

point_transactions

  • id — BIGSERIAL — Primary key — NOT NULL
  • customer_id — BIGINT — Foreign key → customers.id — NOT NULL
  • order_id — BIGINT — Foreign key → orders.id
  • claim_id — BIGINT — Foreign key → claims.id
  • amount — BIGINT — NOT NULL
  • type — VARCHAR(30) — NOT NULL
  • occurred_at — TIMESTAMP — NOT NULL
  • expires_at — TIMESTAMP

product_variants

  • id — BIGSERIAL — Primary key — NOT NULL
  • product_id — BIGINT — Foreign key → products.id — NOT NULL
  • sku — VARCHAR(80) — NOT NULL
  • color — VARCHAR(50)
  • size — VARCHAR(50)
  • price — NUMERIC(14,2) — NOT NULL
  • status — VARCHAR(30) — NOT NULL

products

  • id — BIGSERIAL — Primary key — NOT NULL
  • seller_id — BIGINT — Foreign key → sellers.id — NOT NULL
  • category_id — BIGINT — Foreign key → categories.id — NOT NULL
  • name — VARCHAR(255) — NOT NULL
  • description — TEXT
  • status — VARCHAR(30) — NOT NULL
  • requires_installation — BOOLEAN — NOT NULL
  • is_custom_made — BOOLEAN — NOT NULL
  • is_overseas — BOOLEAN — NOT NULL

refunds

  • id — BIGSERIAL — Primary key — NOT NULL
  • payment_id — BIGINT — Foreign key → payments.id — NOT NULL
  • claim_id — BIGINT — Foreign key → claims.id — NOT NULL
  • amount — NUMERIC(14,2) — NOT NULL
  • status — VARCHAR(30) — NOT NULL
  • requested_at — TIMESTAMP — NOT NULL
  • completed_at — TIMESTAMP

sellers

  • id — BIGSERIAL — Primary key — NOT NULL
  • name — VARCHAR(150) — NOT NULL
  • seller_type — VARCHAR(30) — NOT NULL
  • status — VARCHAR(30) — NOT NULL

shipment_histories

  • id — BIGSERIAL — Primary key — NOT NULL
  • shipment_id — BIGINT — Foreign key → shipments.id — NOT NULL
  • status — VARCHAR(30) — NOT NULL
  • occurred_at — TIMESTAMP — NOT NULL
  • location — VARCHAR(150)

shipment_items

  • id — BIGSERIAL — Primary key — NOT NULL
  • shipment_id — BIGINT — Foreign key → shipments.id — NOT NULL
  • order_item_id — BIGINT — Foreign key → order_items.id — NOT NULL
  • quantity — INTEGER — NOT NULL
  • installation_status — VARCHAR(30)
  • installed_at — TIMESTAMP

shipments

  • id — BIGSERIAL — Primary key — NOT NULL
  • order_id — BIGINT — Foreign key → orders.id — NOT NULL
  • carrier_id — BIGINT — Foreign key → carriers.id
  • warehouse_id — BIGINT — Foreign key → warehouses.id
  • tracking_number — VARCHAR(100)
  • status — VARCHAR(30) — NOT NULL
  • shipped_at — TIMESTAMP
  • delivered_at — TIMESTAMP
  • promised_at — TIMESTAMP

support_actions

  • id — BIGSERIAL — Primary key — NOT NULL
  • ticket_id — BIGINT — Foreign key → support_tickets.id — NOT NULL
  • agent_id — BIGINT — Foreign key → support_agents.id
  • action_type — VARCHAR(50) — NOT NULL
  • result — TEXT
  • approval_status — VARCHAR(30)
  • approved_by — BIGINT — Foreign key → support_agents.id
  • created_at — TIMESTAMP — NOT NULL

support_agents

  • id — BIGSERIAL — Primary key — NOT NULL
  • name — VARCHAR(100) — NOT NULL
  • department — VARCHAR(100) — NOT NULL
  • role — VARCHAR(50) — NOT NULL
  • status — VARCHAR(30) — NOT NULL

support_messages

  • id — BIGSERIAL — Primary key — NOT NULL
  • ticket_id — BIGINT — Foreign key → support_tickets.id — NOT NULL
  • agent_id — BIGINT — Foreign key → support_agents.id
  • sender_type — VARCHAR(30) — NOT NULL
  • content — TEXT — NOT NULL
  • created_at — TIMESTAMP — NOT NULL

support_tickets

  • id — BIGSERIAL — Primary key — NOT NULL
  • customer_id — BIGINT — Foreign key → customers.id — NOT NULL
  • order_id — BIGINT — Foreign key → orders.id
  • claim_id — BIGINT — Foreign key → claims.id
  • assigned_agent_id — BIGINT — Foreign key → support_agents.id
  • category — VARCHAR(50) — NOT NULL
  • status — VARCHAR(30) — NOT NULL
  • subject — VARCHAR(255) — NOT NULL
  • created_at — TIMESTAMP — NOT NULL
  • closed_at — TIMESTAMP

warehouses

  • id — BIGSERIAL — Primary key — NOT NULL
  • name — VARCHAR(100) — NOT NULL
  • region — VARCHAR(100) — NOT NULL