Skip to content

Commit dcbc1b7

Browse files
committed
feat: simplify code
1 parent 3cd8c92 commit dcbc1b7

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

backend/plugins/dora/impl/impl.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ func (p Dora) RootPkgPath() string {
116116
}
117117

118118
func (p Dora) MigrationScripts() []plugin.MigrationScript {
119-
return []plugin.MigrationScript{
120-
migrationscripts.DoraMigrationScript,
121-
}
119+
return migrationscripts.All()
122120
}
123121

124122
func (p Dora) MakeMetricPluginPipelinePlanV200(projectName string, options json.RawMessage) (coreModels.PipelinePlan, errors.Error) {

backend/plugins/dora/models/migrationscripts/register.go

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,15 @@ limitations under the License.
1818
package migrationscripts
1919

2020
import (
21-
"github.com/apache/incubator-devlake/core/context"
22-
"github.com/apache/incubator-devlake/core/errors"
23-
"github.com/apache/incubator-devlake/plugins/dora/models"
21+
"github.com/apache/incubator-devlake/core/plugin"
2422
)
2523

26-
// Export the migration script for use in impl.go
27-
var DoraMigrationScript = &doraMigrationScript{}
28-
29-
type doraMigrationScript struct{}
30-
31-
func (script *doraMigrationScript) Up(basicRes context.BasicRes) errors.Error {
32-
// Just run the migration once - directly on the model
33-
db := basicRes.GetDal()
34-
err := db.AutoMigrate(&models.IssueLeadTimeMetric{})
35-
if err != nil {
36-
return errors.Convert(err)
24+
// All return all the migration scripts
25+
func All() []plugin.MigrationScript {
26+
return []plugin.MigrationScript{
27+
new(addDoraBenchmark),
28+
new(fixDoraBenchmarkMetric),
29+
new(adddoraBenchmark2023),
30+
new(addIssueLeadTimeMetricsTable),
3731
}
38-
return nil
39-
}
40-
41-
func (*doraMigrationScript) Version() uint64 {
42-
return 20220916000001
43-
}
44-
45-
func (*doraMigrationScript) Name() string {
46-
return "dora init schemas including issue lead time metrics"
4732
}

0 commit comments

Comments
 (0)