Ensure consistent naming of title fields #528

Merged
konrad merged 8 commits from fix/title-fields into master 2020-05-16 10:17:47 +00:00
2 changed files with 70 additions and 0 deletions
Showing only changes of commit 36097f792d - Show all commits

View File

@ -17,6 +17,7 @@
package migration
import (
"code.vikunja.io/api/pkg/config"
"src.techknowlogick.com/xormigrate"
"xorm.io/xorm"
)
@ -70,6 +71,46 @@ func init() {
return err
}
// sqlite is not able to drop columns. To have inserting new tasks still work, we drop the column manually.
if config.DatabaseType.GetString() == "sqlite" {
_, err = tx.Exec(`
create table tasks_dg_tmp
(
id INTEGER not null
primary key autoincrement,
description TEXT,
done INTEGER,
done_at_unix INTEGER,
due_date_unix INTEGER,
created_by_id INTEGER not null,
list_id INTEGER not null,
repeat_after INTEGER,
priority INTEGER,
start_date_unix INTEGER,
end_date_unix INTEGER,
hex_color TEXT,
percent_done REAL,
"index" INTEGER default 0 not null,
uid TEXT,
created INTEGER not null,
updated INTEGER not null,
bucket_id INTEGER,
position REAL,
title TEXT
);
insert into tasks_dg_tmp(id, description, done, done_at_unix, due_date_unix, created_by_id, list_id, repeat_after, priority, start_date_unix, end_date_unix, hex_color, percent_done, "index", uid, created, updated, bucket_id, position, title) select id, description, done, done_at_unix, due_date_unix, created_by_id, list_id, repeat_after, priority, start_date_unix, end_date_unix, hex_color, percent_done, "index", uid, created, updated, bucket_id, position, title from tasks;
drop table tasks;
alter table tasks_dg_tmp rename to tasks;
create unique index tasks_id_uindex
on tasks (id);
`)
return err
}
return dropTableColum(tx, "tasks", "text")
},
Rollback: func(tx *xorm.Engine) error {

View File

@ -17,6 +17,7 @@
package migration
import (
"code.vikunja.io/api/pkg/config"
"src.techknowlogick.com/xormigrate"
"xorm.io/xorm"
)
@ -70,6 +71,34 @@ func init() {
return err
}
// sqlite is not able to drop columns. To have inserting new namespaces still work, we drop the column manually.
if config.DatabaseType.GetString() == "sqlite" {
_, err = tx.Exec(`
create table namespaces_dg_tmp
(
id INTEGER not null
primary key autoincrement,
description TEXT,
owner_id INTEGER not null,
created INTEGER not null,
updated INTEGER not null,
is_archived INTEGER default 0 not null,
hex_color TEXT,
title TEXT
);
insert into namespaces_dg_tmp(id, description, owner_id, created, updated, is_archived, hex_color, title) select id, description, owner_id, created, updated, is_archived, hex_color, title from namespaces;
drop table namespaces;
alter table namespaces_dg_tmp rename to namespaces;
create unique index UQE_namespaces_id
on namespaces (id);
`)
return err
}
return dropTableColum(tx, "namespaces", "name")
},
Rollback: func(tx *xorm.Engine) error {