Change task title to TEXT instead of varchar(250) to allow for longer task titles
This commit is contained in:
parent
32a07c4c61
commit
358661e060
5 changed files with 54 additions and 7 deletions
53
pkg/migration/20210709191101.go
Normal file
53
pkg/migration/20210709191101.go
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Vikunja is a to-do list application to facilitate your life.
|
||||
// Copyright 2018-2021 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 (
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/log"
|
||||
"src.techknowlogick.com/xormigrate"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func init() {
|
||||
migrations = append(migrations, &xormigrate.Migration{
|
||||
ID: "20210709191101",
|
||||
Description: "Make the task title type TEXT instead of varchar(250)",
|
||||
Migrate: func(tx *xorm.Engine) error {
|
||||
switch config.DatabaseType.GetString() {
|
||||
case "sqlite":
|
||||
// Sqlite only has a "TEXT" type so we don't need to modify it
|
||||
case "mysql":
|
||||
_, err := tx.Exec("alter table tasks modify title text not null")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case "postgres":
|
||||
_, err := tx.Exec("alter table tasks alter column title type text using title::text")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
log.Fatal("Unknown db.")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Rollback: func(tx *xorm.Engine) error {
|
||||
return nil
|
||||
},
|
||||
})
|
||||
}
|
|
@ -49,7 +49,7 @@ type Task struct {
|
|||
// The unique, numeric id of this task.
|
||||
ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"listtask"`
|
||||
// The task text. This is what you'll see in the list.
|
||||
Title string `xorm:"varchar(250) not null" json:"title" valid:"runelength(1|250)" minLength:"1" maxLength:"250"`
|
||||
Title string `xorm:"TEXT not null" json:"title" valid:"minstringlength(1)" minLength:"1"`
|
||||
// The task description.
|
||||
Description string `xorm:"longtext null" json:"description"`
|
||||
// Whether a task is done or not.
|
||||
|
|
|
@ -7385,7 +7385,6 @@ var doc = `{
|
|||
"title": {
|
||||
"description": "The task text. This is what you'll see in the list.",
|
||||
"type": "string",
|
||||
"maxLength": 250,
|
||||
"minLength": 1
|
||||
},
|
||||
"updated": {
|
||||
|
@ -7955,7 +7954,6 @@ var doc = `{
|
|||
"title": {
|
||||
"description": "The task text. This is what you'll see in the list.",
|
||||
"type": "string",
|
||||
"maxLength": 250,
|
||||
"minLength": 1
|
||||
},
|
||||
"updated": {
|
||||
|
|
|
@ -7368,7 +7368,6 @@
|
|||
"title": {
|
||||
"description": "The task text. This is what you'll see in the list.",
|
||||
"type": "string",
|
||||
"maxLength": 250,
|
||||
"minLength": 1
|
||||
},
|
||||
"updated": {
|
||||
|
@ -7938,7 +7937,6 @@
|
|||
"title": {
|
||||
"description": "The task text. This is what you'll see in the list.",
|
||||
"type": "string",
|
||||
"maxLength": 250,
|
||||
"minLength": 1
|
||||
},
|
||||
"updated": {
|
||||
|
|
|
@ -244,7 +244,6 @@ definitions:
|
|||
type: array
|
||||
title:
|
||||
description: The task text. This is what you'll see in the list.
|
||||
maxLength: 250
|
||||
minLength: 1
|
||||
type: string
|
||||
updated:
|
||||
|
@ -722,7 +721,6 @@ definitions:
|
|||
Will only returned when retreiving one task.
|
||||
title:
|
||||
description: The task text. This is what you'll see in the list.
|
||||
maxLength: 250
|
||||
minLength: 1
|
||||
type: string
|
||||
updated:
|
||||
|
|
Loading…
Reference in a new issue