Page MenuHomePhabricator

[keyserver] Initialize MySQL databases with the latest migration version
ClosedPublic

Authored by ashoat on May 30 2022, 2:05 PM.
Tags
None
Referenced Files
F3492185: D4155.diff
Wed, Dec 18, 10:27 PM
Unknown Object (File)
Tue, Dec 17, 7:57 AM
Unknown Object (File)
Tue, Dec 17, 7:57 AM
Unknown Object (File)
Tue, Dec 17, 7:57 AM
Unknown Object (File)
Tue, Dec 17, 7:57 AM
Unknown Object (File)
Tue, Dec 17, 7:55 AM
Unknown Object (File)
Tue, Dec 17, 6:57 AM
Unknown Object (File)
Mon, Dec 16, 7:46 AM

Details

Summary

Right now, new databases initialized with setupDB will start with no db_version in the metadata table, which corresponds to a value of -1.

This forces the migrate() code to run every single migration for the new database.

Instead, I think we should assume that setupDB is updated for any schema changes. That requires us to land changes to setupDB at the same time as introducing migrations. We should keep this requirement in mind, but I think we have stuck with it in the past.

Depends on D4154

Test Plan

Create a keyserver/.env file, eg.:

COMM_MYSQL_DATABASE=commdev
COMM_MYSQL_USER=commdev
COMM_MYSQL_PASSWORD=pass

And then run the Docker image: cd keyserver && docker-compose down -v && docker-compose up --build

Before this diff, you should see console logs indicating the migrations are being run. After this diff, no migrations are run, and the database is initialized with a version of 2 (latest migration value)

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

This revision is now accepted and ready to land.May 31 2022, 5:20 AM
atul added inline comments.
keyserver/src/database/setup-db.js
21

The table name in the MySQL db is metadata... is there a reason we shouldn't mirror that and name this function setUpMetadataTable?

keyserver/src/database/setup-db.js
21

Good catch. I initially thought the table was named meta, realized that was wrong later and went back to rename things... but definitely missed this

This revision was landed with ongoing or failed builds.May 31 2022, 5:50 AM
This revision was automatically updated to reflect the committed changes.