Dnd remove default column value (#4337)

* Revert "Revert dnd (#4294)"

This reverts commit 9fac8f476e.

* removed default value of new column for DND

* Used a column function, and collases for default value

* fix bad merge

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
This commit is contained in:
Harshil Sharma 2022-12-20 03:07:51 +05:30 committed by GitHub
parent 8927592c57
commit 78ac6924e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View file

@ -13,9 +13,24 @@ import (
const categorySortOrderGap = 10
func (s *SQLStore) categoryFields() []string {
return []string{
"id",
"name",
"user_id",
"team_id",
"create_at",
"update_at",
"delete_at",
"collapsed",
"COALESCE(sort_order, 0)",
"type",
}
}
func (s *SQLStore) getCategory(db sq.BaseRunner, id string) (*model.Category, error) {
query := s.getQueryBuilder(db).
Select("id", "name", "user_id", "team_id", "create_at", "update_at", "delete_at", "collapsed", "sort_order", "type").
Select(s.categoryFields()...).
From(s.tablePrefix + "categories").
Where(sq.Eq{"id": id})
@ -149,7 +164,7 @@ func (s *SQLStore) deleteCategory(db sq.BaseRunner, categoryID, userID, teamID s
func (s *SQLStore) getUserCategories(db sq.BaseRunner, userID, teamID string) ([]model.Category, error) {
query := s.getQueryBuilder(db).
Select("id", "name", "user_id", "team_id", "create_at", "update_at", "delete_at", "collapsed", "sort_order", "type").
Select(s.categoryFields()...).
From(s.tablePrefix+"categories").
Where(sq.Eq{
"user_id": userID,

View file

@ -1,2 +1,2 @@
{{- /* addColumnIfNeeded tableName columnName datatype constraint */ -}}
{{ addColumnIfNeeded "categories" "sort_order" "BIGINT" "DEFAULT 0"}}
{{ addColumnIfNeeded "categories" "sort_order" "BIGINT" ""}}

View file

@ -1,3 +1,2 @@
{{- /* addColumnIfNeeded tableName columnName datatype constraint */ -}}
{{ addColumnIfNeeded "category_boards" "sort_order" "BIGINT" "DEFAULT 0"}}
{{ addColumnIfNeeded "category_boards" "sort_order" "BIGINT" ""}}