Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add process to track and run data migrations #382

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dav1do
Copy link
Contributor

@dav1do dav1do commented Jun 14, 2024

The upcoming changes to normalize some of event payload requires running a data migration a la nosql style. This provides tables to track the daemon version and the state of migrations. They can be run by calling the daemon with the --migrate-data flag. If there are required migrations, the daemon will fail to start.

Copy link

linear bot commented Jun 14, 2024

Copy link
Collaborator

@stbrody stbrody left a comment

Choose a reason for hiding this comment

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

lookin good!

one/src/lib.rs Outdated Show resolved Hide resolved
service/src/lib.rs Show resolved Hide resolved
pub async fn needs_migration(&self) -> Result<bool> {
let new_install = self.is_new_install().await?;

if new_install {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: this feels like a weird place for this logic to live. Seems like there should be an init method or something like that that is called once at startup that handles this, rather than bundling logic into this boolean accessor method.

That said this migration code is going to be fairly self-contained and mostly only run during startup anyway, so it probably doesn't matter that much.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, agreed. I changed it to happen at start up and refactored some things into functions.. sorry, I started with a one line change and then couldn't help myself.

Thinking about this made me realize that this should all be behind &mut and that ceramic one should probably expose a CeramicDataMigration service or something so the binary is completely unaware of all store crate things. I started making those changes and backed them out because that's something for another PR.

Base automatically changed from chore/stream-meta-prep to main June 14, 2024 19:34
@dav1do dav1do temporarily deployed to github-tests-2024 June 14, 2024 21:48 — with GitHub Actions Inactive
…hile running

- looks like more than it is. pulled some queries into the version struct and adjusted signatures accordingly (&self/&mut self/Self, removed async)
- made things more retry friendly. fixed previous version query to exclude the current version and not error if inserting migration as completed a second time
@dav1do dav1do force-pushed the feat/aes-130-data-migrations branch from 83a3068 to e46e101 Compare June 14, 2024 22:06
@dav1do dav1do temporarily deployed to github-tests-2024 June 14, 2024 22:15 — with GitHub Actions Inactive
@dav1do
Copy link
Contributor Author

dav1do commented Jun 17, 2024

So I realized the migrations to extract metadata isn't as urgent as I thought (I fixed IOD to not have bugs without it, and it might be more efficient tbh - will have the cleaned up PR today, still need to split it/make it easier to review). I do think we want to do it before GA, but I don't think I have the new table structures schema quite right, so it might make sense to pause this for a couple days. This doesn't really do much, and it doesn't hurt to merge this and store version info, but we may want to track started_at or other data (so we can see if you downgrade in history). And we may want to support running migrations in the background (slowly read events and extract metadata but maybe it's better to just rip through everything for now), which would mean the flag might not be quite right.

Anyway, @stbrody, curious to hear your thoughts/discuss briefly before you spend any more time on this (and I really appreciate how much you've already spent).

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.

2 participants