-
Notifications
You must be signed in to change notification settings - Fork 47
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
fix: keys migration (document deserialization error) #624
Conversation
8ae003b
to
7df6e30
Compare
7df6e30
to
5e50c15
Compare
Shouldn't it maybe only be executed on demand? |
it's executed only on data matching the criteria (in this case, jwk keyType having the jwk field as a string). what do you mean by demand? |
ee19728
to
bdcbb99
Compare
|
04f0a50
to
0b5f6ac
Compare
d84b1f0
to
7127add
Compare
b05fd41
to
207732d
Compare
207732d
to
c9b55e2
Compare
Quality Gate passedIssues Measures |
Migration system:
e.g.: (explicit types for reference, most not needed)
val migrations = listOf<() -> Unit>(
{ /* migration function code, or reference thereto */ }, // migration 1
{ /* migration function code, or reference thereto */ }, // migration 2
{ /* migration function code, or reference thereto */ }, // migration 3
{ /* migration function code, or reference thereto */ }, // migration 4
)
object Migrations : Table("migrations") {
val latestRunMigration = integer("latest_run_migration")
override val primaryKey: PrimaryKey = PrimaryKey(latestRunMigration)
}
val totalMigrations = migrations.size // list from above
// this function is called on startup, after the database is connected, but before the webserver handles connections (in `init = {` at ServiceInitialization)
fun runNeededMigrations() {
val lastRunMigration = getLatestRunMigration() // select on Migration table
if (totalMigrations > lastRunMigration) {
// additional migrations have to run
migrations.drop(latestMigration).forEachIndexed { index, migration -> // only run migrations that have not yet been run
// next migration
migration.invoke()
setLastestRunMigration(lastRunMigration + index + 1)
}
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above: Only run migrations when necessary
should we implement an in-house data migration tool? |
Description
Introduces keys migration to convert jwk keys documents to new format.
Fixes #625
Type of Change
New feature (non-breaking change which adds functionality)Breaking change (fix or feature that would cause existing functionality to not work as expected)This change requires a documentation updateChecklist
If it is a core feature, I have added thorough testsDo we need to implement analytics?Will this be part of a product update? If yes, please write one phrase about this update.I have commented my code, particularly in hard-to-understand areasI have made corresponding changes to the documentationI have added tests that prove my fix is effective or that my feature works