sui icon indicating copy to clipboard operation
sui copied to clipboard

[events][fullnode] EventStore: Detect need for migrations and run them

Open velvia opened this issue 1 year ago • 0 comments

Steps to Reproduce Issue

If a change to the SQLIte events table schema is made, and a Fullnode restarts without wiping the disk, then we get errors like:

fullnode-fullnode-1  | Error: Non-RocksDB Storage error: error returned from database: (code: 1) no such column: object_type
fullnode-fullnode-1 exited with code 1

This is because the existing table does not have the new entry.

Expected Result

Fullnode should detect that there was a schema change. Ideally it should run some migration, or that can be part of the deploy process and we can expect the schema to match, and fail startup as a result.

Notes

https://david.rothlis.net/declarative-schema-migration-for-sqlite/

sqlx library seems to have some built-in support for migrations: https://docs.rs/sqlx/latest/sqlx/macro.migrate.html

velvia avatar Nov 02 '22 18:11 velvia