-
Notifications
You must be signed in to change notification settings - Fork 25
Database Updates
This page exists as a guide to help the developer target what changes need to be made with a database model update.
- Update the relevant model schemas
- Update the relevant seed files (seeds exist under both
seeds/development
andseeds/testing
directories) - Update the relevant api files
- Update existing APDs in the database via a migration script
- Update the joi schemas in the common directory
- Front end changes (such as patches for redux)
In models/apd.js
, apdSchema
is the base model for an APD.
It may contain other nested schemas, such as:
-
activitySchema
found inmodels/apdActivity.js
as the base activity model -
budgetSchema
found inmodels/budget.js
as the base budget model
Because this project sets up APD of different types (HITECH, MMIS), there are also schemas for the types that expand (by inheritance) on the base schemas. That also means you can overwrite fields (if necessary) that exist in the base schema by whatever schema is inheriting the base.
Example (not an exhaustive list):
Base schema | Schema that inherits base schema | APD Type |
---|---|---|
apdSchema |
hitechSchema |
HITECH |
apdSchema |
mmisSchema |
MMIS |
activitySchema |
hitechActivitySchema |
HITECH |
activitySchema |
mmisActivitySchema |
MMIS |
budgetSchema |
hitechBudgetSchema |
HITECH |
budgetSchema |
mmisBudgetSchema |
MMIS |
Seed files exist in both seeds/development
and seeds/testing
directories
Relevant updates could include files for when a new APD is created (post.data.js
which is the APD-type-shared structure, and possibly the file that contains APD-type-specific structure, like post.mmis.data.js
)
- Create a scaffolding migration file From the api directory, run: (file name should describe update and should have “mongoose” prefix for Mongo-related changes)
yarn run make-migrate mongoose-example-file
- Modify the migration file - this code will update existing data in the database to conform to your model changes
- Use the
up
method to change the current database items to match your new model - Use the
down
method to change the database items back to how they were before the migration ran
Test this by running the migration. The command must be run inside the container: so you should either attach to the container and run it as
yarn migrate
or to run it from your local terminal run
docker compose exec api yarn migrate
Test this multiple times on the same data to ensure this has consistent results. You can delete the migration file from postgres locally, rerun the seed to reset the data, then add the migration file back and repeat.
From the api directory, run as explained above.
- Team Working Agreement
- Team composition
- Workflows and processes
- Testing and bug filing
- Accessing eAPD
- Active Documentation:
- Sandbox Environment
- Glossary of acronyms
- APDs 101
- Design iterations archive
- MMIS Budget calculations
- HITECH Budget calculations
- Beyond the APD: From Paper to Pixels
- UX principles
- User research process
- Visual styling
- Content guide
- User research findings
- eAPD pilot findings
- User needs
- Developer info
- Development environment
- Coding Standards
- Development deployment
- Infrastructure Architecture
- Code Architecture
- Tech 101
- Authentication
- APD Auto Saving Process
- Resetting an Environment
- Hardware Software List
- Deploying Staging Production Instances Using Scripts
- Terraform 101 for eAPD
- Provisioning Infrastructure with Terraform
- WebSocket basics
- Operations-and-Support-Index
- Single Branch Deployment Strategy
- Ops and Support Overview
- Service Level AOI
- Incident Response Plan
- On-Call Policy
- Infrastructure Contingency Plan
- Updating CloudFront Security Headers
- Requesting and Installing TLS Certificates