Skip to content

Database

Postgres, one engine. There is no schema migration system — the schema is the entity files.

How this page was verified

Read on 2026-09-15 from src/database/database-config.service.ts and the module entity files in def-exsport-backend.

One engine

Exsport is Postgres only (TypeORM + pg). None of INACT's cross-driver SQL rules apply here — plain Postgres SQL is fine.

The schema is the entities

The backend runs TypeORM with synchronize: true (src/database/database-config.service.ts). On boot it loads every *.model.ts / *.entity.ts (entities: [__dirname + '/../**/*.{entity,model}{.ts,.js}'], autoLoadEntities: true) and creates or alters tables to match.

What follows from that:

  • There is no migrations folder and no seed scripts. A table exists because an entity file says @Entity({ name: '...' }). To change the schema, change the entity.
  • synchronize: true will alter a live schema to match the code. Be careful pointing a branch with entity changes at a snapshot you care about; it can drop or change columns.
  • "Seeding" is a set of REST endpoints, not scripts: POST admins/seed-settings, POST vouchers/seed-voucher-types, POST vouchers/seed-payment-methods, POST vouchers/seed-shipping-couriers, POST discounts/seed-discount-types.

Pool size is 20; the TypeORM metadata table is typeorm_metadata.

The tables, by module

Table names come from each entity's @Entity({ name }). The main groups:

  • catalogsproducts, product_articles (SKU / size / color variants), product_heads, product_types, product_subtypes, categories, sub_categories, brands, series, collaborations, tags, icons, color_codes, narratives, size_charts, product_on_sales, product_recommendations, and image/banner tables.
  • usersmembers, member_addresses, member_carts, member_cart_items, member_cart_shipping_methods, stores, and ref_countries / ref_provinces / ref_cities / ref_districts / ref_subdistricts.
  • ordersorders, order_items, order_addresses.
  • deliveriesdeliveries.
  • promotionsvouchers (+ voucher_types, voucher_couriers, voucher_payment_methods, and per-kind child tables), discounts (+ discount_types, tier/bundle/gift child tables), order_discounts, flash_sales, flash_sales_products.
  • journalsjournals, journal_categories, journal_tags, journal_products.
  • adminsadmins, roles, menus, roles_menus, departments, settings, promo_banners, highlight_subcategories.

Bilingual columns are common: nameId/nameEn, descId/descEn, metaTitleId/metaTitleEn.

Snapshots and live databases

  • Local (Mac): Postgres at localhost:5432, user postgres, holding dated snapshots exsport_prod_YYYYMMDD and exsport_dev_*. The backend .env DB_NAME picks one — read it, do not assume; it changes often (it was exsport_dev_20250921 on 2026-09-15). Prod snapshots are real production data.
  • Live: AWS RDS. Production is reached through the bastion bastion.prod.exsport.bdt.dev. TablePlus has exsport_dev / exsport_stg / exsport_prod connections.