Details
-
Epic
-
Resolution: Unresolved
-
High
-
None
-
None
-
None
-
DB schema versioning
Description
Problem statement
- A new developer trying to setup the AMRIT platform has no way to get started with the database.
- When a new version of AMRIT is deployed, the DB schema changes are done with manual SQL execution even on production.
- DB schema does not follow any versioning. It is impossible right now to know where we are with the current schema on a production machine.
- Changes to DB schema are not sequential.
Requirements
- A new developer or someone trying to set up AMRIT as a DPG must be able to restore the AMRIT DB schema for all the underlying databases of AMRIT.
- DB schema must follow versioning.
- When production deployments happen, migrations from one schema to next schema must be automated through a CI-CD pipeline.
- At any point, as an IT engineer, I must be able to infer the current DB schema version of a production machine.
- Migrations from one version to the next must follow ACID principles of relational DB. It must be all or none. Migrations must happen as a transaction.
- There must be a mechanism to roll back migrations and return to the previous schema if the deployment fails or is aborted.
Potential solution
- Create a new Spring boot service to exclusively handle migrations.
- Add Flyway as the package for handling migrations: https://documentation.red-gate.com/fd/getting-started-with-flyway-184127223.html
- Connect the flyway configuration to databases of AMRIT.
- Create a baseline migration/schema for the existing DB.
- Test the baseline migration by restoring the migration file to empty DB using migrate command.
- Any additional alterations to the schema must be added as next DB schema version.
- The migrate command will be added to Jenkins pipeline as part of the CI-CD process.
- Create an API endpoint to the service to display current version of the DB and the last 5 migration numbers executed.
Attachments
Issue Links
- blocks
-
AMM-1030 CI-CD Pipeline
-
- Open
-