Skip to content

Commit bcaba8b

Browse files
committed
reanme table name
1 parent 0e37460 commit bcaba8b

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

models/migrations/v1_20/v257.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func CreateVariableTable(x *xorm.Engine) error {
13-
type Variable struct {
13+
type ActionVariable struct {
1414
ID int64 `xorm:"pk autoincr"`
1515
OwnerID int64 `xorm:"INDEX UNIQUE(owner_repo_name) NOT NULL DEFAULT 0"`
1616
RepoID int64 `xorm:"INDEX UNIQUE(owner_repo_name) NOT NULL DEFAULT 0"`
@@ -20,5 +20,5 @@ func CreateVariableTable(x *xorm.Engine) error {
2020
UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
2121
}
2222

23-
return x.Sync(new(Variable))
23+
return x.Sync(new(ActionVariable))
2424
}

models/variable/variable.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"xorm.io/builder"
1717
)
1818

19-
type Variable struct {
19+
type ActionVariable struct {
2020
ID int64 `xorm:"pk autoincr"`
2121
OwnerID int64 `xorm:"INDEX UNIQUE(owner_repo_name) NOT NULL DEFAULT 0"`
2222
RepoID int64 `xorm:"INDEX UNIQUE(owner_repo_name) NOT NULL DEFAULT 0"`
@@ -27,7 +27,7 @@ type Variable struct {
2727
}
2828

2929
func init() {
30-
db.RegisterModel(new(Variable))
30+
db.RegisterModel(new(ActionVariable))
3131
}
3232

3333
type ErrVariableUnbound struct{}
@@ -58,7 +58,7 @@ var (
5858
variableForbiddenPrefixReg = regexp.MustCompile("(?i)^GIT(EA|HUB)_")
5959
)
6060

61-
func (v *Variable) Validate() error {
61+
func (v *ActionVariable) Validate() error {
6262
switch {
6363
case v.OwnerID == 0 && v.RepoID == 0:
6464
return ErrVariableUnbound{}
@@ -73,8 +73,8 @@ func (v *Variable) Validate() error {
7373
}
7474
}
7575

76-
func InsertVariable(ctx context.Context, ownerID, repoID int64, name, data string) (*Variable, error) {
77-
variable := &Variable{
76+
func InsertVariable(ctx context.Context, ownerID, repoID int64, name, data string) (*ActionVariable, error) {
77+
variable := &ActionVariable{
7878
OwnerID: ownerID,
7979
RepoID: repoID,
8080
Name: strings.ToUpper(name),
@@ -103,17 +103,17 @@ func (opts *FindVariablesOpts) toConds() builder.Cond {
103103
return cond
104104
}
105105

106-
func FindVariables(ctx context.Context, opts FindVariablesOpts) ([]*Variable, error) {
107-
var variables []*Variable
106+
func FindVariables(ctx context.Context, opts FindVariablesOpts) ([]*ActionVariable, error) {
107+
var variables []*ActionVariable
108108
sess := db.GetEngine(ctx)
109109
if opts.PageSize != 0 {
110110
sess = db.SetSessionPagination(sess, &opts.ListOptions)
111111
}
112112
return variables, sess.Where(opts.toConds()).Find(&variables)
113113
}
114114

115-
func GetVariableByID(ctx context.Context, variableID int64) (*Variable, error) {
116-
var variable Variable
115+
func GetVariableByID(ctx context.Context, variableID int64) (*ActionVariable, error) {
116+
var variable ActionVariable
117117
has, err := db.GetEngine(ctx).Where("id=?", variableID).Get(&variable)
118118
if err != nil {
119119
return nil, err
@@ -123,13 +123,13 @@ func GetVariableByID(ctx context.Context, variableID int64) (*Variable, error) {
123123
return &variable, nil
124124
}
125125

126-
func UpdateVariable(ctx context.Context, variable *Variable) (bool, error) {
126+
func UpdateVariable(ctx context.Context, variable *ActionVariable) (bool, error) {
127127
if err := variable.Validate(); err != nil {
128128
return false, err
129129
}
130130
count, err := db.GetEngine(ctx).ID(variable.ID).Cols("name", "data").
131131
Where("owner_id = ? and repo_id = ?", variable.OwnerID, variable.RepoID).
132-
Update(&Variable{
132+
Update(&ActionVariable{
133133
Name: variable.Name,
134134
Data: variable.Data,
135135
})

routers/web/shared/variables/variables.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func SetVariablesContext(ctx *context.Context, ownerID, repoID int64) {
3131
func DeleteVariable(ctx *context.Context, ownerID, repoID int64, redirectURL string) {
3232
id := ctx.ParamsInt64(":variableID")
3333

34-
if _, err := db.DeleteByBean(ctx, &variable_model.Variable{
34+
if _, err := db.DeleteByBean(ctx, &variable_model.ActionVariable{
3535
ID: id,
3636
OwnerID: ownerID,
3737
RepoID: repoID,
@@ -86,7 +86,7 @@ func GetVariable(ctx *context.Context) {
8686
func UpdateVariable(ctx *context.Context, ownerID, repoID int64, redirectURL string) {
8787
id := ctx.ParamsInt64(":variableID")
8888
form := web.GetForm(ctx).(*forms.EditVariableForm)
89-
ok, err := variable_model.UpdateVariable(ctx, &variable_model.Variable{
89+
ok, err := variable_model.UpdateVariable(ctx, &variable_model.ActionVariable{
9090
ID: id,
9191
OwnerID: ownerID,
9292
RepoID: repoID,

0 commit comments

Comments
 (0)