Gekidou - Updated Server Database Diagrams/Schema/Models (#6119)

* started with the diagrams

* removed redundant tables

next step:
1. reconstruct id ( local id vs server id )
2. annotate fields with examples
3. recreate relationship

* work in progress

* work in progress

* fix association

* update postsInChannel

* removed SlashCommands from the Server database schema

* added missing associations in the models and updated docs/database

* exported server database

* update test

* code corrections following review

* update relationship

* update docs

* removed cyclic relationship

* Revert "removed cyclic relationship"

This reverts commit 4d784efb81.

* removed isOptional from Draft

* linked myChannelSettings to myChannel instead of Channel

* update diagrams

* store null instead of empty string

* update thread association

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Avinash Lingaloo
2022-04-07 18:14:28 +04:00
committed by GitHub
parent ae3c9e2ef2
commit 9a72837f04
38 changed files with 987 additions and 95 deletions

View File

@@ -32,10 +32,11 @@ export default class CategoryModel extends Model implements CategoryInterface {
/** associations : Describes every relationship to this table. */
static associations: Associations = {
/** A CATEGORY has a 1:N relationship with CHANNEL. A CATEGORY can possess multiple channels */
/** A CHANNEL can belong to several CATEGORY, and a CATEGORY posses multiple channels (N:N relationship).
* We use the intermediate table CATEGORY_CHANNEL for this relationship */
[CATEGORY_CHANNEL]: {type: 'has_many', foreignKey: 'category_id'},
/** A TEAM can be associated to CATEGORY (relationship is 1:N) */
/** A Category belongs to a Team, and a Team can have several categories (relationship 1:N) */
[TEAM]: {type: 'belongs_to', key: 'team_id'},
};

View File

@@ -13,7 +13,6 @@ import type ChannelInfoModel from '@typings/database/models/servers/channel_info
import type ChannelMembershipModel from '@typings/database/models/servers/channel_membership';
import type DraftModel from '@typings/database/models/servers/draft';
import type MyChannelModel from '@typings/database/models/servers/my_channel';
import type MyChannelSettingsModel from '@typings/database/models/servers/my_channel_settings';
import type PostModel from '@typings/database/models/servers/post';
import type PostsInChannelModel from '@typings/database/models/servers/posts_in_channel';
import type TeamModel from '@typings/database/models/servers/team';
@@ -26,7 +25,6 @@ const {
CHANNEL_MEMBERSHIP,
DRAFT,
MY_CHANNEL,
MY_CHANNEL_SETTINGS,
POSTS_IN_CHANNEL,
POST,
TEAM,
@@ -46,7 +44,7 @@ export default class ChannelModel extends Model implements ChannelModelInterface
/** A CHANNEL can be associated with multiple CHANNEL_MEMBERSHIP (relationship is 1:N) */
[CHANNEL_MEMBERSHIP]: {type: 'has_many', foreignKey: 'channel_id'},
/** A CHANNEL can be associated with multiple CATEGORY_CHANNEL (relationship is 1:N) */
/** A CHANNEL can be associated with one CATEGORY_CHANNEL per team (relationship is 1:1) */
[CATEGORY_CHANNEL]: {type: 'has_many', foreignKey: 'channel_id'},
/** A CHANNEL can be associated with multiple DRAFT (relationship is 1:N) */
@@ -66,6 +64,10 @@ export default class ChannelModel extends Model implements ChannelModelInterface
/** A USER can create multiple CHANNEL (relationship is 1:N) */
[USER]: {type: 'belongs_to', key: 'creator_id'},
/** A CHANNEL is associated with one CHANNEL_INFO**/
[CHANNEL_INFO]: {type: 'has_many', foreignKey: 'id'},
};
/** create_at : The creation date for this channel */
@@ -126,9 +128,6 @@ export default class ChannelModel extends Model implements ChannelModelInterface
/** membership : Query returning the membership data for the current user if it belongs to this channel */
@immutableRelation(MY_CHANNEL, 'id') membership!: Relation<MyChannelModel>;
/** settings: User specific settings/preferences for this channel */
@immutableRelation(MY_CHANNEL_SETTINGS, 'id') settings!: Relation<MyChannelSettingsModel>;
/** categoryChannel : Query returning the membership data for the current user if it belongs to this channel */
@immutableRelation(CATEGORY_CHANNEL, 'channel_id') categoryChannel!: Relation<CategoryChannelModel>;

View File

@@ -6,11 +6,12 @@ import {field, immutableRelation} from '@nozbe/watermelondb/decorators';
import Model, {Associations} from '@nozbe/watermelondb/Model';
import {MM_TABLES} from '@constants/database';
import MyChannelSettingsModel from '@typings/database/models/servers/my_channel_settings';
import type ChannelModel from '@typings/database/models/servers/channel';
import type MyChannelModelInterface from '@typings/database/models/servers/my_channel';
const {CATEGORY_CHANNEL, CHANNEL, MY_CHANNEL} = MM_TABLES.SERVER;
const {CATEGORY_CHANNEL, CHANNEL, MY_CHANNEL, MY_CHANNEL_SETTINGS} = MM_TABLES.SERVER;
/**
* MyChannel is an extension of the Channel model but it lists only the Channels the app's user belongs to
@@ -50,4 +51,13 @@ export default class MyChannelModel extends Model implements MyChannelModelInter
/** channel : The relation pointing to the CHANNEL table */
@immutableRelation(CHANNEL, 'id') channel!: Relation<ChannelModel>;
/** settings: User specific settings/preferences for this channel */
@immutableRelation(MY_CHANNEL_SETTINGS, 'id') settings!: Relation<MyChannelSettingsModel>;
async destroyPermanently() {
const settings = await this.settings.fetch();
settings?.destroyPermanently();
super.destroyPermanently();
}
}

View File

@@ -3,15 +3,15 @@
import {Relation} from '@nozbe/watermelondb';
import {immutableRelation, json} from '@nozbe/watermelondb/decorators';
import Model from '@nozbe/watermelondb/Model';
import Model, {Associations} from '@nozbe/watermelondb/Model';
import {MM_TABLES} from '@constants/database';
import {safeParseJSON} from '@utils/helpers';
import type ChannelModel from '@typings/database/models/servers/channel';
import type MyChannelModel from '@typings/database/models/servers/my_channel';
import type MyChannelSettingsModelInterface from '@typings/database/models/servers/my_channel_settings';
const {CHANNEL, MY_CHANNEL_SETTINGS} = MM_TABLES.SERVER;
const {MY_CHANNEL, MY_CHANNEL_SETTINGS} = MM_TABLES.SERVER;
/**
* The MyChannelSettings model represents the specific user's configuration to
@@ -21,9 +21,15 @@ export default class MyChannelSettingsModel extends Model implements MyChannelSe
/** table (name) : MyChannelSettings */
static table = MY_CHANNEL_SETTINGS;
static associations: Associations = {
/** A MY_CHANNEL is associated with one MY_CHANNEL_SETTINGS (relationship is 1:1) **/
[MY_CHANNEL]: {type: 'belongs_to', key: 'id'},
};
/** notify_props : Configurations in regard to this channel */
@json('notify_props', safeParseJSON) notifyProps!: ChannelNotifyProps;
/** channel : The relation pointing to the CHANNEL table */
@immutableRelation(CHANNEL, 'id') channel!: Relation<ChannelModel>;
/** channel : The relation pointing to the MY_CHANNEL table */
@immutableRelation(MY_CHANNEL, 'id') myChannel!: Relation<MyChannelModel>;
}

View File

@@ -20,6 +20,8 @@ export default class MyTeamModel extends Model implements MyTeamModelInterface {
static table = MY_TEAM;
static associations: Associations = {
/** A TEAM is associated to one MY_TEAM (relationship is 1:1) */
[TEAM]: {type: 'belongs_to', key: 'id'},
};

View File

@@ -23,7 +23,7 @@ export default class PostsInThreadModel extends Model implements PostsInThreadMo
/** associations : Describes every relationship to this table. */
static associations: Associations = {
/** A POST can have a POSTS_IN_THREAD.(relationship is 1:1)*/
/** A POST can have multiple POSTS_IN_THREAD. (relationship is 1:N)*/
[POST]: {type: 'belongs_to', key: 'root_id'},
};

View File

@@ -55,6 +55,9 @@ export default class TeamModel extends Model implements TeamModelInterface {
/** A TEAM has a 1:N relationship with THREADS_IN_TEAM. A TEAM can possess multiple threads */
[THREADS_IN_TEAM]: {type: 'has_many', foreignKey: 'team_id'},
/** A TEAM has a 1:1 relationship with TEAM_CHANNEL_HISTORY. */
[TEAM_CHANNEL_HISTORY]: {type: 'has_many', foreignKey: 'id'},
};
/** is_allow_open_invite : Boolean flag indicating if this team is open to the public */

View File

@@ -3,7 +3,7 @@
import {Relation} from '@nozbe/watermelondb';
import {immutableRelation, json} from '@nozbe/watermelondb/decorators';
import Model from '@nozbe/watermelondb/Model';
import Model, {Associations} from '@nozbe/watermelondb/Model';
import {MM_TABLES} from '@constants/database';
import {safeParseJSON} from '@utils/helpers';
@@ -21,6 +21,12 @@ export default class TeamChannelHistoryModel extends Model implements TeamChanne
/** table (name) : TeamChannelHistory */
static table = TEAM_CHANNEL_HISTORY;
static associations: Associations = {
/** A TEAM has a 1:1 relationship with TEAM_CHANNEL_HISTORY. */
[TEAM]: {type: 'belongs_to', key: 'id'},
};
/** channel_ids : An array containing the last 5 channels visited within this team order by recency */
@json('channel_ids', safeParseJSON) channelIds!: string[];

View File

@@ -1,6 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Query} from '@nozbe/watermelondb';
import {children, field, json} from '@nozbe/watermelondb/decorators';
import Model, {Associations} from '@nozbe/watermelondb/Model';
@@ -121,25 +122,25 @@ export default class UserModel extends Model implements UserModelInterface {
@json('timezone', safeParseJSON) timezone!: UserTimezone | null;
/** channelsCreated : All the channels that this user created */
@children(CHANNEL) channelsCreated!: ChannelModel[];
@children(CHANNEL) channelsCreated!: Query<ChannelModel>;
/** channels : All the channels that this user is part of */
@children(CHANNEL_MEMBERSHIP) channels!: ChannelMembershipModel[];
@children(CHANNEL_MEMBERSHIP) channels!: Query<ChannelMembershipModel>;
/** posts : All the posts that this user has written*/
@children(POST) posts!: PostModel[];
@children(POST) posts!: Query<PostModel>;
/** preferences : All user preferences */
@children(PREFERENCE) preferences!: PreferenceModel[];
@children(PREFERENCE) preferences!: Query<PreferenceModel>;
/** reactions : All the reactions to posts that this user had */
@children(REACTION) reactions!: ReactionModel[];
@children(REACTION) reactions!: Query<ReactionModel>;
/** teams : All the team that this user is part of */
@children(TEAM_MEMBERSHIP) teams!: TeamMembershipModel[];
@children(TEAM_MEMBERSHIP) teams!: Query<TeamMembershipModel>;
/** threadParticipations : All the thread participations this user is part of */
@children(THREAD_PARTICIPANT) threadParticipations!: ThreadParticipantsModel[];
@children(THREAD_PARTICIPANT) threadParticipations!: Query<ThreadParticipantsModel>;
prepareStatus = (status: string) => {
this.prepareUpdate((u) => {

View File

@@ -72,11 +72,11 @@ const PostHandler = (superclass: any) => class extends superclass {
* handlePosts: Handler responsible for the Create/Update operations occurring on the Post table from the 'Server' schema
* @param {HandlePostsArgs} handlePosts
* @param {string} handlePosts.actionType
* @param {string[]} handlePosts.orders
* @param {RawPost[]} handlePosts.values
* @param {string[]} handlePosts.order
* @param {RawPost[]} handlePosts.posts
* @param {string | undefined} handlePosts.previousPostId
* @param {boolean | undefined} handlePosts.prepareRecordsOnly
* @returns {Promise<void>}
* @returns {Promise<Model[]>}
*/
handlePosts = async ({actionType, order, posts, previousPostId = '', prepareRecordsOnly = false}: HandlePostsArgs): Promise<Model[]> => {
const tableName = POST;

View File

@@ -112,7 +112,7 @@ export const transformFileRecord = ({action, database, value}: TransformerArgs):
file.width = raw?.width || record?.width || 0;
file.height = raw?.height || record?.height || 0;
file.imageThumbnail = raw?.mini_preview || record?.imageThumbnail || '';
file.localPath = raw?.localPath || record?.localPath || '';
file.localPath = raw?.localPath || record?.localPath || null;
};
return prepareBaseRecord({

View File

@@ -43,7 +43,7 @@ export const transformUserRecord = ({action, database, value}: TransformerArgs):
user.props = raw.props || null;
user.timezone = raw.timezone || null;
user.isBot = raw.is_bot;
user.remoteId = raw?.remote_id ?? '';
user.remoteId = raw?.remote_id ?? null;
if (raw.status) {
user.status = raw.status;
}

View File

@@ -10,12 +10,12 @@ const {CATEGORY} = MM_TABLES.SERVER;
export default tableSchema({
name: CATEGORY,
columns: [
{name: 'collapsed', type: 'boolean'},
{name: 'display_name', type: 'string'},
{name: 'type', type: 'string'},
{name: 'muted', type: 'boolean'},
{name: 'sort_order', type: 'number'},
{name: 'sorting', type: 'string'},
{name: 'muted', type: 'boolean'},
{name: 'collapsed', type: 'boolean'},
{name: 'team_id', type: 'string', isIndexed: true},
{name: 'type', type: 'string'},
],
});

View File

@@ -10,6 +10,6 @@ const {CUSTOM_EMOJI} = MM_TABLES.SERVER;
export default tableSchema({
name: CUSTOM_EMOJI,
columns: [
{name: 'name', type: 'string'},
{name: 'name', type: 'string', isIndexed: true},
],
});

View File

@@ -13,7 +13,7 @@ export default tableSchema({
{name: 'extension', type: 'string'},
{name: 'height', type: 'number'},
{name: 'image_thumbnail', type: 'string'},
{name: 'local_path', type: 'string'},
{name: 'local_path', type: 'string', isOptional: true},
{name: 'mime_type', type: 'string'},
{name: 'name', type: 'string'},
{name: 'post_id', type: 'string', isIndexed: true},

View File

@@ -10,13 +10,14 @@ const {MY_CHANNEL} = MM_TABLES.SERVER;
export default tableSchema({
name: MY_CHANNEL,
columns: [
{name: 'is_unread', type: 'boolean'},
{name: 'last_post_at', type: 'number'},
{name: 'last_viewed_at', type: 'number'},
{name: 'manually_unread', type: 'boolean'},
{name: 'mentions_count', type: 'number'},
{name: 'message_count', type: 'number'},
{name: 'is_unread', type: 'boolean'},
{name: 'roles', type: 'string'},
{name: 'viewed_at', type: 'number'},
],
});

View File

@@ -13,7 +13,6 @@ export default tableSchema({
{name: 'channel_id', type: 'string', isIndexed: true},
{name: 'create_at', type: 'number'},
{name: 'delete_at', type: 'number'},
{name: 'update_at', type: 'number'},
{name: 'edit_at', type: 'number'},
{name: 'is_pinned', type: 'boolean'},
{name: 'message', type: 'string'},
@@ -24,6 +23,8 @@ export default tableSchema({
{name: 'props', type: 'string'},
{name: 'root_id', type: 'string'},
{name: 'type', type: 'string'},
{name: 'update_at', type: 'number'},
{name: 'user_id', type: 'string', isIndexed: true},
],
});

View File

@@ -10,8 +10,8 @@ const {POSTS_IN_THREAD} = MM_TABLES.SERVER;
export default tableSchema({
name: POSTS_IN_THREAD,
columns: [
{name: 'root_id', type: 'string', isIndexed: true},
{name: 'earliest', type: 'number'},
{name: 'latest', type: 'number'},
{name: 'root_id', type: 'string', isIndexed: true},
],
});

View File

@@ -16,3 +16,4 @@ export default tableSchema({
{name: 'user_id', type: 'string', isIndexed: true},
],
});

View File

@@ -10,7 +10,7 @@ const {ROLE} = MM_TABLES.SERVER;
export default tableSchema({
name: ROLE,
columns: [
{name: 'name', type: 'string'},
{name: 'name', type: 'string', isIndexed: true},
{name: 'permissions', type: 'string'},
],
});

View File

@@ -10,10 +10,10 @@ const {TEAM} = MM_TABLES.SERVER;
export default tableSchema({
name: TEAM,
columns: [
{name: 'is_allow_open_invite', type: 'boolean'},
{name: 'allowed_domains', type: 'string'},
{name: 'description', type: 'string'},
{name: 'display_name', type: 'string'},
{name: 'is_allow_open_invite', type: 'boolean'},
{name: 'is_group_constrained', type: 'boolean'},
{name: 'last_team_icon_updated_at', type: 'number'},
{name: 'name', type: 'string'},

View File

@@ -16,3 +16,4 @@ export default tableSchema({
{name: 'term', type: 'string'},
],
});

View File

@@ -10,12 +10,13 @@ const {THREAD} = MM_TABLES.SERVER;
export default tableSchema({
name: THREAD,
columns: [
{name: 'is_following', type: 'boolean'},
{name: 'last_reply_at', type: 'number'},
{name: 'last_viewed_at', type: 'number'},
{name: 'is_following', type: 'boolean'},
{name: 'reply_count', type: 'number'},
{name: 'unread_replies', type: 'number'},
{name: 'unread_mentions', type: 'number'},
{name: 'unread_replies', type: 'number'},
{name: 'viewed_at', type: 'number'},
],
});

View File

@@ -10,8 +10,8 @@ const {THREADS_IN_TEAM} = MM_TABLES.SERVER;
export default tableSchema({
name: THREADS_IN_TEAM,
columns: [
{name: 'loaded_in_global_threads', type: 'boolean', isIndexed: true},
{name: 'team_id', type: 'string', isIndexed: true},
{name: 'thread_id', type: 'string', isIndexed: true},
{name: 'loaded_in_global_threads', type: 'boolean', isIndexed: true},
],
});

View File

@@ -11,7 +11,6 @@ export default tableSchema({
name: USER,
columns: [
{name: 'auth_service', type: 'string'},
{name: 'update_at', type: 'number'},
{name: 'delete_at', type: 'number'},
{name: 'email', type: 'string'},
{name: 'first_name', type: 'string'},
@@ -24,10 +23,11 @@ export default tableSchema({
{name: 'notify_props', type: 'string'},
{name: 'position', type: 'string'},
{name: 'props', type: 'string'},
{name: 'remote_id', type: 'string', isOptional: true},
{name: 'roles', type: 'string'},
{name: 'status', type: 'string'},
{name: 'timezone', type: 'string'},
{name: 'update_at', type: 'number'},
{name: 'username', type: 'string'},
{name: 'remote_id', type: 'string', isOptional: true},
],
});

View File

@@ -45,22 +45,22 @@ describe('*** Test schema for SERVER database ***', () => {
name: CATEGORY,
unsafeSql: undefined,
columns: {
collapsed: {name: 'collapsed', type: 'boolean'},
display_name: {name: 'display_name', type: 'string'},
type: {name: 'type', type: 'string'},
muted: {name: 'muted', type: 'boolean'},
sort_order: {name: 'sort_order', type: 'number'},
sorting: {name: 'sorting', type: 'string'},
muted: {name: 'muted', type: 'boolean'},
collapsed: {name: 'collapsed', type: 'boolean'},
team_id: {name: 'team_id', type: 'string', isIndexed: true},
type: {name: 'type', type: 'string'},
},
columnArray: [
{name: 'collapsed', type: 'boolean'},
{name: 'display_name', type: 'string'},
{name: 'type', type: 'string'},
{name: 'muted', type: 'boolean'},
{name: 'sort_order', type: 'number'},
{name: 'sorting', type: 'string'},
{name: 'muted', type: 'boolean'},
{name: 'collapsed', type: 'boolean'},
{name: 'team_id', type: 'string', isIndexed: true},
{name: 'type', type: 'string'},
],
},
[CATEGORY_CHANNEL]: {
@@ -143,30 +143,30 @@ describe('*** Test schema for SERVER database ***', () => {
name: CUSTOM_EMOJI,
unsafeSql: undefined,
columns: {
name: {name: 'name', type: 'string'},
name: {name: 'name', type: 'string', isIndexed: true},
},
columnArray: [{name: 'name', type: 'string'}],
columnArray: [{name: 'name', type: 'string', isIndexed: true}],
},
[MY_CHANNEL]: {
name: MY_CHANNEL,
unsafeSql: undefined,
columns: {
is_unread: {name: 'is_unread', type: 'boolean'},
last_post_at: {name: 'last_post_at', type: 'number'},
last_viewed_at: {name: 'last_viewed_at', type: 'number'},
manually_unread: {name: 'manually_unread', type: 'boolean'},
mentions_count: {name: 'mentions_count', type: 'number'},
message_count: {name: 'message_count', type: 'number'},
is_unread: {name: 'is_unread', type: 'boolean'},
roles: {name: 'roles', type: 'string'},
viewed_at: {name: 'viewed_at', type: 'number'},
},
columnArray: [
{name: 'is_unread', type: 'boolean'},
{name: 'last_post_at', type: 'number'},
{name: 'last_viewed_at', type: 'number'},
{name: 'manually_unread', type: 'boolean'},
{name: 'mentions_count', type: 'number'},
{name: 'message_count', type: 'number'},
{name: 'is_unread', type: 'boolean'},
{name: 'roles', type: 'string'},
{name: 'viewed_at', type: 'number'},
],
@@ -218,7 +218,7 @@ describe('*** Test schema for SERVER database ***', () => {
extension: {name: 'extension', type: 'string'},
height: {name: 'height', type: 'number'},
image_thumbnail: {name: 'image_thumbnail', type: 'string'},
local_path: {name: 'local_path', type: 'string'},
local_path: {name: 'local_path', type: 'string', isOptional: true},
mime_type: {name: 'mime_type', type: 'string'},
name: {name: 'name', type: 'string'},
post_id: {name: 'post_id', type: 'string', isIndexed: true},
@@ -229,7 +229,7 @@ describe('*** Test schema for SERVER database ***', () => {
{name: 'extension', type: 'string'},
{name: 'height', type: 'number'},
{name: 'image_thumbnail', type: 'string'},
{name: 'local_path', type: 'string'},
{name: 'local_path', type: 'string', isOptional: true},
{name: 'mime_type', type: 'string'},
{name: 'name', type: 'string'},
{name: 'post_id', type: 'string', isIndexed: true},
@@ -241,14 +241,14 @@ describe('*** Test schema for SERVER database ***', () => {
name: POSTS_IN_THREAD,
unsafeSql: undefined,
columns: {
root_id: {name: 'root_id', type: 'string', isIndexed: true},
earliest: {name: 'earliest', type: 'number'},
latest: {name: 'latest', type: 'number'},
root_id: {name: 'root_id', type: 'string', isIndexed: true},
},
columnArray: [
{name: 'root_id', type: 'string', isIndexed: true},
{name: 'earliest', type: 'number'},
{name: 'latest', type: 'number'},
{name: 'root_id', type: 'string', isIndexed: true},
],
},
[POST]: {
@@ -258,7 +258,6 @@ describe('*** Test schema for SERVER database ***', () => {
channel_id: {name: 'channel_id', type: 'string', isIndexed: true},
create_at: {name: 'create_at', type: 'number'},
delete_at: {name: 'delete_at', type: 'number'},
update_at: {name: 'update_at', type: 'number'},
edit_at: {name: 'edit_at', type: 'number'},
is_pinned: {name: 'is_pinned', type: 'boolean'},
message: {name: 'message', type: 'string'},
@@ -269,13 +268,13 @@ describe('*** Test schema for SERVER database ***', () => {
props: {name: 'props', type: 'string'},
root_id: {name: 'root_id', type: 'string'},
type: {name: 'type', type: 'string'},
update_at: {name: 'update_at', type: 'number'},
user_id: {name: 'user_id', type: 'string', isIndexed: true},
},
columnArray: [
{name: 'channel_id', type: 'string', isIndexed: true},
{name: 'create_at', type: 'number'},
{name: 'delete_at', type: 'number'},
{name: 'update_at', type: 'number'},
{name: 'edit_at', type: 'number'},
{name: 'is_pinned', type: 'boolean'},
{name: 'message', type: 'string'},
@@ -286,6 +285,7 @@ describe('*** Test schema for SERVER database ***', () => {
{name: 'props', type: 'string'},
{name: 'root_id', type: 'string'},
{name: 'type', type: 'string'},
{name: 'update_at', type: 'number'},
{name: 'user_id', type: 'string', isIndexed: true},
],
},
@@ -335,11 +335,11 @@ describe('*** Test schema for SERVER database ***', () => {
name: ROLE,
unsafeSql: undefined,
columns: {
name: {name: 'name', type: 'string'},
name: {name: 'name', type: 'string', isIndexed: true},
permissions: {name: 'permissions', type: 'string'},
},
columnArray: [
{name: 'name', type: 'string'},
{name: 'name', type: 'string', isIndexed: true},
{name: 'permissions', type: 'string'},
],
},
@@ -357,13 +357,13 @@ describe('*** Test schema for SERVER database ***', () => {
name: TEAM,
unsafeSql: undefined,
columns: {
allowed_domains: {name: 'allowed_domains', type: 'string'},
description: {name: 'description', type: 'string'},
display_name: {name: 'display_name', type: 'string'},
is_allow_open_invite: {
name: 'is_allow_open_invite',
type: 'boolean',
},
allowed_domains: {name: 'allowed_domains', type: 'string'},
description: {name: 'description', type: 'string'},
display_name: {name: 'display_name', type: 'string'},
is_group_constrained: {
name: 'is_group_constrained',
type: 'boolean',
@@ -377,10 +377,10 @@ describe('*** Test schema for SERVER database ***', () => {
update_at: {name: 'update_at', type: 'number'},
},
columnArray: [
{name: 'is_allow_open_invite', type: 'boolean'},
{name: 'allowed_domains', type: 'string'},
{name: 'description', type: 'string'},
{name: 'display_name', type: 'string'},
{name: 'is_allow_open_invite', type: 'boolean'},
{name: 'is_group_constrained', type: 'boolean'},
{name: 'last_team_icon_updated_at', type: 'number'},
{name: 'name', type: 'string'},
@@ -430,21 +430,21 @@ describe('*** Test schema for SERVER database ***', () => {
name: THREAD,
unsafeSql: undefined,
columns: {
is_following: {name: 'is_following', type: 'boolean'},
last_reply_at: {name: 'last_reply_at', type: 'number'},
last_viewed_at: {name: 'last_viewed_at', type: 'number'},
is_following: {name: 'is_following', type: 'boolean'},
reply_count: {name: 'reply_count', type: 'number'},
unread_replies: {name: 'unread_replies', type: 'number'},
unread_mentions: {name: 'unread_mentions', type: 'number'},
unread_replies: {name: 'unread_replies', type: 'number'},
viewed_at: {name: 'viewed_at', type: 'number'},
},
columnArray: [
{name: 'is_following', type: 'boolean'},
{name: 'last_reply_at', type: 'number'},
{name: 'last_viewed_at', type: 'number'},
{name: 'is_following', type: 'boolean'},
{name: 'reply_count', type: 'number'},
{name: 'unread_replies', type: 'number'},
{name: 'unread_mentions', type: 'number'},
{name: 'unread_replies', type: 'number'},
{name: 'viewed_at', type: 'number'},
],
},
@@ -464,14 +464,14 @@ describe('*** Test schema for SERVER database ***', () => {
name: THREADS_IN_TEAM,
unsafeSql: undefined,
columns: {
loaded_in_global_threads: {name: 'loaded_in_global_threads', type: 'boolean', isIndexed: true},
team_id: {name: 'team_id', type: 'string', isIndexed: true},
thread_id: {name: 'thread_id', type: 'string', isIndexed: true},
loaded_in_global_threads: {name: 'loaded_in_global_threads', type: 'boolean', isIndexed: true},
},
columnArray: [
{name: 'loaded_in_global_threads', type: 'boolean', isIndexed: true},
{name: 'team_id', type: 'string', isIndexed: true},
{name: 'thread_id', type: 'string', isIndexed: true},
{name: 'loaded_in_global_threads', type: 'boolean', isIndexed: true},
],
},
[USER]: {
@@ -479,31 +479,27 @@ describe('*** Test schema for SERVER database ***', () => {
unsafeSql: undefined,
columns: {
auth_service: {name: 'auth_service', type: 'string'},
update_at: {name: 'update_at', type: 'number'},
delete_at: {name: 'delete_at', type: 'number'},
email: {name: 'email', type: 'string'},
first_name: {name: 'first_name', type: 'string'},
is_bot: {name: 'is_bot', type: 'boolean'},
is_guest: {name: 'is_guest', type: 'boolean'},
last_name: {name: 'last_name', type: 'string'},
last_picture_update: {
name: 'last_picture_update',
type: 'number',
},
last_picture_update: {name: 'last_picture_update', type: 'number'},
locale: {name: 'locale', type: 'string'},
nickname: {name: 'nickname', type: 'string'},
notify_props: {name: 'notify_props', type: 'string'},
position: {name: 'position', type: 'string'},
props: {name: 'props', type: 'string'},
remote_id: {name: 'remote_id', type: 'string', isOptional: true},
roles: {name: 'roles', type: 'string'},
status: {name: 'status', type: 'string'},
timezone: {name: 'timezone', type: 'string'},
update_at: {name: 'update_at', type: 'number'},
username: {name: 'username', type: 'string'},
remote_id: {name: 'remote_id', type: 'string', isOptional: true},
},
columnArray: [
{name: 'auth_service', type: 'string'},
{name: 'update_at', type: 'number'},
{name: 'delete_at', type: 'number'},
{name: 'email', type: 'string'},
{name: 'first_name', type: 'string'},
@@ -516,11 +512,12 @@ describe('*** Test schema for SERVER database ***', () => {
{name: 'notify_props', type: 'string'},
{name: 'position', type: 'string'},
{name: 'props', type: 'string'},
{name: 'remote_id', type: 'string', isOptional: true},
{name: 'roles', type: 'string'},
{name: 'status', type: 'string'},
{name: 'timezone', type: 'string'},
{name: 'update_at', type: 'number'},
{name: 'username', type: 'string'},
{name: 'remote_id', type: 'string', isOptional: true},
],
},
},