Make sure all int64 db fields are using bigint when actually storing the data (#741)

Fix lint

Fix migration query for postgres

Fix migration statements

Add migration to make all int(11) fields bigint by default

Make all int(11) fields bigint by default

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/api/pulls/741
Co-Authored-By: konrad <konrad@kola-entertainments.de>
Co-Committed-By: konrad <konrad@kola-entertainments.de>
This commit is contained in:
konrad 2020-12-18 16:51:22 +00:00
parent f15a8baee3
commit b0d4902406
22 changed files with 279 additions and 71 deletions

View file

@ -23,13 +23,13 @@ As an example, this is the definition of a list with all comments:
// List represents a list of tasks // List represents a list of tasks
type List struct { type List struct {
// The unique, numeric id of this list. // The unique, numeric id of this list.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"list"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"list"`
// The title of the list. You'll see this in the namespace overview. // The title of the list. You'll see this in the namespace overview.
Title string `xorm:"varchar(250)" json:"title" valid:"required,runelength(3|250)" minLength:"3" maxLength:"250"` Title string `xorm:"varchar(250)" json:"title" valid:"required,runelength(3|250)" minLength:"3" maxLength:"250"`
// The description of the list. // The description of the list.
Description string `xorm:"varchar(1000)" json:"description" valid:"runelength(0|1000)" maxLength:"1000"` Description string `xorm:"varchar(1000)" json:"description" valid:"runelength(0|1000)" maxLength:"1000"`
OwnerID int64 `xorm:"int(11) INDEX" json:"-"` OwnerID int64 `xorm:"bigint INDEX" json:"-"`
NamespaceID int64 `xorm:"int(11) INDEX" json:"-" param:"namespace"` NamespaceID int64 `xorm:"bigint INDEX" json:"-" param:"namespace"`
// The user who created this list. // The user who created this list.
Owner User `xorm:"-" json:"owner" valid:"-"` Owner User `xorm:"-" json:"owner" valid:"-"`

View file

@ -29,13 +29,13 @@ import (
// File holds all information about a file // File holds all information about a file
type File struct { type File struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id"`
Name string `xorm:"text not null" json:"name"` Name string `xorm:"text not null" json:"name"`
Mime string `xorm:"text null" json:"mime"` Mime string `xorm:"text null" json:"mime"`
Size uint64 `xorm:"int(11) not null" json:"size"` Size uint64 `xorm:"bigint not null" json:"size"`
Created time.Time `xorm:"created" json:"created"` Created time.Time `xorm:"created" json:"created"`
CreatedByID int64 `xorm:"int(11) not null" json:"-"` CreatedByID int64 `xorm:"bigint not null" json:"-"`
File afero.File `xorm:"-" json:"-"` File afero.File `xorm:"-" json:"-"`
// This ReadCloser is only used for migration purposes. Use with care! // This ReadCloser is only used for migration purposes. Use with care!

View file

@ -0,0 +1,208 @@
// Vikunja is a to-do list application to facilitate your life.
// Copyright 2018-2020 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 General Public License 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package migration
import (
"strings"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
"src.techknowlogick.com/xormigrate"
"xorm.io/xorm"
)
func changeColumnToBigint(x *xorm.Session, table, column string, nullable, defaultValue bool) (err error) {
switch config.DatabaseType.GetString() {
case "sqlite":
// Sqlite only has one "INTEGER" type which is at the same time int and int64
case "mysql":
var notnull = " NOT NULL"
if nullable {
notnull = ""
}
var def = ""
if defaultValue {
def = " DEFAULT 0"
}
_, err := x.Exec("ALTER TABLE " + table + " MODIFY `" + column + "` BIGINT" + def + notnull)
if err != nil {
return err
}
case "postgres":
_, err := x.Exec("ALTER TABLE " + table + " ALTER COLUMN `" + column + "` TYPE BIGINT using `" + column + "`::bigint")
if err != nil {
return err
}
default:
log.Fatal("Unknown db.")
}
return
}
func init() {
migrations = append(migrations, &xormigrate.Migration{
ID: "20201218152741",
Description: "Make sure all int64 fields are bigint in the db",
Migrate: func(tx *xorm.Engine) error {
// table is the key, columns are the contents
columns := map[string][]string{
"totp": {
"id",
"user_id",
},
"users": {
"id",
},
"files": {
"id",
"size", // TODO: This should be a uint64
"created_by_id",
},
"namespaces": {
"id",
"owner_id",
},
"team_list": {
"id",
"team_id",
"list_id",
"default:right",
},
"saved_filters": {
"owner_id",
},
"label_task": {
"id",
"task_id",
"label_id",
},
"task_relations": {
"id",
"task_id",
"other_task_id",
"created_by_id",
},
"team_namespaces": {
"id",
"team_id",
"namespace_id",
"default:right",
},
"users_namespace": {
"id",
"user_id",
"namespace_id",
"default:right",
},
"teams": {
"id",
"created_by_id",
},
"team_members": {
"id",
"team_id",
"user_id",
},
"task_assignees": {
"id",
"task_id",
"user_id",
},
"users_list": {
"id",
"user_id",
"list_id",
"default:right",
},
"tasks": {
"id",
"created_by_id",
"list_id",
"nullable:repeat_after",
"nullable:priority",
"default:index",
"nullable:bucket_id",
},
"task_reminders": {
"id",
"task_id",
},
"task_attachments": {
"id",
"task_id",
"file_id",
"created_by_id",
},
"list": {
"id",
"owner_id",
"namespace_id",
},
"labels": {
"id",
"created_by_id",
},
"buckets": {
"id",
"list_id",
"created_by_id",
},
"link_sharing": {
"id",
"list_id",
"default:right",
"sharing_type",
"shared_by_id",
},
"migration_status": {
"id",
"user_id",
},
}
s := tx.NewSession()
for table, cols := range columns {
for _, col := range cols {
var nullable = false
if strings.HasPrefix(col, "nullable:") {
col = strings.ReplaceAll(col, "nullable:", "")
nullable = true
}
var defaultValue = false
if strings.HasPrefix(col, "default:") {
col = strings.ReplaceAll(col, "default:", "")
defaultValue = true
}
log.Debugf("Migrating %s.%s to bigint", table, col)
err := changeColumnToBigint(s, table, col, nullable, defaultValue)
if err != nil {
_ = s.Rollback()
return err
}
}
}
return s.Commit()
},
Rollback: func(tx *xorm.Engine) error {
return nil
},
})
}

View file

@ -28,11 +28,11 @@ import (
// Bucket represents a kanban bucket // Bucket represents a kanban bucket
type Bucket struct { type Bucket struct {
// The unique, numeric id of this bucket. // The unique, numeric id of this bucket.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"bucket"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"bucket"`
// The title of this bucket. // The title of this bucket.
Title string `xorm:"text not null" valid:"required" minLength:"1" json:"title"` Title string `xorm:"text not null" valid:"required" minLength:"1" json:"title"`
// The list this bucket belongs to. // The list this bucket belongs to.
ListID int64 `xorm:"int(11) not null" json:"list_id" param:"list"` ListID int64 `xorm:"bigint not null" json:"list_id" param:"list"`
// All tasks which belong to this bucket. // All tasks which belong to this bucket.
Tasks []*Task `xorm:"-" json:"tasks"` Tasks []*Task `xorm:"-" json:"tasks"`
@ -46,7 +46,7 @@ type Bucket struct {
// The user who initially created the bucket. // The user who initially created the bucket.
CreatedBy *user.User `xorm:"-" json:"created_by" valid:"-"` CreatedBy *user.User `xorm:"-" json:"created_by" valid:"-"`
CreatedByID int64 `xorm:"int(11) not null" json:"-"` CreatedByID int64 `xorm:"bigint not null" json:"-"`
web.Rights `xorm:"-" json:"-"` web.Rights `xorm:"-" json:"-"`
web.CRUDable `xorm:"-" json:"-"` web.CRUDable `xorm:"-" json:"-"`

View file

@ -26,7 +26,7 @@ import (
// Label represents a label // Label represents a label
type Label struct { type Label struct {
// The unique, numeric id of this label. // The unique, numeric id of this label.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"label"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"label"`
// The title of the lable. You'll see this one on tasks associated with it. // The title of the lable. You'll see this one on tasks associated with it.
Title string `xorm:"varchar(250) not null" json:"title" valid:"runelength(1|250)" minLength:"1" maxLength:"250"` Title string `xorm:"varchar(250) not null" json:"title" valid:"runelength(1|250)" minLength:"1" maxLength:"250"`
// The label description. // The label description.
@ -34,7 +34,7 @@ type Label struct {
// The color this label has // The color this label has
HexColor string `xorm:"varchar(6) null" json:"hex_color" valid:"runelength(0|6)" maxLength:"6"` HexColor string `xorm:"varchar(6) null" json:"hex_color" valid:"runelength(0|6)" maxLength:"6"`
CreatedByID int64 `xorm:"int(11) not null" json:"-"` CreatedByID int64 `xorm:"bigint not null" json:"-"`
// The user who created this label // The user who created this label
CreatedBy *user.User `xorm:"-" json:"created_by"` CreatedBy *user.User `xorm:"-" json:"created_by"`

View file

@ -27,10 +27,10 @@ import (
// LabelTask represents a relation between a label and a task // LabelTask represents a relation between a label and a task
type LabelTask struct { type LabelTask struct {
// The unique, numeric id of this label. // The unique, numeric id of this label.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"-"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"-"`
TaskID int64 `xorm:"int(11) INDEX not null" json:"-" param:"listtask"` TaskID int64 `xorm:"bigint INDEX not null" json:"-" param:"listtask"`
// The label id you want to associate with a task. // The label id you want to associate with a task.
LabelID int64 `xorm:"int(11) INDEX not null" json:"label_id" param:"label"` LabelID int64 `xorm:"bigint INDEX not null" json:"label_id" param:"label"`
// A timestamp when this task was created. You cannot change this value. // A timestamp when this task was created. You cannot change this value.
Created time.Time `xorm:"created not null" json:"created"` Created time.Time `xorm:"created not null" json:"created"`

View file

@ -39,20 +39,20 @@ const (
// LinkSharing represents a shared list // LinkSharing represents a shared list
type LinkSharing struct { type LinkSharing struct {
// The ID of the shared thing // The ID of the shared thing
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"share"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"share"`
// The public id to get this shared list // The public id to get this shared list
Hash string `xorm:"varchar(40) not null unique" json:"hash" param:"hash"` Hash string `xorm:"varchar(40) not null unique" json:"hash" param:"hash"`
// The ID of the shared list // The ID of the shared list
ListID int64 `xorm:"int(11) not null" json:"-" param:"list"` ListID int64 `xorm:"bigint not null" json:"-" param:"list"`
// The right this list is shared with. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details. // The right this list is shared with. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"` Right Right `xorm:"bigint INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
// The kind of this link. 0 = undefined, 1 = without password, 2 = with password (currently not implemented). // The kind of this link. 0 = undefined, 1 = without password, 2 = with password (currently not implemented).
SharingType SharingType `xorm:"int(11) INDEX not null default 0" json:"sharing_type" valid:"length(0|2)" maximum:"2" default:"0"` SharingType SharingType `xorm:"bigint INDEX not null default 0" json:"sharing_type" valid:"length(0|2)" maximum:"2" default:"0"`
// The user who shared this list // The user who shared this list
SharedBy *user.User `xorm:"-" json:"shared_by"` SharedBy *user.User `xorm:"-" json:"shared_by"`
SharedByID int64 `xorm:"int(11) INDEX not null" json:"-"` SharedByID int64 `xorm:"bigint INDEX not null" json:"-"`
// A timestamp when this list was shared. You cannot change this value. // A timestamp when this list was shared. You cannot change this value.
Created time.Time `xorm:"created not null" json:"created"` Created time.Time `xorm:"created not null" json:"created"`

View file

@ -30,7 +30,7 @@ import (
// List represents a list of tasks // List represents a list of tasks
type List struct { type List struct {
// The unique, numeric id of this list. // The unique, numeric id of this list.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"list"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"list"`
// The title of the list. You'll see this in the namespace overview. // The title of the list. You'll see this in the namespace overview.
Title string `xorm:"varchar(250) not null" json:"title" valid:"required,runelength(1|250)" minLength:"1" maxLength:"250"` Title string `xorm:"varchar(250) not null" json:"title" valid:"required,runelength(1|250)" minLength:"1" maxLength:"250"`
// The description of the list. // The description of the list.
@ -40,8 +40,8 @@ type List struct {
// The hex color of this list // The hex color of this list
HexColor string `xorm:"varchar(6) null" json:"hex_color" valid:"runelength(0|6)" maxLength:"6"` HexColor string `xorm:"varchar(6) null" json:"hex_color" valid:"runelength(0|6)" maxLength:"6"`
OwnerID int64 `xorm:"int(11) INDEX not null" json:"-"` OwnerID int64 `xorm:"bigint INDEX not null" json:"-"`
NamespaceID int64 `xorm:"int(11) INDEX not null" json:"namespace_id" param:"namespace"` NamespaceID int64 `xorm:"bigint INDEX not null" json:"namespace_id" param:"namespace"`
// The user who created this list. // The user who created this list.
Owner *user.User `xorm:"-" json:"owner" valid:"-"` Owner *user.User `xorm:"-" json:"owner" valid:"-"`

View file

@ -25,13 +25,13 @@ import (
// TeamList defines the relation between a team and a list // TeamList defines the relation between a team and a list
type TeamList struct { type TeamList struct {
// The unique, numeric id of this list <-> team relation. // The unique, numeric id of this list <-> team relation.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id"`
// The team id. // The team id.
TeamID int64 `xorm:"int(11) not null INDEX" json:"team_id" param:"team"` TeamID int64 `xorm:"bigint not null INDEX" json:"team_id" param:"team"`
// The list id. // The list id.
ListID int64 `xorm:"int(11) not null INDEX" json:"-" param:"list"` ListID int64 `xorm:"bigint not null INDEX" json:"-" param:"list"`
// The right this team has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details. // The right this team has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"` Right Right `xorm:"bigint INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
// A timestamp when this relation was created. You cannot change this value. // A timestamp when this relation was created. You cannot change this value.
Created time.Time `xorm:"created not null" json:"created"` Created time.Time `xorm:"created not null" json:"created"`

View file

@ -26,15 +26,15 @@ import (
// ListUser represents a list <-> user relation // ListUser represents a list <-> user relation
type ListUser struct { type ListUser struct {
// The unique, numeric id of this list <-> user relation. // The unique, numeric id of this list <-> user relation.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"namespace"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"namespace"`
// The username. // The username.
Username string `xorm:"-" json:"user_id" param:"user"` Username string `xorm:"-" json:"user_id" param:"user"`
// Used internally to reference the user // Used internally to reference the user
UserID int64 `xorm:"int(11) not null INDEX" json:"-"` UserID int64 `xorm:"bigint not null INDEX" json:"-"`
// The list id. // The list id.
ListID int64 `xorm:"int(11) not null INDEX" json:"-" param:"list"` ListID int64 `xorm:"bigint not null INDEX" json:"-" param:"list"`
// The right this user has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details. // The right this user has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"` Right Right `xorm:"bigint INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
// A timestamp when this relation was created. You cannot change this value. // A timestamp when this relation was created. You cannot change this value.
Created time.Time `xorm:"created not null" json:"created"` Created time.Time `xorm:"created not null" json:"created"`

View file

@ -30,12 +30,12 @@ import (
// Namespace holds informations about a namespace // Namespace holds informations about a namespace
type Namespace struct { type Namespace struct {
// The unique, numeric id of this namespace. // The unique, numeric id of this namespace.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"namespace"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"namespace"`
// The name of this namespace. // The name of this namespace.
Title string `xorm:"varchar(250) not null" json:"title" valid:"required,runelength(1|250)" minLength:"1" maxLength:"250"` Title string `xorm:"varchar(250) not null" json:"title" valid:"required,runelength(1|250)" minLength:"1" maxLength:"250"`
// The description of the namespace // The description of the namespace
Description string `xorm:"longtext null" json:"description"` Description string `xorm:"longtext null" json:"description"`
OwnerID int64 `xorm:"int(11) not null INDEX" json:"-"` OwnerID int64 `xorm:"bigint not null INDEX" json:"-"`
// The hex color of this namespace // The hex color of this namespace
HexColor string `xorm:"varchar(6) null" json:"hex_color" valid:"runelength(0|6)" maxLength:"6"` HexColor string `xorm:"varchar(6) null" json:"hex_color" valid:"runelength(0|6)" maxLength:"6"`

View file

@ -25,13 +25,13 @@ import (
// TeamNamespace defines the relationship between a Team and a Namespace // TeamNamespace defines the relationship between a Team and a Namespace
type TeamNamespace struct { type TeamNamespace struct {
// The unique, numeric id of this namespace <-> team relation. // The unique, numeric id of this namespace <-> team relation.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id"`
// The team id. // The team id.
TeamID int64 `xorm:"int(11) not null INDEX" json:"team_id" param:"team"` TeamID int64 `xorm:"bigint not null INDEX" json:"team_id" param:"team"`
// The namespace id. // The namespace id.
NamespaceID int64 `xorm:"int(11) not null INDEX" json:"-" param:"namespace"` NamespaceID int64 `xorm:"bigint not null INDEX" json:"-" param:"namespace"`
// The right this team has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details. // The right this team has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"` Right Right `xorm:"bigint INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
// A timestamp when this relation was created. You cannot change this value. // A timestamp when this relation was created. You cannot change this value.
Created time.Time `xorm:"created not null" json:"created"` Created time.Time `xorm:"created not null" json:"created"`

View file

@ -26,14 +26,14 @@ import (
// NamespaceUser represents a namespace <-> user relation // NamespaceUser represents a namespace <-> user relation
type NamespaceUser struct { type NamespaceUser struct {
// The unique, numeric id of this namespace <-> user relation. // The unique, numeric id of this namespace <-> user relation.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"namespace"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"namespace"`
// The username. // The username.
Username string `xorm:"-" json:"user_id" param:"user"` Username string `xorm:"-" json:"user_id" param:"user"`
UserID int64 `xorm:"int(11) not null INDEX" json:"-"` UserID int64 `xorm:"bigint not null INDEX" json:"-"`
// The namespace id // The namespace id
NamespaceID int64 `xorm:"int(11) not null INDEX" json:"-" param:"namespace"` NamespaceID int64 `xorm:"bigint not null INDEX" json:"-" param:"namespace"`
// The right this user has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details. // The right this user has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"` Right Right `xorm:"bigint INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
// A timestamp when this relation was created. You cannot change this value. // A timestamp when this relation was created. You cannot change this value.
Created time.Time `xorm:"created not null" json:"created"` Created time.Time `xorm:"created not null" json:"created"`

View file

@ -33,7 +33,7 @@ type SavedFilter struct {
Title string `xorm:"varchar(250) not null" json:"title" valid:"required,runelength(1|250)" minLength:"1" maxLength:"250"` Title string `xorm:"varchar(250) not null" json:"title" valid:"required,runelength(1|250)" minLength:"1" maxLength:"250"`
// The description of the filter // The description of the filter
Description string `xorm:"longtext null" json:"description"` Description string `xorm:"longtext null" json:"description"`
OwnerID int64 `xorm:"int(11) not null INDEX" json:"-"` OwnerID int64 `xorm:"bigint not null INDEX" json:"-"`
// The user who owns this filter // The user who owns this filter
Owner *user.User `xorm:"-" json:"owner" valid:"-"` Owner *user.User `xorm:"-" json:"owner" valid:"-"`

View file

@ -26,9 +26,9 @@ import (
// TaskAssginee represents an assignment of a user to a task // TaskAssginee represents an assignment of a user to a task
type TaskAssginee struct { type TaskAssginee struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"-"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"-"`
TaskID int64 `xorm:"int(11) INDEX not null" json:"-" param:"listtask"` TaskID int64 `xorm:"bigint INDEX not null" json:"-" param:"listtask"`
UserID int64 `xorm:"int(11) INDEX not null" json:"user_id" param:"user"` UserID int64 `xorm:"bigint INDEX not null" json:"user_id" param:"user"`
Created time.Time `xorm:"created not null"` Created time.Time `xorm:"created not null"`
web.CRUDable `xorm:"-" json:"-"` web.CRUDable `xorm:"-" json:"-"`

View file

@ -27,11 +27,11 @@ import (
// TaskAttachment is the definition of a task attachment // TaskAttachment is the definition of a task attachment
type TaskAttachment struct { type TaskAttachment struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"attachment"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"attachment"`
TaskID int64 `xorm:"int(11) not null" json:"task_id" param:"task"` TaskID int64 `xorm:"bigint not null" json:"task_id" param:"task"`
FileID int64 `xorm:"int(11) not null" json:"-"` FileID int64 `xorm:"bigint not null" json:"-"`
CreatedByID int64 `xorm:"int(11) not null" json:"-"` CreatedByID int64 `xorm:"bigint not null" json:"-"`
CreatedBy *user.User `xorm:"-" json:"created_by"` CreatedBy *user.User `xorm:"-" json:"created_by"`
File *files.File `xorm:"-" json:"file"` File *files.File `xorm:"-" json:"file"`

View file

@ -76,15 +76,15 @@ func (rk RelationKind) isValid() bool {
// TaskRelation represents a kind of relation between two tasks // TaskRelation represents a kind of relation between two tasks
type TaskRelation struct { type TaskRelation struct {
// The unique, numeric id of this relation. // The unique, numeric id of this relation.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"-"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"-"`
// The ID of the "base" task, the task which has a relation to another. // The ID of the "base" task, the task which has a relation to another.
TaskID int64 `xorm:"int(11) not null" json:"task_id" param:"task"` TaskID int64 `xorm:"bigint not null" json:"task_id" param:"task"`
// The ID of the other task, the task which is being related. // The ID of the other task, the task which is being related.
OtherTaskID int64 `xorm:"int(11) not null" json:"other_task_id"` OtherTaskID int64 `xorm:"bigint not null" json:"other_task_id"`
// The kind of the relation. // The kind of the relation.
RelationKind RelationKind `xorm:"varchar(50) not null" json:"relation_kind"` RelationKind RelationKind `xorm:"varchar(50) not null" json:"relation_kind"`
CreatedByID int64 `xorm:"int(11) not null" json:"-"` CreatedByID int64 `xorm:"bigint not null" json:"-"`
// The user who created this relation // The user who created this relation
CreatedBy *user.User `xorm:"-" json:"created_by"` CreatedBy *user.User `xorm:"-" json:"created_by"`

View file

@ -36,7 +36,7 @@ import (
// Task represents an task in a todolist // Task represents an task in a todolist
type Task struct { type Task struct {
// The unique, numeric id of this task. // The unique, numeric id of this task.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"listtask"` 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. // 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:"varchar(250) not null" json:"title" valid:"runelength(1|250)" minLength:"1" maxLength:"250"`
// The task description. // The task description.
@ -49,15 +49,15 @@ type Task struct {
DueDate time.Time `xorm:"DATETIME INDEX null 'due_date'" json:"due_date"` DueDate time.Time `xorm:"DATETIME INDEX null 'due_date'" json:"due_date"`
// An array of datetimes when the user wants to be reminded of the task. // An array of datetimes when the user wants to be reminded of the task.
Reminders []time.Time `xorm:"-" json:"reminder_dates"` Reminders []time.Time `xorm:"-" json:"reminder_dates"`
CreatedByID int64 `xorm:"int(11) not null" json:"-"` // ID of the user who put that task on the list CreatedByID int64 `xorm:"bigint not null" json:"-"` // ID of the user who put that task on the list
// The list this task belongs to. // The list this task belongs to.
ListID int64 `xorm:"int(11) INDEX not null" json:"list_id" param:"list"` ListID int64 `xorm:"bigint INDEX not null" json:"list_id" param:"list"`
// An amount in seconds this task repeats itself. If this is set, when marking the task as done, it will mark itself as "undone" and then increase all remindes and the due date by its amount. // An amount in seconds this task repeats itself. If this is set, when marking the task as done, it will mark itself as "undone" and then increase all remindes and the due date by its amount.
RepeatAfter int64 `xorm:"int(11) INDEX null" json:"repeat_after"` RepeatAfter int64 `xorm:"bigint INDEX null" json:"repeat_after"`
// If specified, a repeating task will repeat from the current date rather than the last set date. // If specified, a repeating task will repeat from the current date rather than the last set date.
RepeatFromCurrentDate bool `xorm:"null" json:"repeat_from_current_date"` RepeatFromCurrentDate bool `xorm:"null" json:"repeat_from_current_date"`
// The task priority. Can be anything you want, it is possible to sort by this later. // The task priority. Can be anything you want, it is possible to sort by this later.
Priority int64 `xorm:"int(11) null" json:"priority"` Priority int64 `xorm:"bigint null" json:"priority"`
// When this task starts. // When this task starts.
StartDate time.Time `xorm:"DATETIME INDEX null 'start_date'" json:"start_date" query:"-"` StartDate time.Time `xorm:"DATETIME INDEX null 'start_date'" json:"start_date" query:"-"`
// When this task ends. // When this task ends.
@ -74,7 +74,7 @@ type Task struct {
// The task identifier, based on the list identifier and the task's index // The task identifier, based on the list identifier and the task's index
Identifier string `xorm:"-" json:"identifier"` Identifier string `xorm:"-" json:"identifier"`
// The task index, calculated per list // The task index, calculated per list
Index int64 `xorm:"int(11) not null default 0" json:"index"` Index int64 `xorm:"bigint not null default 0" json:"index"`
// The UID is currently not used for anything other than caldav, which is why we don't expose it over json // The UID is currently not used for anything other than caldav, which is why we don't expose it over json
UID string `xorm:"varchar(250) null" json:"-"` UID string `xorm:"varchar(250) null" json:"-"`
@ -94,7 +94,7 @@ type Task struct {
Updated time.Time `xorm:"updated not null" json:"updated"` Updated time.Time `xorm:"updated not null" json:"updated"`
// BucketID is the ID of the kanban bucket this task belongs to. // BucketID is the ID of the kanban bucket this task belongs to.
BucketID int64 `xorm:"int(11) null" json:"bucket_id"` BucketID int64 `xorm:"bigint null" json:"bucket_id"`
// The position of the task - any task list can be sorted as usual by this parameter. // The position of the task - any task list can be sorted as usual by this parameter.
// When accessing tasks via kanban buckets, this is primarily used to sort them based on a range // When accessing tasks via kanban buckets, this is primarily used to sort them based on a range
@ -118,8 +118,8 @@ func (Task) TableName() string {
// TaskReminder holds a reminder on a task // TaskReminder holds a reminder on a task
type TaskReminder struct { type TaskReminder struct {
ID int64 `xorm:"int(11) autoincr not null unique pk"` ID int64 `xorm:"bigint autoincr not null unique pk"`
TaskID int64 `xorm:"int(11) not null INDEX"` TaskID int64 `xorm:"bigint not null INDEX"`
Reminder time.Time `xorm:"DATETIME not null INDEX 'reminder'"` Reminder time.Time `xorm:"DATETIME not null INDEX 'reminder'"`
Created time.Time `xorm:"created not null"` Created time.Time `xorm:"created not null"`
} }

View file

@ -28,12 +28,12 @@ import (
// Team holds a team object // Team holds a team object
type Team struct { type Team struct {
// The unique, numeric id of this team. // The unique, numeric id of this team.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"team"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"team"`
// The name of this team. // The name of this team.
Name string `xorm:"varchar(250) not null" json:"name" valid:"required,runelength(1|250)" minLength:"1" maxLength:"250"` Name string `xorm:"varchar(250) not null" json:"name" valid:"required,runelength(1|250)" minLength:"1" maxLength:"250"`
// The team's description. // The team's description.
Description string `xorm:"longtext null" json:"description"` Description string `xorm:"longtext null" json:"description"`
CreatedByID int64 `xorm:"int(11) not null INDEX" json:"-"` CreatedByID int64 `xorm:"bigint not null INDEX" json:"-"`
// The user who created this team. // The user who created this team.
CreatedBy *user.User `xorm:"-" json:"created_by"` CreatedBy *user.User `xorm:"-" json:"created_by"`
@ -61,13 +61,13 @@ func (t *Team) AfterLoad() {
// TeamMember defines the relationship between a user and a team // TeamMember defines the relationship between a user and a team
type TeamMember struct { type TeamMember struct {
// The unique, numeric id of this team member relation. // The unique, numeric id of this team member relation.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id"`
// The team id. // The team id.
TeamID int64 `xorm:"int(11) not null INDEX" json:"-" param:"team"` TeamID int64 `xorm:"bigint not null INDEX" json:"-" param:"team"`
// The username of the member. We use this to prevent automated user id entering. // The username of the member. We use this to prevent automated user id entering.
Username string `xorm:"-" json:"username" param:"user"` Username string `xorm:"-" json:"username" param:"user"`
// Used under the hood to manage team members // Used under the hood to manage team members
UserID int64 `xorm:"int(11) not null INDEX" json:"-"` UserID int64 `xorm:"bigint not null INDEX" json:"-"`
// Whether or not the member is an admin of the team. See the docs for more about what a team admin can do // Whether or not the member is an admin of the team. See the docs for more about what a team admin can do
Admin bool `xorm:"null" json:"admin"` Admin bool `xorm:"null" json:"admin"`

View file

@ -24,8 +24,8 @@ import (
// Status represents this migration status // Status represents this migration status
type Status struct { type Status struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id"`
UserID int64 `xorm:"int(11) not null" json:"-"` UserID int64 `xorm:"bigint not null" json:"-"`
MigratorName string `xorm:"varchar(255)" json:"migrator_name"` MigratorName string `xorm:"varchar(255)" json:"migrator_name"`
Created time.Time `xorm:"created not null 'created'" json:"time"` Created time.Time `xorm:"created not null 'created'" json:"time"`
} }

View file

@ -26,8 +26,8 @@ import (
// TOTP holds a user's totp setting in the database. // TOTP holds a user's totp setting in the database.
type TOTP struct { type TOTP struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"-"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"-"`
UserID int64 `xorm:"int(11) not null" json:"-"` UserID int64 `xorm:"bigint not null" json:"-"`
Secret string `xorm:"text not null" json:"secret"` Secret string `xorm:"text not null" json:"secret"`
// The totp entry will only be enabled after the user verified they have a working totp setup. // The totp entry will only be enabled after the user verified they have a working totp setup.
Enabled bool `xorm:"null" json:"enabled"` Enabled bool `xorm:"null" json:"enabled"`

View file

@ -42,7 +42,7 @@ type Login struct {
// User holds information about an user // User holds information about an user
type User struct { type User struct {
// The unique, numeric id of this user. // The unique, numeric id of this user.
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` ID int64 `xorm:"bigint autoincr not null unique pk" json:"id"`
// The full name of the user. // The full name of the user.
Name string `xorm:"text null" json:"name"` Name string `xorm:"text null" json:"name"`
// The username of the user. Is always unique. // The username of the user. Is always unique.