MM-45494: Add endpoint for message history (#20945)

* add api url

* write sql in store

* update app and client golang driver

* update layers and tests

* change sql query sort

* update layers

* fix style

* fix style post_store.go

* fix comments

* add test for app/post_test.go

* update layers

* fix test

* fix style

* fix style again :)

* add permission check

* add additional checks and tests

* change from nil to empty

* update app-layers

* fix style

* add index for OriginalId for Posts table

* fix postgres query

* update migration file names

* update app-layers

* address PR reviews

* write tests for post store

* fix style

* Update file name

* Update file name 2

* Update file name 3

* Update file name 4

* change the error orders

* update migration file name

---------

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Sinan Sonmez (Chaush)
2023-02-07 15:30:37 +01:00
коммит произвёл GitHub
родитель eabf454764
Коммит 50fec7c892
19 изменённых файлов: 433 добавлений и 0 удалений

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

@@ -202,6 +202,8 @@ db/migrations/mysql/000100_add_draft_priority_column.down.sql
db/migrations/mysql/000100_add_draft_priority_column.up.sql
db/migrations/mysql/000101_create_true_up_review_history.down.sql
db/migrations/mysql/000101_create_true_up_review_history.up.sql
db/migrations/mysql/000102_posts_originalid_index.down.sql
db/migrations/mysql/000102_posts_originalid_index.up.sql
db/migrations/postgres/000001_create_teams.down.sql
db/migrations/postgres/000001_create_teams.up.sql
db/migrations/postgres/000002_create_team_members.down.sql
@@ -404,3 +406,5 @@ db/migrations/postgres/000100_add_draft_priority_column.down.sql
db/migrations/postgres/000100_add_draft_priority_column.up.sql
db/migrations/postgres/000101_create_true_up_review_history.down.sql
db/migrations/postgres/000101_create_true_up_review_history.up.sql
db/migrations/postgres/000102_posts_originalid_index.down.sql
db/migrations/postgres/000102_posts_originalid_index.up.sql

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

@@ -0,0 +1,14 @@
SET @preparedStatement = (SELECT IF(
(
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_name = 'Posts'
AND table_schema = DATABASE()
AND index_name = 'idx_posts_original_id'
) > 0,
'DROP INDEX idx_posts_original_id on Posts;',
'SELECT 1;'
));
PREPARE removeIndexIfExists FROM @preparedStatement;
EXECUTE removeIndexIfExists;
DEALLOCATE PREPARE removeIndexIfExists;

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

@@ -0,0 +1,14 @@
SET @preparedStatement = (SELECT IF(
(
SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_name = 'Posts'
AND table_schema = DATABASE()
AND index_name = 'idx_posts_original_id'
) > 0,
'SELECT 1;',
'CREATE INDEX idx_posts_original_id on Posts(OriginalId);'
));
PREPARE createIndexIfNotExists FROM @preparedStatement;
EXECUTE createIndexIfNotExists;
DEALLOCATE PREPARE createIndexIfNotExists;

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

@@ -0,0 +1 @@
DROP INDEX IF EXISTS idx_posts_original_id;

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

@@ -0,0 +1 @@
CREATE INDEX IF NOT EXISTS idx_posts_original_id ON Posts(originalid);