We follow a consistent development workflow to ensure high-quality code and smooth collaboration.
- feature/ - For new features (e.g.,
feature/issue-10-user-authentication) - bugfix/ - For bug fixes (e.g.,
bugfix/issue-5-fix-login-error) - refactor/ - For code refactoring (e.g.,
refactor/api-response-handler) - docs/ - For documentation changes
- PR Title:
[Issue #X] Description - PR Description: Mention the issue number it closes/fixes.
- Review: At least one approval is required before merging.
- Branch follows naming convention
- Linting and formatting pass (
npm run lintandnpm run format) - TypeScript build passes (
npm run build) - Tests pass (
npm run test) - Documentation updated if necessary
- Create a branch from
main. - Commit your changes.
- Push to your fork or the main repository.
- Open a PR.
- Ensure linting and tests pass.
- Use TypeScript strict mode.
- Use ESLint and Prettier (enforced via pre-commit hooks).
- Prefer async/await over callbacks.
- Use Zod for validation.
We use node-pg-migrate for database schema versioning and migrations.
# Run pending migrations
npm run migrate:up
# Rollback last migration
npm run migrate:down
# Check migration status
npm run migrate:status
# Create a new migration
npm run migrate:create <migration-name>- Development: Migrations run automatically on server startup in development mode
- Production: Run migrations as a separate pre-deploy step:
npm run migrate:up
- CI/CD: Migrations run automatically before integration tests
-
Create a new migration file:
npm run migrate:create add_new_feature
-
Edit the generated file in
database/migrations/ -
Implement both
upanddownfunctions:exports.up = (pgm) => { pgm.createTable('my_table', { id: 'id', name: { type: 'varchar(100)', notNull: true }, created_at: { type: 'timestamp', default: pgm.func('NOW()') } }); }; exports.down = (pgm) => { pgm.dropTable('my_table'); };
- Always provide both
upanddownmigrations - Test migrations locally before committing
- Use transactions for data migrations
- Never modify existing migrations that have been deployed
- Use descriptive migration names
- Add indexes for foreign keys and frequently queried columns
- Document complex migrations with comments
A lock table prevents concurrent migration runs. If a migration fails:
- Check the error in logs
- Fix the issue
- Run
npm run migrate:downif needed - Run
npm run migrate:upagain