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
F3249393: D4155.id13222.diff
Fri, Nov 15, 2:21 PM
Unknown Object (File)
Mon, Oct 28, 2:49 AM
Unknown Object (File)
Fri, Oct 25, 7:12 AM
Unknown Object (File)
Fri, Oct 25, 7:12 AM
Unknown Object (File)
Fri, Oct 25, 7:12 AM
Unknown Object (File)
Fri, Oct 25, 7:12 AM
Unknown Object (File)
Sat, Oct 19, 5:57 AM
Unknown Object (File)
Oct 5 2024, 1:13 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.