Skip to content

Draft schema (db) change process #309

@anantmittal

Description

@anantmittal

Need for Optimization
As we move forward, the following json schema related requests might arise:

  1. Add new properties (optional or required)
  2. Remove old properties (optional or required)
  3. Update features of existing properties
    1. Turn property from optional to required
    2. Turn property from required to optional
    3. Add/Update constraints on single or multiple properties
    4. Update type
    5. Update enum values
    6. Edit property name
  4. Mix of above

Describe Desired Optimization
Define and implement a database migration process which makes sure all the existing documents (in db) are consistent with respect to the new schema.

For the existent documents that do not match the updated schema, figure out what's the best way to migrate them. Note that the migration process and the document update decision is likely dependent on the type of schema update.

Describe Alternatives
There are no alternative solutions, we need to have this process in place to take care of future feature requests, bug fixes, and optimizations.

Additional Context
Some notes from NCI R01 Technology Implementation Meeting on April 18 2022:

  • Write a new json schema (BIG OR) to validate if document (json) matches just oneOf all the existing schemas
  • Introduce the above schema check in collection utils
  • Write a migration script which exports the database, validates all the documents against schemas (old and the new updated one(s)), fixes the document(s) that result in schema failure, validates all the documents again, insert all the documents into the database if there are no schema failures

Metadata

Metadata

Labels

BackendThis issue requires touching flask and/or database modelDatabase SchemaThis issue changes the database schemaHigh priorityThis issue is high priority

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions