Skip to content

Commit 42b39c1

Browse files
committed
Add SQLDelight migration utilities
1 parent 9951f4f commit 42b39c1

File tree

1 file changed

+20
-0
lines changed
  • libpretixsync/src/main/java/eu/pretix/libpretixsync/sqldelight

1 file changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package eu.pretix.libpretixsync.sqldelight
2+
3+
import app.cash.sqldelight.db.AfterVersion
4+
5+
object Migrations {
6+
/**
7+
* Lowest schema version that we can still migrate from
8+
*/
9+
const val minSupportedVersion = 91L
10+
11+
/**
12+
* AfterVersion callback that can be used in SQLDelight code migrations to crash if we encounter
13+
* a schema version that we have no migrations for.
14+
* Without it, SQLDelight might just increase the DB version without actually creating the
15+
* correct schema.
16+
*/
17+
val minVersionCallback = AfterVersion(minSupportedVersion - 1L) { _ ->
18+
throw IllegalStateException("Unsupported database version. Minimum supported version is $minSupportedVersion")
19+
}
20+
}

0 commit comments

Comments
 (0)