Skip to content

Commit 3a39d35

Browse files
add indices to group_id and group_sort_order column
add migration for repository table
1 parent 01c5327 commit 3a39d35

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

models/migrations/migrations.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ func prepareMigrationTasks() []*migration {
386386

387387
// Gitea 1.24.0 ends at database version 321
388388
newMigration(321, "Use LONGTEXT for some columns and fix review_state.updated_files column", v1_25.UseLongTextInSomeColumnsAndFixBugs),
389+
newMigration(322, "Add group_id and group_sort_order columns to repository table", v1_25.AddGroupColumnsToRepositoryTable),
389390
}
390391
return preparedMigrations
391392
}

models/migrations/v1_25/v322.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_25
5+
6+
import "xorm.io/xorm"
7+
8+
func AddGroupColumnsToRepositoryTable(x *xorm.Engine) error {
9+
type Repository struct {
10+
GroupID int64 `xorm:"DEFAULT NULL"`
11+
GroupSortOrder int
12+
}
13+
_, err := x.SyncWithOptions(xorm.SyncOptions{
14+
IgnoreConstrains: false,
15+
IgnoreIndices: false,
16+
}, new(Repository))
17+
return err
18+
}

models/repo/repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ type Repository struct {
220220
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
221221
ArchivedUnix timeutil.TimeStamp `xorm:"DEFAULT 0"`
222222

223-
GroupID int64 `xorm:"DEFAULT NULL"`
224-
GroupSortOrder int
223+
GroupID int64 `xorm:"INDEX DEFAULT NULL"`
224+
GroupSortOrder int `xorm:"INDEX"`
225225
}
226226

227227
func init() {

0 commit comments

Comments
 (0)