Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cherry-pick #7900 fix: component length scripts are not working #7902

Merged
merged 1 commit into from
Aug 15, 2024
Merged
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
4 changes: 3 additions & 1 deletion backend/core/dal/dal.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ type Dal interface {
RenameColumn(table, oldColumnName, newColumnName string) errors.Error
// ModifyColumnType modifies column type
ModifyColumnType(table, columnName, columnType string) errors.Error
// DropIndexes drops all specified tables
// DropIndexes drops indexes by their name
DropIndexes(table string, indexes ...string) errors.Error
// DropIndex drops the index of specified column names
DropIndex(table string, columnNames ...string) errors.Error
// Dialect returns the dialect of current database
Dialect() string
// Session creates a new manual session for special scenarios
Expand Down
6 changes: 6 additions & 0 deletions backend/impls/dalgorm/dalgorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,12 @@ func (d *Dalgorm) DropIndexes(table string, indexNames ...string) errors.Error {
return nil
}

// DropIndexes drops the index of specified columns
func (d *Dalgorm) DropIndex(table string, columnNames ...string) errors.Error {
indexName := fmt.Sprintf("idx_%s_%s", table, strings.Join(columnNames, "_"))
return d.DropIndexes(table, indexName)
}

// Dialect returns the dialect of the database
func (d *Dalgorm) Dialect() string {
return d.db.Dialector.Name()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ var _ plugin.MigrationScript = (*changeIssueComponentType)(nil)
type changeIssueComponentType struct{}

func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error {
return basicRes.GetDal().ModifyColumnType("_tool_bitbucket_issues", "components", "text")
return basicRes.GetDal().ModifyColumnType("_tool_bitbucket_issues", "component", "text")
}

func (*changeIssueComponentType) Version() uint64 {
return 20240813154323
}

func (*changeIssueComponentType) Name() string {
return "change _tool_bitbucket_issues.components type to text"
return "change _tool_bitbucket_issues.component type to text"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ var _ plugin.MigrationScript = (*changeIssueComponentType)(nil)
type changeIssueComponentType struct{}

func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error {
return basicRes.GetDal().ModifyColumnType("_tool_gitee_issues", "components", "text")
return basicRes.GetDal().ModifyColumnType("_tool_gitee_issues", "component", "text")
}

func (*changeIssueComponentType) Version() uint64 {
return 20240813154445
}

func (*changeIssueComponentType) Name() string {
return "change _tool_gitee_issues.components type to text"
return "change _tool_gitee_issues.component type to text"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ var _ plugin.MigrationScript = (*changeIssueComponentType)(nil)
type changeIssueComponentType struct{}

func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error {
return basicRes.GetDal().ModifyColumnType("_tool_github_issues", "components", "text")
return basicRes.GetDal().ModifyColumnType("_tool_github_issues", "component", "text")
}

func (*changeIssueComponentType) Version() uint64 {
return 20240813154633
}

func (*changeIssueComponentType) Name() string {
return "change _tool_github_issues.components type to text"
return "change _tool_github_issues.component type to text"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ var _ plugin.MigrationScript = (*changeIssueComponentType)(nil)
type changeIssueComponentType struct{}

func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error {
return basicRes.GetDal().ModifyColumnType("_tool_gitlab_issues", "components", "text")
return basicRes.GetDal().ModifyColumnType("_tool_gitlab_issues", "component", "text")
}

func (*changeIssueComponentType) Version() uint64 {
return 20240813154323
}

func (*changeIssueComponentType) Name() string {
return "change _tool_gitlab_issues.components type to text"
return "change _tool_gitlab_issues.component type to text"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ var _ plugin.MigrationScript = (*changeIssueComponentType)(nil)
type changeIssueComponentType struct{}

func (script *changeIssueComponentType) Up(basicRes context.BasicRes) errors.Error {
return basicRes.GetDal().ModifyColumnType("_tool_sonarqube_issues", "components", "text")
db := basicRes.GetDal()
errors.Must(db.DropIndex("_tool_sonarqube_issues", "component"))
return db.ModifyColumnType("_tool_sonarqube_issues", "component", "text")
}

func (*changeIssueComponentType) Version() uint64 {
return 20240813153541
}

func (*changeIssueComponentType) Name() string {
return "change _tool_sonarqube_issues.components type to text"
return "change _tool_sonarqube_issues.component type to text"
}
Loading