Skip to content

Add option to execute code before a migration #5728

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

neilgmiller
Copy link

Adds a new interface MigrationCallback which replaces AfterVersion as the callback vararg type for migrations. It is defined as follows:

interface MigrationCallback {
  val version: Long
  fun beforeMigration(driver: SqlDriver) {}
  fun afterMigration(driver: SqlDriver) {}
}

AfterVersion is updated to implement this interface, and remains fully backwards compatible. In addition a matching class BeforeVersion is added for ease of use.

@neilgmiller
Copy link
Author

A couple notes:

  • there were 6 failed tests on the branch master, the same 6 also failed after my changes
  • existing generated code for migration doesn't check for duplicate versions in the list of callback, I can add that if desired, as this change does make that case more likely. I would like some guidance on whether "run all" or "fail" would be preferred in the case of duplicates, if that's the case.

@JakeWharton
Copy link
Collaborator

This is an ABI-incompatible change that can only be made as part of 3.0. If you'd like to open an issue we can discuss potential compatible mechanisms of introducing this.

@neilgmiller
Copy link
Author

Ah, I hadn't considered ABI compatibility. I've opened an issue: #5729

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

Successfully merging this pull request may close these issues.

2 participants