Skip to content

Conversation

grgbkr
Copy link
Contributor

@grgbkr grgbkr commented May 18, 2023

Update AuthDO schema migration logic to deal with down-migrates (i.e. dealing with rolling back a deploy that does a migration).

Also address arv's feedback from #491

@vercel
Copy link

vercel bot commented May 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
replicache-docs-trunk ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 19, 2023 0:53am

@grgbkr grgbkr requested a review from arv May 18, 2023 21:09
@grgbkr grgbkr changed the title WIP AuthDO schema migration refinements AuthDO schema migration refinements May 18, 2023
@grgbkr grgbkr marked this pull request as ready for review May 18, 2023 21:15
storage,
lc,
storageSchemaMeta,
STORAGE_SCHEMA_VERSION,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I see now.

In that case, I think it would be safer to specify the actual version number in these calls (i.e. 1 instead of STORAGE_SCHEMA_VERSION), so that when subsequent migration steps steps are added, the previous steps don't need to be changed.

Then we would add a check in migrate...() that the version <= STORAGE_SCHEMA_VERSION.

wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion. Done.

@grgbkr grgbkr force-pushed the grgbkr/auth-do-migrate-follow-up branch from a92bf77 to 71c4c6b Compare May 19, 2023 00:52
@grgbkr grgbkr merged commit 85a30e0 into main May 19, 2023
@grgbkr grgbkr deleted the grgbkr/auth-do-migrate-follow-up branch May 19, 2023 00:57
Copy link
Contributor

@arv arv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

this._initRoutes();
this._lc.info?.('Starting server');
this._lc.info?.('Version:', version);
void state.blockConcurrencyWhile(() =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.catch would be better and log the error if any.

minSafeRollbackVersion: number;
};

async function migrateStorageSchemaToVersion(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to move this to another file? This file is getting large.

(await storage.get(AUTH_DO_STORAGE_SCHEMA_VERSION_KEY)) ?? 0;
if (storageSchemaVersion >= AUTH_DO_STORAGE_SCHEMA_VERSION) {
return;
lc.addContext('SchemaUpdate');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lc = lc.addContext

storage,
CONNECTION_KEY_PREFIX,
)) {
await storage.delete(connectionKeyString);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth using multi delete here and below?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants