mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-14 00:01:05 +02:00
update migrations
This commit is contained in:
parent
b7a8287625
commit
657d35a3c5
@ -3,18 +3,22 @@
|
|||||||
|
|
||||||
package v1_26
|
package v1_26
|
||||||
|
|
||||||
import "xorm.io/xorm"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
func AddGroupColumnsToRepositoryTable(x *xorm.Engine) error {
|
"xorm.io/xorm"
|
||||||
type Repository struct {
|
)
|
||||||
LowerName string `xorm:"UNIQUE(s) UNIQUE(g) INDEX NOT NULL"`
|
|
||||||
GroupID int64 `xorm:"UNIQUE(g) INDEX DEFAULT 0"`
|
func FixClosedMilestoneCompleteness(x *xorm.Engine) error {
|
||||||
OwnerID int64 `xorm:"UNIQUE(s) UNIQUE(g) index"`
|
// Update all milestones to recalculate completeness with the new logic:
|
||||||
GroupSortOrder int
|
// - 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,
|
return nil
|
||||||
IgnoreIndices: false,
|
|
||||||
}, new(Repository))
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|||||||
20
models/migrations/v1_26/v331.go
Normal file
20
models/migrations/v1_26/v331.go
Normal 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
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user