Skip to content

Commit

Permalink
chore: Make liquibase diffChangeLog task working again
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCizmar committed Dec 28, 2023
1 parent 87d6413 commit f07dd00
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backend/data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ apply from: "$rootDir/gradle/liquibase.gradle"
configureLiquibase("public", "hibernate:spring:io.tolgee", 'src/main/resources/db/changelog/schema.xml')

diff.dependsOn compileKotlin
diffChangeLog.dependsOn compileKotlin
diffChangelog.dependsOn compileKotlin

kotlin {
jvmToolchain(17)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.tolgee.model.activity

import io.hypersistence.utils.hibernate.type.json.JsonBinaryType
import io.tolgee.activity.data.EntityDescriptionRef
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.IdClass
Expand All @@ -26,9 +27,11 @@ class ActivityDescribingEntity(
val entityId: Long
) : Serializable {

@Column(columnDefinition = "jsonb")
@Type(JsonBinaryType::class)
var data: Map<String, Any?> = mutableMapOf()

@Type(JsonBinaryType::class)
@Column(columnDefinition = "jsonb")
var describingRelations: Map<String, EntityDescriptionRef>? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.hypersistence.utils.hibernate.type.json.JsonBinaryType
import io.tolgee.activity.data.EntityDescriptionRef
import io.tolgee.activity.data.PropertyModification
import io.tolgee.activity.data.RevisionType
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Enumerated
import jakarta.persistence.Id
Expand Down Expand Up @@ -39,19 +40,22 @@ class ActivityModifiedEntity(
/**
* Map of field to object containing old and new values
*/
@Column(columnDefinition = "jsonb")
@Type(JsonBinaryType::class)
var modifications: MutableMap<String, PropertyModification> = mutableMapOf()

/**
* Data, which are discribing the entity, but are not modified by the change
*/
@Column(columnDefinition = "jsonb")
@Type(JsonBinaryType::class)
var describingData: Map<String, Any?>? = null

/**
* Relations describing the entity.
* e.g. For translation, we would also need key and language data
*/
@Column(columnDefinition = "jsonb")
@Type(JsonBinaryType::class)
var describingRelations: Map<String, EntityDescriptionRef>? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ActivityRevision : java.io.Serializable {
*/
var authorId: Long? = null

@Column(columnDefinition = "jsonb")
@Type(JsonBinaryType::class)
var meta: MutableMap<String, Any?>? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.tolgee.model.Project
import io.tolgee.model.StandardAuditModel
import io.tolgee.model.UserAccount
import io.tolgee.model.activity.ActivityRevision
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.EnumType.STRING
import jakarta.persistence.Enumerated
Expand All @@ -27,6 +28,7 @@ class BatchJob : StandardAuditModel(), IBatchJob {
@ManyToOne(fetch = FetchType.LAZY)
var author: UserAccount? = null

@Column(columnDefinition = "jsonb")
@Type(JsonBinaryType::class)
var target: List<Any> = listOf()

Expand All @@ -45,6 +47,7 @@ class BatchJob : StandardAuditModel(), IBatchJob {
@OneToOne(mappedBy = "batchJob", fetch = FetchType.LAZY)
var activityRevision: ActivityRevision? = null

@Column(columnDefinition = "jsonb")
@Type(JsonBinaryType::class)
var params: Any? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class BatchJobChunkExecution : StandardAuditModel() {

var chunkNumber: Int = 0

@Column(columnDefinition = "jsonb")
@Type(JsonBinaryType::class)
var successTargets: List<Any> = listOf()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.tolgee.model.Project
import io.tolgee.model.StandardAuditModel
import io.tolgee.model.automations.AutomationAction
import io.tolgee.model.enums.TranslationState
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.FetchType
import jakarta.persistence.ManyToOne
Expand Down Expand Up @@ -37,25 +38,30 @@ class ContentDeliveryConfig(
var lastPublished: Date? = null

@Type(JsonBinaryType::class)
@Column(columnDefinition = "jsonb")
override var languages: Set<String>? = null

override var format: ExportFormat = ExportFormat.JSON
override var structureDelimiter: Char? = '.'

@Type(JsonBinaryType::class)
@Column(columnDefinition = "jsonb")
override var filterKeyId: List<Long>? = null

@Type(JsonBinaryType::class)
@Column(columnDefinition = "jsonb")
override var filterKeyIdNot: List<Long>? = null
override var filterTag: String? = null
override var filterKeyPrefix: String? = null

@Type(JsonBinaryType::class)
@Column(columnDefinition = "jsonb")
override var filterState: List<TranslationState>? = listOf(
TranslationState.TRANSLATED,
TranslationState.REVIEWED,
)

@Type(JsonBinaryType::class)
@Column(columnDefinition = "jsonb")
override var filterNamespace: List<String?>? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class KeyScreenshotReference {
lateinit var screenshot: Screenshot

@Type(JsonBinaryType::class)
@Column(columnDefinition = "jsonb")
var positions: MutableList<KeyInScreenshotPosition>? = mutableListOf()

@Column(columnDefinition = "text", length = 5000)
Expand Down
54 changes: 54 additions & 0 deletions backend/data/src/main/resources/db/changelog/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2968,4 +2968,58 @@
<column name="key1id"/>
</createIndex>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-5">
<addUniqueConstraint columnNames="batch_job_chunk_execution_id" constraintName="UC_ACTIVITY_REVISIONBATCH_JOB_CHUNK_EXECUTION_ID_COL" tableName="activity_revision"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-6">
<addUniqueConstraint columnNames="batch_job_id" constraintName="UC_ACTIVITY_REVISIONBATCH_JOB_ID_COL" tableName="activity_revision"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-7">
<addUniqueConstraint columnNames="target_language_id" constraintName="UC_AUTO_TRANSLATION_CONFIGTARGET_LANGUAGE_ID_COL" tableName="auto_translation_config"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-8">
<addUniqueConstraint columnNames="conflict_id" constraintName="UC_IMPORT_TRANSLATIONCONFLICT_ID_COL" tableName="import_translation"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-9">
<addUniqueConstraint columnNames="import_key_id" constraintName="UC_KEY_METAIMPORT_KEY_ID_COL" tableName="key_meta"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-10">
<addUniqueConstraint columnNames="key_id" constraintName="UC_KEY_METAKEY_ID_COL" tableName="key_meta"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-11">
<addUniqueConstraint columnNames="user_account_id" constraintName="UC_MT_CREDIT_BUCKETUSER_ACCOUNT_ID_COL" tableName="mt_credit_bucket"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-12">
<addUniqueConstraint columnNames="target_language_id" constraintName="UC_MT_SERVICE_CONFIGTARGET_LANGUAGE_ID_COL" tableName="mt_service_config"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-13">
<addUniqueConstraint columnNames="invitation_id" constraintName="UC_ORGANIZATION_ROLEINVITATION_ID_COL" tableName="organization_role"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-14">
<addUniqueConstraint columnNames="invitation_id" constraintName="UC_PERMISSIONINVITATION_ID_COL" tableName="permission"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-15">
<addUniqueConstraint columnNames="organization_id" constraintName="UC_PERMISSIONORGANIZATION_ID_COL" tableName="permission"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-16">
<addUniqueConstraint columnNames="base_language_id" constraintName="UC_PROJECTBASE_LANGUAGE_ID_COL" tableName="project"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-17">
<addUniqueConstraint columnNames="author_id, project_id" constraintName="UKgf336yxrmsyau8skvim42lkuj" tableName="import"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-18">
<dropColumn columnName="revision_type" tableName="activity_describing_entity"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-1">
<modifyDataType columnName="avatar_hash" newDataType="varchar(255)" tableName="organization"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-2">
<modifyDataType columnName="avatar_hash" newDataType="varchar(255)" tableName="project"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-3">
<modifyDataType columnName="avatar_hash" newDataType="varchar(255)" tableName="user_account"/>
</changeSet>
<changeSet author="jenik (generated)" id="1703766932501-4">
<modifyDataType columnName="structure_delimiter" newDataType="char(255)" tableName="content_delivery_config"/>
</changeSet>
</databaseChangeLog>
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ project(':server-app').afterEvaluate {
task startDbChangelogContainer {
doLast {
exec {
commandLine "docker", "run", "-e", "POSTGRES_PASSWORD=postgres", "-d", "-p55432:5432", "--name", dbSchemaContainerName, "postgres:13"
commandLine "docker", "run", "-e", "POSTGRES_PASSWORD=postgres", "-d", "-p55438:5432", "--name", dbSchemaContainerName, "postgres:13"
}
Thread.sleep(5000)
}
}

task stopDbChangelogContainer(type: Exec) {
commandLine "docker", "rm", "--force", dbSchemaContainerName
mustRunAfter project(':data').tasks.findByName("diffChangeLog")
mustRunAfter project(':ee-app').tasks.findByName("diffChangeLog")
mustRunAfter project(':data').tasks.findByName("diffChangelog")
mustRunAfter project(':ee-app').tasks.findByName("diffChangelog")
}

task diffChangeLog {
Expand All @@ -126,7 +126,7 @@ project(':server-app').afterEvaluate {
finalizedBy = [
startDbChangelogContainer,
project(':server-app').tasks.findByName("bootRun"),
project(':data').tasks.findByName("diffChangeLog"),
project(':data').tasks.findByName("diffChangelog"),
]

def billingDiffChangelog = project(':billing-app').tasks.findByName("diffChangeLog")
Expand Down
2 changes: 1 addition & 1 deletion ee/backend/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ apply from: "$rootDir/gradle/liquibase.gradle"
configureLiquibase("ee", "hibernate:spring:io.tolgee.ee.model", 'src/main/resources/db/changelog/ee-schema.xml')

diff.dependsOn compileKotlin
diffChangeLog.dependsOn compileKotlin
diffChangelog.dependsOn compileKotlin

dependencies {
implementation("org.springframework.boot:spring-boot-starter")
Expand Down
2 changes: 1 addition & 1 deletion gradle/liquibase.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ext {
activities {
//noinspection GroovyAssignabilityCheck
main {
changeLogFile changeLogPah
changeLogFile "${project.projectDir}/${changeLogPah}"
url liveDb.url
referenceUrl liveDb.referenceUrl
username liveDb.username
Expand Down
8 changes: 4 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {
}

if (requested.id.id == 'org.liquibase.gradle') {
useModule('org.liquibase.gradle:org.liquibase.gradle.gradle.plugin:2.1.1')
useModule('org.liquibase.gradle:org.liquibase.gradle.gradle.plugin:2.2.1')
}
if (requested.id.id == 'org.hibernate.orm') {
useVersion(hibernateVersion)
Expand Down Expand Up @@ -58,10 +58,10 @@ dependencyResolutionManagement {
library('amazonSTS', "software.amazon.awssdk:sts:$amazonAwsSdkVersion")
library('amazonTranslate', "software.amazon.awssdk:translate:$amazonAwsSdkVersion")
library('googleCloud', "com.google.cloud:libraries-bom:24.0.0")
library('liquibaseCore', "org.liquibase:liquibase-core:4.25.0")
library('liquibaseHibernate', "org.liquibase.ext:liquibase-hibernate6:4.25.0")
library('liquibaseCore', "org.liquibase:liquibase-core:4.25.1")
library('liquibaseHibernate', "org.liquibase.ext:liquibase-hibernate6:4.25.1")
library('liquibasePicoli', "info.picocli:picocli:4.6.3")
library('hibernateTypes', "io.hypersistence:hypersistence-utils-hibernate-62:3.6.0")
library('hibernateTypes', "io.hypersistence:hypersistence-utils-hibernate-63:3.7.0")
library('redissonSpringBootStarter', "org.redisson:redisson-spring-boot-starter:3.23.2")
library('redissonSpringData', 'org.redisson:redisson-spring-data-27:3.23.2')
library('postHog', 'com.posthog.java:posthog:1.1.0')
Expand Down

0 comments on commit f07dd00

Please sign in to comment.