This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 7165b5bf3 fix(plugins): fix raw table schemas and cleanup legacy table
structures in testmo (#8566)
7165b5bf3 is described below
commit 7165b5bf31a75b748075121f0b0d9352a0a540d9
Author: Richard Boisvert <[email protected]>
AuthorDate: Sun Sep 7 23:27:18 2025 -0400
fix(plugins): fix raw table schemas and cleanup legacy table structures in
testmo (#8566)
When using a new database, there were issues with the testmo plugin. This
fixes pipeline issues by ensuring proper raw table naming conventions and
schema consistency for testmo data import.
---
.../20250905_fix_raw_table_names_and_schemas.go | 69 ++++++++++++++++++++++
.../testmo/models/migrationscripts/archived/run.go | 7 ++-
.../testmo/models/migrationscripts/register.go | 1 +
3 files changed, 74 insertions(+), 3 deletions(-)
diff --git
a/backend/plugins/testmo/models/migrationscripts/20250905_fix_raw_table_names_and_schemas.go
b/backend/plugins/testmo/models/migrationscripts/20250905_fix_raw_table_names_and_schemas.go
new file mode 100644
index 000000000..9ade2d992
--- /dev/null
+++
b/backend/plugins/testmo/models/migrationscripts/20250905_fix_raw_table_names_and_schemas.go
@@ -0,0 +1,69 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/dal"
+ "github.com/apache/incubator-devlake/core/errors"
+ "github.com/apache/incubator-devlake/core/plugin"
+)
+
+type fixRawTableNamesAndSchemas struct{}
+
+func (*fixRawTableNamesAndSchemas) Up(basicRes context.BasicRes) errors.Error {
+ db := basicRes.GetDal()
+
+ legacy := []string{
+ "testmo_projects",
+ "testmo_milestones",
+ "testmo_automation_runs",
+ "testmo_runs",
+ }
+ for _, tbl := range legacy {
+ if db.HasTable(tbl) {
+ if err := db.DropTables(tbl); err != nil {
+ return err
+ }
+ }
+ }
+
+ current := []string{
+ "_raw_testmo_projects",
+ "_raw_testmo_milestones",
+ "_raw_testmo_automation_runs",
+ "_raw_testmo_runs",
+ }
+ for _, tbl := range current {
+ if db.HasTable(tbl) {
+ err := db.All(&[]struct{}{}, dal.From(tbl),
dal.Where("_raw_data_table = '' AND 1 = 0"))
+ if err != nil {
+ if dropErr := db.DropTables(tbl); dropErr !=
nil {
+ return dropErr
+ }
+ }
+ }
+ }
+
+ return nil
+}
+
+func (*fixRawTableNamesAndSchemas) Version() uint64 { return 20250905000001 }
+func (*fixRawTableNamesAndSchemas) Name() string { return "Fix raw table
names and schemas" }
+
+var _ plugin.MigrationScript = (*fixRawTableNamesAndSchemas)(nil)
diff --git a/backend/plugins/testmo/models/migrationscripts/archived/run.go
b/backend/plugins/testmo/models/migrationscripts/archived/run.go
index db1cba3e6..3205b5dd6 100644
--- a/backend/plugins/testmo/models/migrationscripts/archived/run.go
+++ b/backend/plugins/testmo/models/migrationscripts/archived/run.go
@@ -19,6 +19,8 @@ package archived
import (
"time"
+
+ corearchived
"github.com/apache/incubator-devlake/core/models/migrationscripts/archived"
)
type TestmoRun struct {
@@ -40,9 +42,8 @@ type TestmoRun struct {
TestmoCreatedAt *time.Time `json:"created_at"`
TestmoUpdatedAt *time.Time `json:"updated_at"`
- // Inline definition of NoPKModel
- CreatedAt time.Time `json:"createdAt"`
- UpdatedAt time.Time `json:"updatedAt"`
+ // Include standard NoPKModel with RawDataOrigin columns
+ corearchived.NoPKModel
}
func (TestmoRun) TableName() string {
diff --git a/backend/plugins/testmo/models/migrationscripts/register.go
b/backend/plugins/testmo/models/migrationscripts/register.go
index 3ab9cc075..7843d4b84 100644
--- a/backend/plugins/testmo/models/migrationscripts/register.go
+++ b/backend/plugins/testmo/models/migrationscripts/register.go
@@ -24,5 +24,6 @@ func All() []plugin.MigrationScript {
new(addInitTables),
new(addScopeConfigIdToProjects),
new(replaceTestsWithRuns),
+ new(fixRawTableNamesAndSchemas),
}
}