Skip to content

catalog / bảng đơn lẻ (3) ​

Trang sinh tự động

Sinh từ ad83b0aea — chạy 820 migration lên PostgreSQL 17 rồi đọc pg_catalog. Mô tả bảng và cột lấy từ COMMENT ON. Không sửa tay: lần chạy docgen sau sẽ ghi đè.

3 bảng. Quay lại catalog.

categories ​

P2-01. Product category tree (<= 5 levels, products on leaves only). Soft delete, version, code/name keys (trim + NFC + lower) unique among live rows only (U6-P2-20, X-02 / Rule #11). PERM_GATED catalog.read/write (matrix CAT-01/02).

public.categories · 16 cột · 6 check · 0 unique · 4 index · 3 policy · 4 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
codetextNOT NULL
code_keytext
nametextNOT NULL
name_keytext
parent_iduuidFK → categories
descriptiontext
image_media_iduuidFK → mediaU6-P2-20: optional category image (NH-US-02/03). FK public.media(id); attach rules = be:media assertAttachable CATEGORY_IMAGE (PRODUCT_IMAGE purpose, JPG/PNG, <= 5 MiB) + media_uses category_image.
statustextNOT NULL
created_byuuidNOT NULLFK → accounts
updated_byuuidNOT NULLFK → accounts
deleted_attimestamptz
deleted_byuuidFK → accounts
created_attimestamptzNOT NULL
updated_attimestamptzNOT NULL
versionintegerNOT NULL

Khoá chính: id

Trỏ ra (5):

  • created_by → accounts · ON DELETE RESTRICT
  • deleted_by → accounts · ON DELETE RESTRICT
  • image_media_id → media · ON DELETE RESTRICT
  • parent_id → categories · ON DELETE RESTRICT
  • updated_by → accounts · ON DELETE RESTRICT

Được trỏ tới (3): categories, product_attributes, products

brands ​

P2-01. Flat brand list. Soft delete, version, code/name keys (trim + NFC + lower) unique among live rows only (U6-P2-21, X-02 / Rule #11). PERM_GATED catalog.read/write (matrix CAT-01/02).

public.brands · 14 cột · 4 check · 0 unique · 3 index · 3 policy · 4 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
codetextNOT NULL
code_keytext
nametextNOT NULL
name_keytext
descriptiontext
logo_media_iduuidFK → mediaU6-P2-21: optional brand logo (TH-US-02/03). FK public.media(id); attach rules = be:media assertAttachable BRAND_LOGO (PRODUCT_IMAGE purpose, JPG/PNG, <= 5 MiB) + media_uses brand_logo.
created_byuuidNOT NULLFK → accounts
updated_byuuidNOT NULLFK → accounts
deleted_attimestamptz
deleted_byuuidFK → accounts
created_attimestamptzNOT NULL
updated_attimestamptzNOT NULL
versionintegerNOT NULL

Khoá chính: id

Trỏ ra (4):

  • created_by → accounts · ON DELETE RESTRICT
  • deleted_by → accounts · ON DELETE RESTRICT
  • logo_media_id → media · ON DELETE RESTRICT
  • updated_by → accounts · ON DELETE RESTRICT

Được trỏ tới (1): products

combo_components ​

P2-02. Standard products inside a combo with quantities. Written with the combo, immutable afterwards.

public.combo_components · 6 cột · 2 check · 1 unique · 3 index · 2 policy · 3 trigger · RLS bật

CộtKiểuKhoáMô tả
iduuidNOT NULLPK
combo_iduuidNOT NULLFK → products
component_iduuidNOT NULLFK → products
quantityintegerNOT NULL
created_byuuidNOT NULLFK → accounts
created_attimestamptzNOT NULL

Khoá chính: id

Trỏ ra (3):

  • combo_id → products · ON DELETE RESTRICT
  • component_id → products · ON DELETE RESTRICT
  • created_by → accounts · ON DELETE RESTRICT

Được trỏ tới: không có

Sinh từ ad83b0aea · 820 migration · PostgreSQL 17