fix(kanban): Make sure all saved taskBucket positions are saved with their project view id
When the tasks were migrated from belonging directly to a bucket to only belonging to a view, I forgot to add the view in that migration, resulting in task buckets where the view was 0. These entries were not deleted when a task was moved between buckets, but the new task bucket relation nevertheless inserted. This resulted in tasks showing up multiple times on the kanban board. This change adds a new migration which adds the correct project view id (as derived from the bucket) and fixes the old migration as well. Resolves https://community.vikunja.io/t/no-longer-able-to-properly-move-tasks-between-kanban-columns/2175
This commit is contained in:
parent
e0417c8bda
commit
7b8fab33a5
@ -78,8 +78,9 @@ func init() {
|
|||||||
if view.ViewKind == 3 { // Kanban view
|
if view.ViewKind == 3 { // Kanban view
|
||||||
|
|
||||||
pos := taskBuckets20240315110428{
|
pos := taskBuckets20240315110428{
|
||||||
TaskID: task.ID,
|
TaskID: task.ID,
|
||||||
BucketID: task.BucketID,
|
BucketID: task.BucketID,
|
||||||
|
ProjectViewID: view.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = tx.Insert(pos)
|
_, err = tx.Insert(pos)
|
||||||
|
83
pkg/migration/20240406125227.go
Normal file
83
pkg/migration/20240406125227.go
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// Vikunja is a to-do list application to facilitate your life.
|
||||||
|
// Copyright 2018-present Vikunja and contributors. All rights reserved.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public Licensee as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public Licensee for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public Licensee
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package migration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"src.techknowlogick.com/xormigrate"
|
||||||
|
"xorm.io/xorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type taskBucket20240406125227 struct {
|
||||||
|
BucketID int64 `xorm:"bigint not null index"`
|
||||||
|
TaskID int64 `xorm:"bigint not null index"`
|
||||||
|
ProjectViewID int64 `xorm:"bigint not null index"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (taskBucket20240406125227) TableName() string {
|
||||||
|
return "task_buckets"
|
||||||
|
}
|
||||||
|
|
||||||
|
type bucket20240406125227 struct {
|
||||||
|
ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"bucket"`
|
||||||
|
ProjectViewID int64 `xorm:"bigint not null" json:"project_view_id" param:"view"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bucket20240406125227) TableName() string {
|
||||||
|
return "buckets"
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
migrations = append(migrations, &xormigrate.Migration{
|
||||||
|
ID: "20240406125227",
|
||||||
|
Description: "Add correct project_view_id to task_buckets",
|
||||||
|
Migrate: func(tx *xorm.Engine) error {
|
||||||
|
|
||||||
|
buckets := make(map[int64]*bucket20240406125227)
|
||||||
|
|
||||||
|
err := tx.Find(&buckets)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tbs := []*taskBucket20240406125227{}
|
||||||
|
err = tx.Where("project_view_id = 0").Find(&tbs)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(tbs) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tb := range tbs {
|
||||||
|
tb.ProjectViewID = buckets[tb.BucketID].ProjectViewID
|
||||||
|
_, err = tx.
|
||||||
|
Where("task_id = ? AND bucket_id = ?", tb.TaskID, tb.BucketID).
|
||||||
|
Cols("project_view_id").
|
||||||
|
Update(tb)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
Rollback: func(tx *xorm.Engine) error {
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user