mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-19 22:40:30 +02:00
add group ID column to repository table's unique constraint
This commit is contained in:
parent
7a8db72e63
commit
e2c6623244
@ -1,24 +1,15 @@
|
|||||||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
package v1_26
|
package v1_26
|
||||||
|
|
||||||
import (
|
import "xorm.io/xorm"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"xorm.io/xorm"
|
func AddGroupColumnsToRepositoryTable(x *xorm.Engine) error {
|
||||||
)
|
type Repository struct {
|
||||||
|
GroupID int64 `xorm:"UNIQUE(s) INDEX DEFAULT NULL"`
|
||||||
func FixClosedMilestoneCompleteness(x *xorm.Engine) error {
|
GroupSortOrder int
|
||||||
// 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)
|
|
||||||
}
|
}
|
||||||
|
_, err := x.SyncWithOptions(xorm.SyncOptions{
|
||||||
return nil
|
IgnoreConstrains: false,
|
||||||
|
IgnoreIndices: false,
|
||||||
|
}, new(Repository))
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -220,7 +220,7 @@ type Repository struct {
|
|||||||
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
|
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
|
||||||
ArchivedUnix timeutil.TimeStamp `xorm:"DEFAULT 0"`
|
ArchivedUnix timeutil.TimeStamp `xorm:"DEFAULT 0"`
|
||||||
|
|
||||||
GroupID int64 `xorm:"INDEX DEFAULT NULL"`
|
GroupID int64 `xorm:"UNIQUE(s) INDEX DEFAULT NULL"`
|
||||||
GroupSortOrder int `xorm:"INDEX"`
|
GroupSortOrder int `xorm:"INDEX"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user