memos icon indicating copy to clipboard operation
memos copied to clipboard

Run migrations for fresh installs

Open RoccoSmit opened this issue 1 year ago • 4 comments

as per https://github.com/usememos/memos/issues/4060 the 00__reactions.sql migration for v0.23 does not run when you start with a fresh install

This PR covers 2 changes

Change 1: GetCurrentSchemaVersion get the current version (v0.23) and passes it into the migration logic. getSchemaVersionOfMigrateScript then increases the minor version so the schema version is v0.23.1 which does not match up with the schema set in the version.go file.

Change 2: For fresh installs the migrations logic does not currently run as the logic looks to see if schemaVersion > latestMigrationHistoryVersion but these 2 are set to be equal in the preMigrate logic if no previous migrations found which would be the case for fresh installs.

RoccoSmit avatar Nov 03 '24 12:11 RoccoSmit

Not sure what is causing checks to fail. Will revisit tomorrow

RoccoSmit avatar Nov 03 '24 13:11 RoccoSmit

@RoccoSmit Expectedly, the newly started instance should not execute any migrations. So I think what's needed here is to handle the default reactions value for memo setting.

Reference: https://github.com/usememos/memos/blob/main/store/workspace_setting.go#L157

boojack avatar Nov 03 '24 14:11 boojack

Makes sense. I wasn't sure if the LASTEST.sql files were for creating the initial db structure and the migrations were to add data to the tables.

If migrations are not run on the first install, would it make sense to add the insertion of the initial reactions to the LATEST.sql files? If not, I'll add 👍 as a default reaction value in workspace_setting.go if no value is set during save and load.

RoccoSmit avatar Nov 04 '24 11:11 RoccoSmit

I'll add 👍 as a default reaction value in workspace_setting.go if no value is set during save and load.

SGTM

boojack avatar Nov 04 '24 12:11 boojack