0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-10 20:31:25 +02:00

update migrations

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-12-20 16:14:25 -05:00
parent 3cb61517a3
commit a79c96748d
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C
2 changed files with 36 additions and 12 deletions

View File

@ -3,18 +3,22 @@
package v1_26
import "xorm.io/xorm"
import (
"fmt"
func AddGroupColumnsToRepositoryTable(x *xorm.Engine) error {
type Repository struct {
LowerName string `xorm:"UNIQUE(s) UNIQUE(g) INDEX NOT NULL"`
GroupID int64 `xorm:"UNIQUE(g) INDEX DEFAULT 0"`
OwnerID int64 `xorm:"UNIQUE(s) UNIQUE(g) index"`
GroupSortOrder int
"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)
}
_, err := x.SyncWithOptions(xorm.SyncOptions{
IgnoreConstrains: false,
IgnoreIndices: false,
}, new(Repository))
return err
return nil
}

View File

@ -0,0 +1,20 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package v1_26
import "xorm.io/xorm"
func AddGroupColumnsToRepositoryTable(x *xorm.Engine) error {
type Repository struct {
LowerName string `xorm:"UNIQUE(s) UNIQUE(g) INDEX NOT NULL"`
GroupID int64 `xorm:"UNIQUE(s) INDEX DEFAULT 0"`
OwnerID int64 `xorm:"UNIQUE(s) UNIQUE(g) index"`
GroupSortOrder int
}
_, err := x.SyncWithOptions(xorm.SyncOptions{
IgnoreConstrains: false,
IgnoreIndices: false,
}, new(Repository))
return err
}