Added Archived column to FileInfo (#20164)
* Added Archived column to FileInfo * fixed typo * Added new column to store column list * Fixing tests * Updated migration number to syncup with master
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c100fc2135
Коммит
b13d5e7466
14
db/migrations/mysql/000085_fileinfo_add_archived_column.down.sql
Обычный файл
14
db/migrations/mysql/000085_fileinfo_add_archived_column.down.sql
Обычный файл
@@ -0,0 +1,14 @@
|
|||||||
|
SET @preparedStatement = (SELECT IF(
|
||||||
|
(
|
||||||
|
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE table_name = 'FileInfo'
|
||||||
|
AND table_schema = DATABASE()
|
||||||
|
AND column_name = 'Archived'
|
||||||
|
) > 0,
|
||||||
|
'ALTER TABLE FileInfo DROP COLUMN Archived;',
|
||||||
|
'SELECT 1'
|
||||||
|
));
|
||||||
|
|
||||||
|
PREPARE alterIfExists FROM @preparedStatement;
|
||||||
|
EXECUTE alterIfExists;
|
||||||
|
DEALLOCATE PREPARE alterIfExists;
|
||||||
15
db/migrations/mysql/000085_fileinfo_add_archived_column.up.sql
Обычный файл
15
db/migrations/mysql/000085_fileinfo_add_archived_column.up.sql
Обычный файл
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
SET @preparedStatement = (SELECT IF(
|
||||||
|
(
|
||||||
|
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE table_name = 'FileInfo'
|
||||||
|
AND table_schema = DATABASE()
|
||||||
|
AND column_name = 'Archived'
|
||||||
|
) > 0,
|
||||||
|
'SELECT 1',
|
||||||
|
'ALTER TABLE FileInfo ADD COLUMN Archived boolean NOT NULL DEFAULT false;'
|
||||||
|
));
|
||||||
|
|
||||||
|
PREPARE alterIfExists FROM @preparedStatement;
|
||||||
|
EXECUTE alterIfExists;
|
||||||
|
DEALLOCATE PREPARE alterIfExists;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE fileinfo DROP COLUMN IF EXISTS archived;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE fileinfo ADD COLUMN IF NOT EXISTS archived boolean NOT NULL DEFAULT false;
|
||||||
@@ -55,6 +55,7 @@ type FileInfo struct {
|
|||||||
MiniPreview *[]byte `json:"mini_preview"` // declared as *[]byte to avoid postgres/mysql differences in deserialization
|
MiniPreview *[]byte `json:"mini_preview"` // declared as *[]byte to avoid postgres/mysql differences in deserialization
|
||||||
Content string `json:"-"`
|
Content string `json:"-"`
|
||||||
RemoteId *string `json:"remote_id"`
|
RemoteId *string `json:"remote_id"`
|
||||||
|
Archived bool `json:"archived"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fi *FileInfo) PreSave() {
|
func (fi *FileInfo) PreSave() {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ type fileInfoWithChannelID struct {
|
|||||||
MiniPreview *[]byte
|
MiniPreview *[]byte
|
||||||
Content string
|
Content string
|
||||||
RemoteId *string
|
RemoteId *string
|
||||||
|
Archived bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fi fileInfoWithChannelID) ToModel() *model.FileInfo {
|
func (fi fileInfoWithChannelID) ToModel() *model.FileInfo {
|
||||||
@@ -103,6 +104,7 @@ func newSqlFileInfoStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterfac
|
|||||||
"FileInfo.MiniPreview",
|
"FileInfo.MiniPreview",
|
||||||
"Coalesce(FileInfo.Content, '') AS Content",
|
"Coalesce(FileInfo.Content, '') AS Content",
|
||||||
"Coalesce(FileInfo.RemoteId, '') AS RemoteId",
|
"Coalesce(FileInfo.RemoteId, '') AS RemoteId",
|
||||||
|
"FileInfo.Archived",
|
||||||
}
|
}
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user