1.1.0 • Published 4 years ago
requisitions-models v1.1.0
requisitions-models
Repository that contains data access layer, migrations and seeds for requisitions related data.
Local development
- If you haven't already, set up your local mysql5.7 database.
- Create database
CREATE DATABASE requisitions CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
- Create your
local-config.ts
file in the same format as./src/config/connection/local.example.ts
and replace with your local database credentials. - Run all migrations
npm run migrate-up-local
Your local database is now ready for seeding and testing. Please do not use RDS databases during development.
Migration
- Run
npm run generate-migration-file __MigrationName__=<your-migration-name>
This will create a new file using migration template and automatically suffix the date. For example, if<your-migration-name>
= 'addStatusColumn' a file named 'add-status-column-20210328070522.ts' will be created in in./migrations
. - The migration is automatically wrapped in a transaction and will be rolled back if an error occurs. Please remember that schema changes cannot be rolled back automatically which is why the down steps are executed upon an
up
failure and vice versa.
Remember to test your migration can be rolled back
CI/CD Process
- Run outstanding migrations in
requisitions_test
in production RDS instance. TODO: move this to an ecr image. - Database is seeded during
beforeAll
in tests. - Integration tests on
requisitions_test
. - Test data is destroyed during
afterAll
. - The latest migration on
requisitions_test
is undone.
Merging onto main
branch
- Publish package to npm.
- If published successfully run outstanding migrations in
requisitions_test
,requisitions_dev
andrequisitions
.