A RESTful API for Heroes of Might & Magic 3
- NestJS
- TypeScript
- PostgreSQL
npm installCopy the example env and adjust if needed:
cp .env.example .env.developmentdocker compose up -dCreate or update the database schema:
npm run migration:runIf you already have tables from a previous synchronize: true setup, either use a fresh database or drop existing tables (and the migrations table if present), then run migration:run again.
Insert demo data (towns, heroes, units, etc.):
npm run seedSeed is idempotent: it skips if data already exists.
# development & watch mode
npm run start:dev
# production mode
npm run start:prod- Migrations define the schema (tables, columns, FKs). Always run
npm run migration:runon a fresh DB or after pulling new migrations. - Seed fills the DB with demo data; safe to run multiple times (no duplicates).
- Change entities in
src/(add/remove columns, new tables, etc.). - Generate a migration from the diff:
This creates a new file under
npm run migration:generate -- src/database/migrations/DescribeYourChange
src/database/migrations/withup()anddown(). - Review the generated file, then run:
npm run migration:run
| Command | Description |
|---|---|
npm run migration:run |
Run all pending migrations |
npm run migration:revert |
Revert the last migration |
npm run migration:generate -- src/database/migrations/Name |
Generate migration from entity changes |
npm run seed |
Insert demo data (skips if already seeded) |