Skip to content
Open
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 @@ -10,6 +10,7 @@ import io.tolgee.batch.data.BatchJobType
import io.tolgee.batch.request.DeleteKeysRequest
import io.tolgee.development.testDataBuilder.data.BaseTestData
import io.tolgee.development.testDataBuilder.data.BatchJobsTestData
import io.tolgee.development.testDataBuilder.data.ContentDeliveryConfigBranchingTestData
import io.tolgee.development.testDataBuilder.data.ContentDeliveryConfigTestData
import io.tolgee.development.testDataBuilder.data.MtSettingsTestData
import io.tolgee.development.testDataBuilder.data.ProjectWithQaEntitiesTestData
Expand Down Expand Up @@ -133,6 +134,19 @@ class ProjectHardDeletingServiceTest : AbstractSpringTest() {
}
}

@Test
fun `deletes project with content delivery configs on branches`() {
val testData = ContentDeliveryConfigBranchingTestData()
testDataService.saveTestData(testData.root)
Comment thread
bdshadow marked this conversation as resolved.
executeInNewRepeatableTransaction(platformTransactionManager) {
projectHardDeletingService.hardDeleteProject(testData.projectBuilder.self.refresh())
}

executeInNewTransaction {
projectService.find(testData.projectBuilder.self.id).assert.isNull()
}
}

@Test
fun `deletes project with webhooks`() {
val testData = WebhooksTestData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ class ProjectHardDeletingService(
entityManager.clear()

bigMetaService.deleteAllByProjectId(projectId)
branchService.deleteAllByProjectId(projectId)
projectQaConfigRepository.deleteAllByProjectId(projectId)

// Flush and clear the persistence context to ensure deletions are synchronized
Expand Down Expand Up @@ -183,6 +182,13 @@ class ProjectHardDeletingService(
.setParameter("projectId", projectId)
.executeUpdate()

// Branches are referenced by content_delivery_config.branch_id, so they must be
// deleted only after the content delivery configs above are gone. deleteAllByProjectId
// removes the entities via the persistence context, so flush to push the DELETEs to the
// DB before the project row is deleted (branch.project_id references project).
branchService.deleteAllByProjectId(projectId)
entityManager.flush()
Comment thread
bdshadow marked this conversation as resolved.

// Delete ContentStorage children first
entityManager
.createQuery("DELETE FROM AzureContentStorageConfig a WHERE a.contentStorage.project.id = :projectId")
Expand Down
Loading