-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge the Databases #1372
Merge the Databases #1372
Conversation
f21e1a8
to
baf77c7
Compare
Thanks @Mythicaeda - the instructions above note that you need to "Update your .env" before testing. Can you write up a bit more detail on which variables have been renamed/added that need to be populated? I can probably figure it out from the code but we'll want to add this to the upgrade guide when we release. |
I've updated the PR Description. Let me know if there's any areas that need more clarification! |
71d22a4
to
0be4989
Compare
0be4989
to
454c078
Compare
- Update databases.yaml - Reorder contents of schema-level tables.yamls to better resemble schema-level init.sqls
- Track `preset_to_snapshot_directive` - Translate manual configurations to use fkeys where possible - Update remote relationships to non-remote relationships - Fixed array relationship `expansion_sets` on `expansion_set_to_rule` that should be an object relationship (BREAKING CHANGE)
Adds fkeys that were previously unexpressable due to the tables being in separate DBs Adds a trigger to create a Scheduling Spec when a plan is created (this is breaking for the UI)
Adds fkeys that were previously unexpressable due to the tables being in separate DBs
Adds fkeys that were previously unexpressable due to the tables being in separate DBs Additionally refines the comment on `expansion_rule.activity_type`
- Update `deallocate` to remove unneeded reference to the Spec ID and to properly pass analysisID instead of spec revision
…st_status [Hasura is currently unable to properly use custom types not in the public schema] (hasura/graphql-engine#4630). While this can be partially circumvented by specifying a search_path in the connection string (see change to Docker Compose), because these two types share a name, Hasura would always match to the type specified in the first listed schema in the search path. Because these types are identical sans the originating DB, they were combined into a singular type, `request_status`, rather than renaming each one.
- Add schema info and language tags to SQL statements - Suppress `SqlSourceToSinkFlow` warnings, which are not significant since this is test code - Extract duplicate SQL code into methods - Close the connection and datasource when stopping DB in `DatabaseTestHelper`. Method renamed to `close` to reflect this. - Create helper method `DBTestHelper::clearSchema` to simplify test cleanup code - Move `PlanCollaborationTests::UpdateActivityName` and `DeleteActivityDirective` to `MerlinDBTestHelper` - Wrap created statements in "try-with-resources" - Fix Plan Collaboration Test `mergeBaseBetweenSelf`, which wasn't calling `get_merge_base` before
- Replace inserting a scheduling spec with fetching the automatically generated one's id
Update DB Envvars
- Remove outdated explanations - Take v2.8.0 as base - Exclude the HDB_Catalog schema from throwing comparison failures, as this schema is controlled by Hasura
Done in case the database has any rows that would violate the foreign key about to be added.
cf71ef0
to
3a285c9
Compare
Description
Breaking Changes:
This PR goes through all of our databases and combine them into a single
aerie
database. This change involved:set new.revision = old.revision +1
) into functions in theutil_functions
schema.Verification
This PR will not pass the E2E Test Workflow. The Gateway code needed to be updated as well, and this change was breaking. The
develop
Gateway that the e2eTest workflow uses is unable to upload files to this backend.This PR will not pass the DB Migration Check Workflow. That workflow has been updated to work with future migrations once this PR has been released (note: if this PR is merged post-2.8.0, the Workflow will need to be updated). Instead, the migration was tested as follows:
brew install libpq
..env
).mkdir -p mergeDmp migrationDmp
develop
. (I recommend running./gradlew clean
afterwards to get rid of the copied SQL files)Documentation
to migrate thedevelop
DB to the merged DBDatabase comparison succeeded
This process was run both on a "raw" database and on one that had simulation datasets on it, since datasets are the only part of the DB using partition tables and
execute
statements.Other Test changes:
HDB_Catalog
schema. This schema was already effectively excluded via our "expected mismatch" file, but testing revealed that this schema is officially controlled exclusively via Hasura, meaning we shouldn't be migrating it or concerned with changes Hasura makes to it.SqlSourceToSinkFlow
warnings, which are not significant since this is test codeMerlinDBTestHelper
classDBTestHelper
now closes the connection and datasource when shutting down, no longer needs init File passed it on startup, and has gained a helper methodclearSchema
Documentation
The migration script guide in our docs needs to be updated.
How to run this migration needs to be included in our upgrade docs:
Prerequisites:
aerie_merlin
,aerie_scheduler
,aerie_sequencing
,aerie_ui
), you must rename them to the default names..env
anddocker-compose.yaml
using the provided files indeployment
. Specifically, the following envvars have been added to the.env
:and the containers enviornment variables have been updated as follows:
POSTGRES_AERIE_MERLIN_DB
POSTGRES_USER
POSTGRES_PASSWORD
POSTGRES_HOST
->AERIE_DB_HOST
POSTGRES_PORT
->AERIE_DB_PORT
GATEWAY_DB_USER: "${GATEWAY_USERNAME}"
GATEWAY_DB_PASSWORD: "${GATEWAY_PASSWORD}"
MERLIN_DB
MERLIN_DB_SERVER
->AERIE_DB_HOST
MERLIN_DB_PORT
->AERIE_DB_PORT
MERLIN_DB_USER
should now be mapped at the envvar"${MERLIN_USERNAME}"
MERLIN_DB_PASSWORD
should now be mapped at the envvar"${MERLIN_PASSWORD}"
MERLIN_WORKER_DB
MERLIN_WORKER_DB_USER
MERLIN_WORKER_DB_PASSWORD
MERLIN_WORKER_DB_SERVER
->AERIE_DB_HOST
MERLIN_WORKER_DB_PORT
->AERIE_DB_PORT
MERLIN_DB_USER: "${MERLIN_USERNAME}"
MERLIN_DB_PASSWORD: "${MERLIN_PASSWORD}"
SCHEDULER_DB
SCHEDULER_DB_SERVER
->AERIE_DB_HOST
SCHEDULER_DB_PORT
->AERIE_DB_PORT
SCHEDULER_DB_USER
should now be mapped at the envvar"${SCHEDULER_USERNAME}"
SCHEDULER_DB_PASSWORD
should now be mapped at the envvar"${SCHEDULER_PASSWORD}"
SCHEDULER_WORKER_DB
SCHEDULER_WORKER_DB_USER
SCHEDULER_WORKER_DB_PASSWORD
SCHEDULER_WORKER_DB_SERVER
->AERIE_DB_HOST
SCHEDULER_WORKER_DB_PORT
->AERIE_DB_PORT
SCHEDULER_DB_USER: "${SCHEDULER_USERNAME}"
SCHEDULER_DB_PASSWORD: "${SCHEDULER_PASSWORD}"
SEQUENCING_DB
SEQUENCING_DB_SERVER
->AERIE_DB_HOST
SEQUENCING_DB_PORT
->AERIE_DB_PORT
SEQUENCING_DB_USER
should now be mapped at the envvar"${SEQUENCING_USERNAME}"
SEQUENCING_DB_PASSWORD
should now be mapped at the envvar"${SEQUENCING_PASSWORD}"
AERIE_MERLIN_DATABASE_URL
AERIE_SCHEDULER_DATABASE_URL
AERIE_SEQUENCING_DATABASE_URL
AERIE_UI_DATABASE_URL
AERIE_DATABASE_URL: "postgres://${AERIE_USERNAME}:${AERIE_PASSWORD}@postgres:5432/aerie?options=-c%20search_path%3Dutil_functions%2Chasura%2Cpermissions%2Ctags%2Cmerlin%2Cscheduler%2Csequencing%2Cpublic"
GATEWAY_DB_USER: "${GATEWAY_USERNAME}"
GATEWAY_DB_PASSWORD: "${GATEWAY_PASSWORD}"
MERLIN_DB_USER: "${MERLIN_USERNAME}"
MERLIN_DB_PASSWORD: "${MERLIN_PASSWORD}"
SCHEDULER_DB_USER: "${SCHEDULER_USERNAME}"
SCHEDULER_DB_PASSWORD: "${SCHEDULER_PASSWORD}"
SEQUENCING_DB_USER: "${SEQUENCING_USERNAME}"
SEQUENCING_DB_PASSWORD: "${SEQUENCING_PASSWORD}"
Migration:
merge_aerie_db
directory, executemerge_db.sh
. Usage is below. If you would like to drop the old DBs as part of the task, ensure the non-postgres containers are not running.If you encounter any errors while running
merge_db.sh
, it is safe drop theaerie
database and restart the migration. If you ran the migration with the-d
flag and encountered the error during theDropping old Databases
command, however, the migration was successful and that step can be reattempted by itself using thedrop_old_dbs.sh
script. See below for usage.If you did not run the migration step with the
-d
flag, you can drop the old databases using thedrop_old_dbs.sh
script. Usage is below:Drop the pre-v2.8.0 unmerged Aerie Databases usage: drop_old_dbs.sh [-h] [-e ENV_PATH] [-n NETWORK_LOCATION] options: -h print this message and exit -e path to the .env file used to deploy v2.8.0 Aerie. defaults to ../.env -n network location of the database. defaults to localhost
Future work
merlin
-exclusive part of the DB that can be pulled out of theMerlinDBHelper
.security definer
vssecurity invoker
permissions.