Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: delete the bb.issue.general issue related (#7913)

h3n4l53623f3de3e4
diff --git a/backend/migrator/migration/prod/2.7/0005##delete_general_issue_related.sql b/backend/migrator/migration/prod/2.7/0005##delete_general_issue_related.sql
new file mode 100644
index 0000000000..40acf02c88
--- /dev/null
+++ b/backend/migrator/migration/prod/2.7/0005##delete_general_issue_related.sql
@@ -0,0 +1,50 @@
+-- task_run
+DELETE FROM
+ task_run
+WHERE
+ task_run.task_id IN (
+ SELECT
+ DISTINCT(task.id)
+ FROM
+ task
+ WHERE
+ type = 'bb.task.general'
+ );
+
+-- task
+DELETE FROM
+ task
+WHERE
+ type = 'bb.task.general';
+
+-- stage
+DELETE FROM
+ stage
+WHERE
+ stage.pipeline_id IN (
+ SELECT
+ DISTINCT(pipeline.id)
+ FROM
+ pipeline
+ JOIN issue ON issue.pipeline_id = pipeline.id
+ AND issue.type = 'bb.issue.general'
+ );
+
+-- issue
+DELETE FROM
+ issue
+WHERE
+ issue.type = 'bb.issue.general';
+
+-- pipeline
+DELETE FROM
+ pipeline
+WHERE
+ (
+ SELECT
+ COUNT(1)
+ FROM
+ stage
+ where
+ stage.pipeline_id = pipeline.id
+ ) = 0;
\ No newline at end of file
diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index ddfa286f37..bf1862695e 100644
--- a/backend/migrator/migrator_test.go
+++ b/backend/migrator/migrator_test.go
@@ -241,5 +241,5 @@ func TestMigrationCompatibility(t *testing.T) {
func TestGetCutoffVersion(t *testing.T) {
releaseVersion, err := getProdCutoffVersion()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("2.7.4"), releaseVersion)
+ require.Equal(t, semver.MustParse("2.7.5"), releaseVersion)
}