diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 00d84da2e..e134a875e 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -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 diff --git a/models/migrations/v140.go b/models/migrations/v140.go new file mode 100644 index 000000000..5684dba44 --- /dev/null +++ b/models/migrations/v140.go @@ -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 +} diff --git a/models/repo_tag.go b/models/repo_tag.go index 579a6cf5f..21e742082 100644 --- a/models/repo_tag.go +++ b/models/repo_tag.go @@ -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"`