forked from Ivasoft/mattermost-mobile
MM-30482 [Gekidou] Data Operator (#5346)
* MM_30482: Imported database and types /database folder * MM_30482: Imported database and types /database folder * MM_30482 : All tests are passing * MM_30482 : Updating patch package for watermelon db * MM_30482 : Fixing CI issue * MM_30482 : Updating TS complaint * Update index.ts * MM_30482 : Code clean up Co-authored-by: Avinash Lingaloo <>
This commit is contained in:
38
app/database/schema/default/index.ts
Normal file
38
app/database/schema/default/index.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {AppSchema, appSchema, tableSchema} from '@nozbe/watermelondb';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
const {APP, GLOBAL, SERVERS} = MM_TABLES.DEFAULT;
|
||||
|
||||
export const defaultSchema: AppSchema = appSchema({
|
||||
version: 1,
|
||||
tables: [
|
||||
tableSchema({
|
||||
name: APP,
|
||||
columns: [
|
||||
{name: 'build_number', type: 'string'},
|
||||
{name: 'created_at', type: 'number'},
|
||||
{name: 'version_number', type: 'string'},
|
||||
],
|
||||
}),
|
||||
tableSchema({
|
||||
name: GLOBAL,
|
||||
columns: [
|
||||
{name: 'name', type: 'string', isIndexed: true},
|
||||
{name: 'value', type: 'string'},
|
||||
],
|
||||
}),
|
||||
tableSchema({
|
||||
name: SERVERS,
|
||||
columns: [
|
||||
{name: 'db_path', type: 'string'},
|
||||
{name: 'display_name', type: 'string'},
|
||||
{name: 'mention_count', type: 'number'},
|
||||
{name: 'unread_count', type: 'number'},
|
||||
{name: 'url', type: 'string', isIndexed: true},
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
17
app/database/schema/default/table_schemas/app.ts
Normal file
17
app/database/schema/default/table_schemas/app.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {tableSchema} from '@nozbe/watermelondb';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
const {APP} = MM_TABLES.DEFAULT;
|
||||
|
||||
export default tableSchema({
|
||||
name: APP,
|
||||
columns: [
|
||||
{name: 'build_number', type: 'string'},
|
||||
{name: 'created_at', type: 'number'},
|
||||
{name: 'version_number', type: 'string'},
|
||||
],
|
||||
});
|
||||
16
app/database/schema/default/table_schemas/global.ts
Normal file
16
app/database/schema/default/table_schemas/global.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {tableSchema} from '@nozbe/watermelondb';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
const {GLOBAL} = MM_TABLES.DEFAULT;
|
||||
|
||||
export default tableSchema({
|
||||
name: GLOBAL,
|
||||
columns: [
|
||||
{name: 'name', type: 'string', isIndexed: true},
|
||||
{name: 'value', type: 'string'},
|
||||
],
|
||||
});
|
||||
6
app/database/schema/default/table_schemas/index.ts
Normal file
6
app/database/schema/default/table_schemas/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
export {default as app} from './app';
|
||||
export {default as global} from './global';
|
||||
export {default as servers} from './servers';
|
||||
19
app/database/schema/default/table_schemas/servers.ts
Normal file
19
app/database/schema/default/table_schemas/servers.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {tableSchema} from '@nozbe/watermelondb';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
const {SERVERS} = MM_TABLES.DEFAULT;
|
||||
|
||||
export default tableSchema({
|
||||
name: SERVERS,
|
||||
columns: [
|
||||
{name: 'db_path', type: 'string'},
|
||||
{name: 'display_name', type: 'string'},
|
||||
{name: 'mention_count', type: 'number'},
|
||||
{name: 'unread_count', type: 'number'},
|
||||
{name: 'url', type: 'string', isIndexed: true},
|
||||
],
|
||||
});
|
||||
59
app/database/schema/default/test.ts
Normal file
59
app/database/schema/default/test.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import {defaultSchema} from './index';
|
||||
|
||||
const {APP, GLOBAL, SERVERS} = MM_TABLES.DEFAULT;
|
||||
|
||||
describe('*** Test schema for DEFAULT database ***', () => {
|
||||
it('=> The DEFAULT SCHEMA should strictly match', () => {
|
||||
expect(defaultSchema).toEqual({
|
||||
version: 1,
|
||||
tables: {
|
||||
[APP]: {
|
||||
name: APP,
|
||||
columns: {
|
||||
build_number: {name: 'build_number', type: 'string'},
|
||||
created_at: {name: 'created_at', type: 'number'},
|
||||
version_number: {name: 'version_number', type: 'string'},
|
||||
},
|
||||
columnArray: [
|
||||
{name: 'build_number', type: 'string'},
|
||||
{name: 'created_at', type: 'number'},
|
||||
{name: 'version_number', type: 'string'},
|
||||
],
|
||||
},
|
||||
[GLOBAL]: {
|
||||
name: GLOBAL,
|
||||
columns: {
|
||||
name: {name: 'name', type: 'string', isIndexed: true},
|
||||
value: {name: 'value', type: 'string'},
|
||||
},
|
||||
columnArray: [
|
||||
{name: 'name', type: 'string', isIndexed: true},
|
||||
{name: 'value', type: 'string'},
|
||||
],
|
||||
},
|
||||
[SERVERS]: {
|
||||
name: SERVERS,
|
||||
columns: {
|
||||
db_path: {name: 'db_path', type: 'string'},
|
||||
display_name: {name: 'display_name', type: 'string'},
|
||||
mention_count: {name: 'mention_count', type: 'number'},
|
||||
unread_count: {name: 'unread_count', type: 'number'},
|
||||
url: {name: 'url', type: 'string', isIndexed: true},
|
||||
},
|
||||
columnArray: [
|
||||
{name: 'db_path', type: 'string'},
|
||||
{name: 'display_name', type: 'string'},
|
||||
{name: 'mention_count', type: 'number'},
|
||||
{name: 'unread_count', type: 'number'},
|
||||
{name: 'url', type: 'string', isIndexed: true},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user