Browse Source

#981

add sql
tags/v1.21.12.2^2
chenyifan01 3 years ago
parent
commit
535835416b
3 changed files with 34 additions and 0 deletions
  1. +2
    -0
      models/migrations/migrations.go
  2. +31
    -0
      models/migrations/v140.go
  3. +1
    -0
      models/repo_tag.go

+ 2
- 0
models/migrations/migrations.go View File

@@ -212,6 +212,8 @@ var migrations = []Migration{
NewMigration("Add ResolveDoerID to Comment table", addResolveDoerIDCommentColumn),
// v139 -> v140
NewMigration("prepend refs/heads/ to issue refs", prependRefsHeadsToIssueRefs),
// v140 -> v141
NewMigration("init selected tag", initSelectedTag),
}

// GetCurrentDBVersion returns the current db version


+ 31
- 0
models/migrations/v140.go View File

@@ -0,0 +1,31 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package migrations

import (
"code.gitea.io/gitea/models"
"xorm.io/xorm"
)

func initSelectedTag(x *xorm.Engine) error {
p := &models.OfficialTag{
Code: "Selected",
}

ok, err := x.Get(p)

if ok {
return nil
}

t := &models.OfficialTag{
ID: 1,
Code: "Selected",
Name: "精选项目",
Limit: 9,
}
_, err = x.Insert(t)
return err
}

+ 1
- 0
models/repo_tag.go View File

@@ -10,6 +10,7 @@ const DefaultOrgTagLimit = -1
type OfficialTag struct {
ID int64 `xorm:"pk autoincr"`
Name string `xorm:"NOT NULL"`
Code string `xorm:"NOT NULL"`
Limit int `xorm:"NOT NULL default(-1)"`
CreatedUnix timeutil.TimeStamp `xorm:"created"`
UpdatedUnix timeutil.TimeStamp `xorm:"updated"`


Loading…
Cancel
Save