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

Idea: Should be able to have multiple migrations within a single file or snapshots? #40

Open
JAForbes opened this issue May 4, 2024 · 0 comments

Comments

@JAForbes
Copy link
Owner

JAForbes commented May 4, 2024

For bulk data loads you can't know the migration will have time to complete in CI. So it could be nice to break up data updates by date ranges or pages. But if it fails or doesn't finish the complete change, you wouldn't want to restart the entire paging process again.

So it would be nice to be able to define an atomic migration programmatically. So you could generate migrations in file and then you've got a kind of checkpoint for the data load.

for( let date of date range ) {
  pgmg.migrate('big data load ' + date, {
  
    async action(sql){ 
      await sql`update ... where date is between ${date} and ${...}` 
    }
  })
}

If you have that API, you need to run the file to discover what migrations exist. And the number of migrations could be dynamic. E.g. the name there could change if the data in prod shifts dates, which means a prior migration that we considered "done" may suddenly re-run and crash.

Should we instead still have a concept of a migration being done, but introduce an idea of snapshots within a migration hook. So if the hook restarts on a second attempt, the snapshots can resume, but if the hook is marked as complete, we don't enter it to eval the snapshots to run.

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

No branches or pull requests

1 participant