-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6 Persist a summary of each reconciliation run which can link all th…
…e rows together Allows running reconciliation for the same dataset multiple times
- Loading branch information
1 parent
8834a5e
commit 8100e91
Showing
5 changed files
with
95 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
src/main/kotlin/com/thoughtworks/recce/server/dataset/MigrationRecordRepository.kt
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
src/main/kotlin/com/thoughtworks/recce/server/dataset/MigrationRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.thoughtworks.recce.server.dataset | ||
|
||
import io.micronaut.data.annotation.DateCreated | ||
import io.micronaut.data.annotation.DateUpdated | ||
import io.micronaut.data.model.query.builder.sql.Dialect | ||
import io.micronaut.data.r2dbc.annotation.R2dbcRepository | ||
import io.micronaut.data.repository.reactive.ReactorCrudRepository | ||
import java.io.Serializable | ||
import java.time.LocalDateTime | ||
import javax.persistence.* | ||
|
||
@R2dbcRepository(dialect = Dialect.H2) | ||
interface MigrationRunRepository : ReactorCrudRepository<MigrationRun, Int> | ||
|
||
@R2dbcRepository(dialect = Dialect.H2) | ||
interface MigrationRecordRepository : ReactorCrudRepository<MigrationRecord, MigrationRecordKey> | ||
|
||
@Entity | ||
@Table(name = "data_set_migration_run") | ||
data class MigrationRun( | ||
@Id @GeneratedValue val id: Int?, | ||
val dataSetId: String, | ||
@DateCreated val createdTime: LocalDateTime?, | ||
) { | ||
@DateUpdated | ||
var updatedTime: LocalDateTime? = null | ||
var completedTime: LocalDateTime? = null | ||
|
||
constructor(dataSetId: String) : this(null, dataSetId, null) | ||
|
||
@Transient | ||
var results: DataSetResults? = null | ||
} | ||
|
||
data class DataSetResults(val sourceRowsInserted: Long) | ||
|
||
@Entity | ||
@Table(name = "data_set_migration_record") | ||
data class MigrationRecord( | ||
@EmbeddedId val id: MigrationRecordKey, | ||
var sourceData: String? = null, | ||
var targetData: String? = null | ||
) | ||
|
||
@Embeddable | ||
data class MigrationRecordKey( | ||
@Column(name = "migration_id") val migrationId: Int, | ||
@Column(name = "migration_key") val migrationKey: String | ||
) : Serializable |
14 changes: 12 additions & 2 deletions
14
src/main/resources/db/migration/V1__CREATE_MIGRATION_RECORD.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
CREATE TABLE data_set_migration_run | ||
( | ||
id SERIAL PRIMARY KEY, | ||
data_set_id VARCHAR(255) NOT NULL, | ||
created_time TIMESTAMP NOT NULL, | ||
updated_time TIMESTAMP NOT NULL, | ||
completed_time TIMESTAMP | ||
); | ||
|
||
CREATE TABLE data_set_migration_record | ||
( | ||
data_set_id VARCHAR(255) NOT NULL, | ||
migration_id INTEGER NOT NULL, | ||
migration_key VARCHAR(255) NOT NULL, | ||
source_data VARCHAR(1024), | ||
target_data VARCHAR(1024), | ||
PRIMARY KEY (data_set_id, migration_key) | ||
PRIMARY KEY (migration_id, migration_key), | ||
FOREIGN KEY (migration_id) REFERENCES data_set_migration_run (id) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters