generated from cloudoperators/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
services: | ||
maintenance: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
container_name: heureka_maintenance | ||
environment: | ||
DB_HOST: host.docker.internal | ||
DB_NAME: ${DB_NAME} | ||
DB_USER: ${DB_USER} | ||
DB_PASSWORD: ${DB_PASSWORD} | ||
volumes: | ||
- ./scripts:/scripts |
Empty file.
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,46 @@ | ||
-- Maintenance script for database truncation | ||
-- Enable logging | ||
SET @start_time = NOW(); | ||
SELECT CONCAT('Starting maintenance at ', @start_time) AS log_message; | ||
|
||
-- Start transaction | ||
START TRANSACTION; | ||
|
||
-- Disable foreign key checks temporarily | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
|
||
-- Truncate junction join tables first | ||
TRUNCATE TABLE IssueMatchEvidence; | ||
TRUNCATE TABLE ComponentVersionIssue; | ||
TRUNCATE TABLE IssueRepositoryService; | ||
TRUNCATE TABLE ActivityHasIssue; | ||
TRUNCATE TABLE ActivityHasService; | ||
TRUNCATE TABLE IssueMatchChange; | ||
TRUNCATE TABLE SupportGroupService; | ||
TRUNCATE TABLE SupportGroupUser; | ||
TRUNCATE TABLE Owner; | ||
|
||
-- Truncate dependent entity tables | ||
TRUNCATE TABLE IssueMatch; | ||
TRUNCATE TABLE Evidence; | ||
TRUNCATE TABLE ComponentInstance; | ||
TRUNCATE TABLE IssueVariant; | ||
TRUNCATE TABLE ComponentVersion; | ||
TRUNCATE TABLE Activity; | ||
|
||
-- Truncate main entity tables | ||
TRUNCATE TABLE Component; | ||
TRUNCATE TABLE Service; | ||
TRUNCATE TABLE SupportGroup; | ||
TRUNCATE TABLE Issue; | ||
TRUNCATE TABLE IssueRepository; | ||
|
||
-- Re-enable foreign key checks | ||
SET FOREIGN_KEY_CHECKS = 1; | ||
|
||
-- Log completion | ||
SELECT CONCAT('Maintenance completed at ', NOW(), '. Duration: ', | ||
TIMESTAMPDIFF(SECOND, @start_time, NOW()), ' seconds') AS log_message; | ||
|
||
-- Commit transaction | ||
COMMIT; |