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
Этот коммит содержится в:
Harshil Sharma
2022-05-23 12:15:56 +05:30
коммит произвёл GitHub
родитель c100fc2135
Коммит b13d5e7466
6 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@@ -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;

Просмотреть файл

@@ -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
Content string `json:"-"`
RemoteId *string `json:"remote_id"`
Archived bool `json:"archived"`
}
func (fi *FileInfo) PreSave() {

Просмотреть файл

@@ -41,6 +41,7 @@ type fileInfoWithChannelID struct {
MiniPreview *[]byte
Content string
RemoteId *string
Archived bool
}
func (fi fileInfoWithChannelID) ToModel() *model.FileInfo {
@@ -103,6 +104,7 @@ func newSqlFileInfoStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterfac
"FileInfo.MiniPreview",
"Coalesce(FileInfo.Content, '') AS Content",
"Coalesce(FileInfo.RemoteId, '') AS RemoteId",
"FileInfo.Archived",
}
return s