add group ID column to repository table's unique constraint

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ committed 2026-04-02 20:00:57 -04:00
1 parent 7a8db72e63
commit e2c6623244
2 files changed
+11 -20

No files matched your search

+10 -19
View File
@@ -1,24 +1,15 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package v1_26
import (
"fmt"
import "xorm.io/xorm"
"xorm.io/xorm"
)
func FixClosedMilestoneCompleteness(x *xorm.Engine) error {
// Update all milestones to recalculate completeness with the new logic:
// - Closed milestones with 0 issues should show 100%
// - All other milestones should calculate based on closed/total ratio
_, err := x.Exec("UPDATE `milestone` SET completeness=(CASE WHEN is_closed = ? AND num_issues = 0 THEN 100 ELSE 100*num_closed_issues/(CASE WHEN num_issues > 0 THEN num_issues ELSE 1 END) END)",
true,
)
if err != nil {
return fmt.Errorf("error updating milestone completeness: %w", err)
func AddGroupColumnsToRepositoryTable(x *xorm.Engine) error {
type Repository struct {
GroupID int64 `xorm:"UNIQUE(s) INDEX DEFAULT NULL"`
GroupSortOrder int
}
return nil
_, err := x.SyncWithOptions(xorm.SyncOptions{
IgnoreConstrains: false,
IgnoreIndices: false,
}, new(Repository))
return err
}