Raido uses Flyway to manage schema migrations.
The migration process is run from within AWS via a codebuild project - we
do not run Flyway from within api-svc server process.
Remember that this codebase is publicly visible. You must not put secrets or private customer information into the DB migration scripts.
Take the data migration process for the legacy V1 data as an example:
- the scheme and migration code are committed in the
/api-svc-/db/v1-ddb-migrationproject - the actual data is stored in a private S3 bucket
- the migration process is run from a
codebuildinstance, which has been granted explicit access to the migration data files
:api-svc:db- acts as a "container" project of the various DB projects
:api-svc:db:shared- empty project, it exists to collect stuff that needs to be shared between
the
dbsubprojects - specifically, the
apiSvcPgproperties and the loading of those from the~/.config/raido/api-svc-db.gradleconfig file
- empty project, it exists to collect stuff that needs to be shared between
the
:api-svc:db:raido- contains the flyway and jooq stuff for the
raidoschema - have a quick scan of /doc/schema-guideline.md
- contains the flyway and jooq stuff for the
:api-svc:db:v1-ddb-migration- contains the flyway and jooq stuff for the
raid_v1_importschema
- contains the flyway and jooq stuff for the
Launch local Postgres instance in a docker container.
docker rm --force raido-db; docker run --name raido-db -p 7432:5432 -d --restart unless-stopped -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD= -e POSTGRES_DB=raido postgres:15.2
raido-dbis the docker container nameraidois the postgres database name
This won't actually run, because no password. Copy/paste and add a password,
then run the command to get a raido database.
The DB at that point will be completely empty (no schema structure or data).
This file controls the configuration used to do database schema creation and migration of the Postgres DB.
The :api-svc:db:shared has these default values:
apiSvcPgUrl= jdbc:postgresql://localhost:7432/raidoapiSvcPgUser= postgres
These defaults will work with the raido-db container described above.
You must configure the apiSvcPgPassword property to specify the
same password you gave to create the database:
~/.config/raido/api-svc-db.gradle:
apiSvcPgPassword="the password you specified in the `docker run` command"
apiSvcExtraLocations=["classpath:db/env/api_user","classpath:db/env/demo"]
apiSvcRolePassword="password you want for api_user"
apiSvcPgPassword- the password you have the Raido database when creating the docker container
apiSvcExtraLocation- can be used to load "conditional" schema files
for a given environment. The above will make sure your local DB has the same
SQL executed as the
demoenvironment.
- can be used to load "conditional" schema files
for a given environment. The above will make sure your local DB has the same
SQL executed as the
apiSvcRolePassword- is passed to a flyway placeholder, so that the migration scripts can set
the password for the
api_userrole. This password must be same as used by the api-svc, the spring/readme.md discusses setting up the config for the api-svc.
- is passed to a flyway placeholder, so that the migration scripts can set
the password for the
flywayCleanDisabled- set this to false if you need to run the
flywayCleantask
- set this to false if you need to run the