BoR scheduled posts and drafts DB migrations (#9352)
* Added type column to scheduled post and draft table * removed console log * fixed a test * fixes * Restored ununtended changes * Code uniformity
This commit is contained in:
parent
31fc648e50
commit
c42ebca8d3
14 changed files with 63 additions and 5 deletions
|
|
@ -25,6 +25,23 @@ const {
|
|||
const {PLAYBOOK_RUN, PLAYBOOK_CHECKLIST, PLAYBOOK_CHECKLIST_ITEM, PLAYBOOK_RUN_ATTRIBUTE, PLAYBOOK_RUN_ATTRIBUTE_VALUE} = PLAYBOOK_TABLES;
|
||||
|
||||
export default schemaMigrations({migrations: [
|
||||
{
|
||||
toVersion: 16,
|
||||
steps: [
|
||||
addColumns({
|
||||
table: SCHEDULED_POST,
|
||||
columns: [
|
||||
{name: 'type', type: 'string', isOptional: true},
|
||||
],
|
||||
}),
|
||||
addColumns({
|
||||
table: DRAFT,
|
||||
columns: [
|
||||
{name: 'type', type: 'string', isOptional: true},
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
toVersion: 15,
|
||||
steps: [
|
||||
|
|
|
|||
|
|
@ -44,4 +44,7 @@ export default class DraftModel extends Model implements DraftModelInterface {
|
|||
|
||||
/** update_at : The timestamp to when this post was last updated on the server */
|
||||
@field('update_at') updateAt!: number;
|
||||
|
||||
/** type : The type of post */
|
||||
@field('type') type!: PostTypesUserCreatable | null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,9 @@ export default class ScheduledPostModel extends Model implements ScheduledPostMo
|
|||
/** error_code : The reason message if the schedule post failed */
|
||||
@field('error_code') errorCode!: string;
|
||||
|
||||
/** type : The type of the post being scheduled */
|
||||
@field('type') type!: PostTypesUserCreatable | null;
|
||||
|
||||
toApi = (user_id: string) => {
|
||||
const scheduledPost: ScheduledPost = {
|
||||
id: this.id,
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@ export const transformSchedulePostsRecord = ({action, database, value}: Transfor
|
|||
scheduledPost.scheduledAt = raw.scheduled_at;
|
||||
scheduledPost.processedAt = raw.processed_at ?? 0;
|
||||
scheduledPost.errorCode = raw.error_code || scheduledPost.errorCode;
|
||||
scheduledPost.type = raw.type || '';
|
||||
};
|
||||
|
||||
return prepareBaseRecord({
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import {
|
|||
} from './table_schemas';
|
||||
|
||||
export const serverSchema: AppSchema = appSchema({
|
||||
version: 15,
|
||||
version: 16,
|
||||
tables: [
|
||||
CategorySchema,
|
||||
CategoryChannelSchema,
|
||||
|
|
|
|||
|
|
@ -16,5 +16,6 @@ export default tableSchema({
|
|||
{name: 'root_id', type: 'string', isIndexed: true},
|
||||
{name: 'metadata', type: 'string', isOptional: true},
|
||||
{name: 'update_at', type: 'number'},
|
||||
{name: 'type', type: 'string', isOptional: true},
|
||||
],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,5 +20,6 @@ export default tableSchema({
|
|||
{name: 'scheduled_at', type: 'number'},
|
||||
{name: 'processed_at', type: 'number'},
|
||||
{name: 'error_code', type: 'string'},
|
||||
{name: 'type', type: 'string', isOptional: true},
|
||||
],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ const {PLAYBOOK_RUN, PLAYBOOK_CHECKLIST, PLAYBOOK_CHECKLIST_ITEM, PLAYBOOK_RUN_A
|
|||
describe('*** Test schema for SERVER database ***', () => {
|
||||
it('=> The SERVER SCHEMA should strictly match', () => {
|
||||
expect(serverSchema).toEqual({
|
||||
version: 15,
|
||||
version: 16,
|
||||
unsafeSql: undefined,
|
||||
tables: {
|
||||
[CATEGORY]: {
|
||||
|
|
@ -317,6 +317,7 @@ describe('*** Test schema for SERVER database ***', () => {
|
|||
root_id: {name: 'root_id', type: 'string', isIndexed: true},
|
||||
metadata: {name: 'metadata', type: 'string', isOptional: true},
|
||||
update_at: {name: 'update_at', type: 'number'},
|
||||
type: {name: 'type', type: 'string', isOptional: true},
|
||||
},
|
||||
columnArray: [
|
||||
{name: 'channel_id', type: 'string', isIndexed: true},
|
||||
|
|
@ -325,6 +326,7 @@ describe('*** Test schema for SERVER database ***', () => {
|
|||
{name: 'root_id', type: 'string', isIndexed: true},
|
||||
{name: 'metadata', type: 'string', isOptional: true},
|
||||
{name: 'update_at', type: 'number'},
|
||||
{name: 'type', type: 'string', isOptional: true},
|
||||
],
|
||||
},
|
||||
[FILE]: {
|
||||
|
|
@ -717,6 +719,7 @@ describe('*** Test schema for SERVER database ***', () => {
|
|||
scheduled_at: {name: 'scheduled_at', type: 'number'},
|
||||
processed_at: {name: 'processed_at', type: 'number'},
|
||||
error_code: {name: 'error_code', type: 'string'},
|
||||
type: {name: 'type', type: 'string', isOptional: true},
|
||||
},
|
||||
columnArray: [
|
||||
{name: 'channel_id', type: 'string', isIndexed: true},
|
||||
|
|
@ -729,6 +732,7 @@ describe('*** Test schema for SERVER database ***', () => {
|
|||
{name: 'scheduled_at', type: 'number'},
|
||||
{name: 'processed_at', type: 'number'},
|
||||
{name: 'error_code', type: 'string'},
|
||||
{name: 'type', type: 'string', isOptional: true},
|
||||
],
|
||||
},
|
||||
[SYSTEM]: {
|
||||
|
|
|
|||
|
|
@ -95,6 +95,23 @@ channel_id string INDEX FK >- Channel.id
|
|||
files string #stringify (array)
|
||||
message string
|
||||
root_id string INDEX NULL FK >- Post.id
|
||||
type string NULL
|
||||
|
||||
|
||||
ScheduledPost
|
||||
-
|
||||
id PK string # auto-generated
|
||||
channel_id string INDEX FK >- Channel.id
|
||||
files string #stringify (array)
|
||||
message string
|
||||
root_id string INDEX NULL FK >- Post.id
|
||||
metadata string NULL
|
||||
create_at number
|
||||
update_at number
|
||||
scheduled_at number
|
||||
processed_at number NULL
|
||||
error_code string
|
||||
type string NULL
|
||||
|
||||
|
||||
File
|
||||
|
|
|
|||
|
|
@ -652,6 +652,7 @@ class TestHelperSingleton {
|
|||
files: [],
|
||||
metadata: {},
|
||||
updateAt: 0,
|
||||
type: '',
|
||||
...overwrite,
|
||||
};
|
||||
};
|
||||
|
|
@ -880,6 +881,7 @@ class TestHelperSingleton {
|
|||
scheduledAt: 0,
|
||||
processedAt: 0,
|
||||
errorCode: '',
|
||||
type: '',
|
||||
toApi: jest.fn(),
|
||||
...overwrite,
|
||||
};
|
||||
|
|
|
|||
8
types/api/posts.d.ts
vendored
8
types/api/posts.d.ts
vendored
|
|
@ -1,8 +1,11 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
type PostType =
|
||||
type PostTypesUserCreatable =
|
||||
| ''
|
||||
| 'burn_on_read';
|
||||
|
||||
type PostType = PostTypesUserCreatable
|
||||
| 'system_add_remove'
|
||||
| 'system_add_to_channel'
|
||||
| 'system_add_to_team'
|
||||
|
|
@ -30,8 +33,7 @@ type PostType =
|
|||
| 'custom_calls_recording'
|
||||
| 'custom_run_update'
|
||||
| 'custom_llmbot'
|
||||
| 'custom_llm_postback'
|
||||
| 'burn_on_read';
|
||||
| 'custom_llm_postback';
|
||||
|
||||
type PostEmbedType = 'image' | 'message_attachment' | 'opengraph' | 'permalink';
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ declare class DraftModel extends Model {
|
|||
|
||||
/** update_at : The timestamp to when this post was last updated on the server */
|
||||
updateAt: number;
|
||||
|
||||
/** type : The post type of draft */
|
||||
type: string | null;
|
||||
}
|
||||
|
||||
export default DraftModel;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ declare class ScheduledPostModel extends Model {
|
|||
/** error_code : The reason message if the schedule post failed */
|
||||
errorCode: string;
|
||||
|
||||
/** type : The post type of draft */
|
||||
type: string | null;
|
||||
|
||||
toApi: (user_id: string) => ScheduledPost;
|
||||
}
|
||||
|
||||
|
|
|
|||
1
types/database/raw_values.d.ts
vendored
1
types/database/raw_values.d.ts
vendored
|
|
@ -24,6 +24,7 @@ type Draft = {
|
|||
root_id: string;
|
||||
metadata?: PostMetadata;
|
||||
update_at: number;
|
||||
type?: string;
|
||||
};
|
||||
|
||||
type MyTeam = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue