diff --git a/docs/content/doc/practical-instructions/swagger-docs.md b/docs/content/doc/practical-instructions/swagger-docs.md index 0ae86db99..3e6370476 100644 --- a/docs/content/doc/practical-instructions/swagger-docs.md +++ b/docs/content/doc/practical-instructions/swagger-docs.md @@ -23,13 +23,13 @@ As an example, this is the definition of a list with all comments: // List represents a list of tasks type List struct { // 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. Title string `xorm:"varchar(250)" json:"title" valid:"required,runelength(3|250)" minLength:"3" maxLength:"250"` // The description of the list. Description string `xorm:"varchar(1000)" json:"description" valid:"runelength(0|1000)" maxLength:"1000"` - OwnerID int64 `xorm:"int(11) INDEX" json:"-"` - NamespaceID int64 `xorm:"int(11) INDEX" json:"-" param:"namespace"` + OwnerID int64 `xorm:"bigint INDEX" json:"-"` + NamespaceID int64 `xorm:"bigint INDEX" json:"-" param:"namespace"` // The user who created this list. Owner User `xorm:"-" json:"owner" valid:"-"` diff --git a/pkg/files/files.go b/pkg/files/files.go index 9145f4c99..d2c290fdd 100644 --- a/pkg/files/files.go +++ b/pkg/files/files.go @@ -29,13 +29,13 @@ import ( // File holds all information about a file 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"` 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"` - CreatedByID int64 `xorm:"int(11) not null" json:"-"` + CreatedByID int64 `xorm:"bigint not null" json:"-"` File afero.File `xorm:"-" json:"-"` // This ReadCloser is only used for migration purposes. Use with care! diff --git a/pkg/migration/20201218152741.go b/pkg/migration/20201218152741.go new file mode 100644 index 000000000..ebb0b7a71 --- /dev/null +++ b/pkg/migration/20201218152741.go @@ -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 . + +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 + }, + }) +} diff --git a/pkg/models/kanban.go b/pkg/models/kanban.go index 3242b8f8f..af4667e39 100644 --- a/pkg/models/kanban.go +++ b/pkg/models/kanban.go @@ -28,11 +28,11 @@ import ( // Bucket represents a kanban bucket type Bucket struct { // 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. Title string `xorm:"text not null" valid:"required" minLength:"1" json:"title"` // 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. Tasks []*Task `xorm:"-" json:"tasks"` @@ -46,7 +46,7 @@ type Bucket struct { // The user who initially created the bucket. 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.CRUDable `xorm:"-" json:"-"` diff --git a/pkg/models/label.go b/pkg/models/label.go index 414b4a2d8..9786c0449 100644 --- a/pkg/models/label.go +++ b/pkg/models/label.go @@ -26,7 +26,7 @@ import ( // Label represents a label type Label struct { // 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. Title string `xorm:"varchar(250) not null" json:"title" valid:"runelength(1|250)" minLength:"1" maxLength:"250"` // The label description. @@ -34,7 +34,7 @@ type Label struct { // The color this label has 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 CreatedBy *user.User `xorm:"-" json:"created_by"` diff --git a/pkg/models/label_task.go b/pkg/models/label_task.go index 7d0614d66..57fae608c 100644 --- a/pkg/models/label_task.go +++ b/pkg/models/label_task.go @@ -27,10 +27,10 @@ import ( // LabelTask represents a relation between a label and a task type LabelTask struct { // The unique, numeric id of this label. - ID int64 `xorm:"int(11) autoincr not null unique pk" json:"-"` - TaskID int64 `xorm:"int(11) INDEX not null" json:"-" param:"listtask"` + ID int64 `xorm:"bigint autoincr not null unique pk" json:"-"` + TaskID int64 `xorm:"bigint INDEX not null" json:"-" param:"listtask"` // 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. Created time.Time `xorm:"created not null" json:"created"` diff --git a/pkg/models/link_sharing.go b/pkg/models/link_sharing.go index 7fc85c7dc..608240fb2 100644 --- a/pkg/models/link_sharing.go +++ b/pkg/models/link_sharing.go @@ -39,20 +39,20 @@ const ( // LinkSharing represents a shared list type LinkSharing struct { // 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 Hash string `xorm:"varchar(40) not null unique" json:"hash" param:"hash"` // 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. - 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). - 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 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. Created time.Time `xorm:"created not null" json:"created"` diff --git a/pkg/models/list.go b/pkg/models/list.go index 8b61dad1d..fa5cbe98e 100644 --- a/pkg/models/list.go +++ b/pkg/models/list.go @@ -30,7 +30,7 @@ import ( // List represents a list of tasks type List struct { // 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. Title string `xorm:"varchar(250) not null" json:"title" valid:"required,runelength(1|250)" minLength:"1" maxLength:"250"` // The description of the list. @@ -40,8 +40,8 @@ type List struct { // The hex color of this list HexColor string `xorm:"varchar(6) null" json:"hex_color" valid:"runelength(0|6)" maxLength:"6"` - OwnerID int64 `xorm:"int(11) INDEX not null" json:"-"` - NamespaceID int64 `xorm:"int(11) INDEX not null" json:"namespace_id" param:"namespace"` + OwnerID int64 `xorm:"bigint INDEX not null" json:"-"` + NamespaceID int64 `xorm:"bigint INDEX not null" json:"namespace_id" param:"namespace"` // The user who created this list. Owner *user.User `xorm:"-" json:"owner" valid:"-"` diff --git a/pkg/models/list_team.go b/pkg/models/list_team.go index db36d9e0e..371e267ca 100644 --- a/pkg/models/list_team.go +++ b/pkg/models/list_team.go @@ -25,13 +25,13 @@ import ( // TeamList defines the relation between a team and a list type TeamList struct { // 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. - 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. - 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. - 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. Created time.Time `xorm:"created not null" json:"created"` diff --git a/pkg/models/list_users.go b/pkg/models/list_users.go index ce139e1dc..b9ada17f8 100644 --- a/pkg/models/list_users.go +++ b/pkg/models/list_users.go @@ -26,15 +26,15 @@ import ( // ListUser represents a list <-> user relation type ListUser struct { // 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. Username string `xorm:"-" json:"user_id" param:"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. - 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. - 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. Created time.Time `xorm:"created not null" json:"created"` diff --git a/pkg/models/namespace.go b/pkg/models/namespace.go index c6acd6574..5c767b816 100644 --- a/pkg/models/namespace.go +++ b/pkg/models/namespace.go @@ -30,12 +30,12 @@ import ( // Namespace holds informations about a namespace type Namespace struct { // 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. Title string `xorm:"varchar(250) not null" json:"title" valid:"required,runelength(1|250)" minLength:"1" maxLength:"250"` // The description of the namespace 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 HexColor string `xorm:"varchar(6) null" json:"hex_color" valid:"runelength(0|6)" maxLength:"6"` diff --git a/pkg/models/namespace_team.go b/pkg/models/namespace_team.go index 417e27e14..f249e2e50 100644 --- a/pkg/models/namespace_team.go +++ b/pkg/models/namespace_team.go @@ -25,13 +25,13 @@ import ( // TeamNamespace defines the relationship between a Team and a Namespace type TeamNamespace struct { // 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. - 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. - 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. - 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. Created time.Time `xorm:"created not null" json:"created"` diff --git a/pkg/models/namespace_users.go b/pkg/models/namespace_users.go index 8b69630f4..119d0f60f 100644 --- a/pkg/models/namespace_users.go +++ b/pkg/models/namespace_users.go @@ -26,14 +26,14 @@ import ( // NamespaceUser represents a namespace <-> user relation type NamespaceUser struct { // 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. 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 - 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. - 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. Created time.Time `xorm:"created not null" json:"created"` diff --git a/pkg/models/saved_filters.go b/pkg/models/saved_filters.go index d3d081da6..97ab4f85e 100644 --- a/pkg/models/saved_filters.go +++ b/pkg/models/saved_filters.go @@ -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"` // The description of the filter 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 Owner *user.User `xorm:"-" json:"owner" valid:"-"` diff --git a/pkg/models/task_assignees.go b/pkg/models/task_assignees.go index bb103322b..cbf0f7fea 100644 --- a/pkg/models/task_assignees.go +++ b/pkg/models/task_assignees.go @@ -26,9 +26,9 @@ import ( // TaskAssginee represents an assignment of a user to a task type TaskAssginee struct { - ID int64 `xorm:"int(11) autoincr not null unique pk" json:"-"` - TaskID int64 `xorm:"int(11) INDEX not null" json:"-" param:"listtask"` - UserID int64 `xorm:"int(11) INDEX not null" json:"user_id" param:"user"` + ID int64 `xorm:"bigint autoincr not null unique pk" json:"-"` + TaskID int64 `xorm:"bigint INDEX not null" json:"-" param:"listtask"` + UserID int64 `xorm:"bigint INDEX not null" json:"user_id" param:"user"` Created time.Time `xorm:"created not null"` web.CRUDable `xorm:"-" json:"-"` diff --git a/pkg/models/task_attachment.go b/pkg/models/task_attachment.go index ac0d72927..a55fd6112 100644 --- a/pkg/models/task_attachment.go +++ b/pkg/models/task_attachment.go @@ -27,11 +27,11 @@ import ( // TaskAttachment is the definition of a task attachment type TaskAttachment struct { - ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"attachment"` - TaskID int64 `xorm:"int(11) not null" json:"task_id" param:"task"` - FileID int64 `xorm:"int(11) not null" json:"-"` + ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"attachment"` + TaskID int64 `xorm:"bigint not null" json:"task_id" param:"task"` + 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"` File *files.File `xorm:"-" json:"file"` diff --git a/pkg/models/task_relation.go b/pkg/models/task_relation.go index 4372e2eaf..6ab162ff4 100644 --- a/pkg/models/task_relation.go +++ b/pkg/models/task_relation.go @@ -76,15 +76,15 @@ func (rk RelationKind) isValid() bool { // TaskRelation represents a kind of relation between two tasks type TaskRelation struct { // 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. - 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. - 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. 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 CreatedBy *user.User `xorm:"-" json:"created_by"` diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 58be285e7..44adbd551 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -36,7 +36,7 @@ import ( // Task represents an task in a todolist type Task struct { // 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. Title string `xorm:"varchar(250) not null" json:"title" valid:"runelength(1|250)" minLength:"1" maxLength:"250"` // The task description. @@ -49,15 +49,15 @@ type Task struct { 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. 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. - 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. - 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. 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. - Priority int64 `xorm:"int(11) null" json:"priority"` + Priority int64 `xorm:"bigint null" json:"priority"` // When this task starts. StartDate time.Time `xorm:"DATETIME INDEX null 'start_date'" json:"start_date" query:"-"` // When this task ends. @@ -74,7 +74,7 @@ type Task struct { // The task identifier, based on the list identifier and the task's index Identifier string `xorm:"-" json:"identifier"` // 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 UID string `xorm:"varchar(250) null" json:"-"` @@ -94,7 +94,7 @@ type Task struct { Updated time.Time `xorm:"updated not null" json:"updated"` // 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. // 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 type TaskReminder struct { - ID int64 `xorm:"int(11) autoincr not null unique pk"` - TaskID int64 `xorm:"int(11) not null INDEX"` + ID int64 `xorm:"bigint autoincr not null unique pk"` + TaskID int64 `xorm:"bigint not null INDEX"` Reminder time.Time `xorm:"DATETIME not null INDEX 'reminder'"` Created time.Time `xorm:"created not null"` } diff --git a/pkg/models/teams.go b/pkg/models/teams.go index dbf188170..b7c40c9ea 100644 --- a/pkg/models/teams.go +++ b/pkg/models/teams.go @@ -28,12 +28,12 @@ import ( // Team holds a team object type Team struct { // 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. Name string `xorm:"varchar(250) not null" json:"name" valid:"required,runelength(1|250)" minLength:"1" maxLength:"250"` // The team's 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. 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 type TeamMember struct { // 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. - 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. Username string `xorm:"-" json:"username" param:"user"` // 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 Admin bool `xorm:"null" json:"admin"` diff --git a/pkg/modules/migration/migration_status.go b/pkg/modules/migration/migration_status.go index a319ee7aa..be893db35 100644 --- a/pkg/modules/migration/migration_status.go +++ b/pkg/modules/migration/migration_status.go @@ -24,8 +24,8 @@ import ( // Status represents this migration status type Status struct { - ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` - UserID int64 `xorm:"int(11) not null" json:"-"` + ID int64 `xorm:"bigint autoincr not null unique pk" json:"id"` + UserID int64 `xorm:"bigint not null" json:"-"` MigratorName string `xorm:"varchar(255)" json:"migrator_name"` Created time.Time `xorm:"created not null 'created'" json:"time"` } diff --git a/pkg/user/totp.go b/pkg/user/totp.go index b5c29c2e7..c8b6a1636 100644 --- a/pkg/user/totp.go +++ b/pkg/user/totp.go @@ -26,8 +26,8 @@ import ( // TOTP holds a user's totp setting in the database. type TOTP struct { - ID int64 `xorm:"int(11) autoincr not null unique pk" json:"-"` - UserID int64 `xorm:"int(11) not null" json:"-"` + ID int64 `xorm:"bigint autoincr not null unique pk" json:"-"` + UserID int64 `xorm:"bigint not null" json:"-"` 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. Enabled bool `xorm:"null" json:"enabled"` diff --git a/pkg/user/user.go b/pkg/user/user.go index b655da870..394d5d18d 100644 --- a/pkg/user/user.go +++ b/pkg/user/user.go @@ -42,7 +42,7 @@ type Login struct { // User holds information about an user type User struct { // 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. Name string `xorm:"text null" json:"name"` // The username of the user. Is always unique.