Skip to content

Commit 9e852ed

Browse files
6543lafriks
andauthored
Add v171 (addSortingColToProjectBoard) migration for #14634 (#14652)
* add v171 Migration for #14634 * NOT NULL Co-authored-by: Lauris BH <[email protected]>
1 parent 51fb046 commit 9e852ed

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ var migrations = []Migration{
288288
NewMigration("Update DeleteBranch comments to set the old_ref to the commit_sha", commentTypeDeleteBranchUseOldRef),
289289
// v170 -> v171
290290
NewMigration("Add Dismissed to Review table", addDismissedReviewColumn),
291+
// v171 -> v172
292+
NewMigration("Add Sorting to ProjectBoard table", addSortingColToProjectBoard),
291293
}
292294

293295
// GetCurrentDBVersion returns the current db version

models/migrations/v171.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"fmt"
9+
10+
"xorm.io/xorm"
11+
)
12+
13+
func addSortingColToProjectBoard(x *xorm.Engine) error {
14+
type ProjectBoard struct {
15+
Sorting int8 `xorm:"NOT NULL DEFAULT 0"`
16+
}
17+
18+
if err := x.Sync2(new(ProjectBoard)); err != nil {
19+
return fmt.Errorf("Sync2: %v", err)
20+
}
21+
return nil
22+
}

models/project_board.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type ProjectBoard struct {
3636
ID int64 `xorm:"pk autoincr"`
3737
Title string
3838
Default bool `xorm:"NOT NULL DEFAULT false"` // issues not assigned to a specific board will be assigned to this board
39-
Sorting int8 `xorm:"DEFAULT 0"`
39+
Sorting int8 `xorm:"NOT NULL DEFAULT 0"`
4040

4141
ProjectID int64 `xorm:"INDEX NOT NULL"`
4242
CreatorID int64 `xorm:"NOT NULL"`

0 commit comments

Comments
 (0)