Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add a flag to ignore schema definitions during migration checks #3203

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

Merged
merged 1 commit into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ abstract class VerifyMigrationTask : SqlDelightWorkerTask() {

@Input var verifyMigrations: Boolean = false

@Input var verifyDefinitions: Boolean = true

/* Tasks without an output are never considered UP-TO-DATE by Gradle. Adding an output file that's created when the
* task completes successfully works around the lack of an output for this task. There may be a better solution once
* https://github.com/gradle/gradle/issues/14223 is resolved. */
Expand All @@ -62,6 +64,7 @@ abstract class VerifyMigrationTask : SqlDelightWorkerTask() {
it.properties.set(properties)
it.verifyMigrations.set(verifyMigrations)
it.compilationUnit.set(compilationUnit)
it.verifyDefinitions.set(verifyDefinitions)
}
workQueue.await()
}.onSuccess {
Expand All @@ -85,6 +88,7 @@ abstract class VerifyMigrationTask : SqlDelightWorkerTask() {
val properties: Property<SqlDelightDatabaseProperties>
val compilationUnit: Property<SqlDelightCompilationUnit>
val verifyMigrations: Property<Boolean>
val verifyDefinitions: Property<Boolean>
}

abstract class VerifyMigrationAction : WorkAction<VerifyMigrationWorkParameters> {
Expand Down Expand Up @@ -141,6 +145,7 @@ abstract class VerifyMigrationTask : SqlDelightWorkerTask() {
private fun checkMigration(dbFile: File, currentDb: CatalogDatabase) {
val actualCatalog = createActualDb(dbFile)
val databaseComparator = ObjectDifferDatabaseComparator(
ignoreDefinitions = !parameters.verifyDefinitions.get(),
circularReferenceExceptionLogger = {
logger.debug(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import de.danielbechler.diff.node.DiffNode.State.REMOVED
import de.danielbechler.diff.node.DiffNode.State.UNTOUCHED

class ObjectDifferDatabaseComparator(
private val ignoreDefinitions: Boolean,
private val circularReferenceExceptionLogger: ((String) -> Unit)? = null
) : DatabaseComparator<CatalogDatabase> {

Expand All @@ -30,6 +31,8 @@ class ObjectDifferDatabaseComparator(
propertyName("importedForeignKeys")
propertyName("deferrable")
propertyName("initiallyDeferred")

if (ignoreDefinitions) propertyName("definition")
}
// Partial columns are used for unresolved columns to avoid cycles. Matching based on string
// is fine for our purposes.
Expand Down