This directory contains database configuration and migrations for Stellar Uzima Backend.
database/
├── migrations/ # TypeORM migrations
├── data-source.ts # Database configuration (to be created)
├── database.module.ts # Database module
└── README.md
To create a new migration:
npm run migrate:create -- -n MigrationNameTo run migrations:
npm run migrateEntity files are located in their respective module directories:
src/modules/users/entities/user.entity.tssrc/modules/health-tasks/entities/task.entity.tssrc/modules/wallet/entities/wallet.entity.ts- etc.
- Ensure PostgreSQL is running
- Create the database specified in
.env - Run
npm run start:devto automatically sync entities (in development)
- Create entities in their respective modules
- Use TypeORM decorators for all database-related metadata
- Always create migrations for schema changes
- Add proper indexes and constraints
- Use migrations for production deployments