diff --git a/app/database/migration/server/index.ts b/app/database/migration/server/index.ts index cacdeaa56..5916eb497 100644 --- a/app/database/migration/server/index.ts +++ b/app/database/migration/server/index.ts @@ -8,7 +8,7 @@ import {addColumns, schemaMigrations} from '@nozbe/watermelondb/Schema/migration import {MM_TABLES} from '@constants/database'; -const {CHANNEL_INFO} = MM_TABLES.SERVER; +const {CHANNEL_INFO, DRAFT} = MM_TABLES.SERVER; export default schemaMigrations({migrations: [ { @@ -20,6 +20,12 @@ export default schemaMigrations({migrations: [ {name: 'files_count', type: 'number'}, ], }), + addColumns({ + table: DRAFT, + columns: [ + {name: 'metadata', type: 'string', isOptional: true}, + ], + }), ], }, ]}); diff --git a/app/database/models/server/draft.ts b/app/database/models/server/draft.ts index f651029d0..aebe33e28 100644 --- a/app/database/models/server/draft.ts +++ b/app/database/models/server/draft.ts @@ -5,7 +5,7 @@ import {field, json} from '@nozbe/watermelondb/decorators'; import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; -import {safeParseJSON} from '@utils/helpers'; +import {identity, safeParseJSON} from '@utils/helpers'; import type DraftModelInterface from '@typings/database/models/servers/draft'; @@ -39,4 +39,6 @@ export default class DraftModel extends Model implements DraftModelInterface { /** files : The files field will hold an array of file objects that have not yet been uploaded and persisted within the FILE table */ @json('files', safeParseJSON) files!: FileInfo[]; + + @json('metadata', identity) metadata?: PostMetadata; } diff --git a/app/database/schema/server/table_schemas/draft.ts b/app/database/schema/server/table_schemas/draft.ts index eeeb438c7..c69cde445 100644 --- a/app/database/schema/server/table_schemas/draft.ts +++ b/app/database/schema/server/table_schemas/draft.ts @@ -14,5 +14,6 @@ export default tableSchema({ {name: 'files', type: 'string'}, {name: 'message', type: 'string'}, {name: 'root_id', type: 'string', isIndexed: true}, + {name: 'metadata', type: 'string', isOptional: true}, ], }); diff --git a/app/database/schema/server/test.ts b/app/database/schema/server/test.ts index 1a6c1690d..d660b2073 100644 --- a/app/database/schema/server/test.ts +++ b/app/database/schema/server/test.ts @@ -226,12 +226,14 @@ describe('*** Test schema for SERVER database ***', () => { files: {name: 'files', type: 'string'}, message: {name: 'message', type: 'string'}, root_id: {name: 'root_id', type: 'string', isIndexed: true}, + metadata: {name: 'metadata', type: 'string', isOptional: true}, }, columnArray: [ {name: 'channel_id', type: 'string', isIndexed: true}, {name: 'files', type: 'string'}, {name: 'message', type: 'string'}, {name: 'root_id', type: 'string', isIndexed: true}, + {name: 'metadata', type: 'string', isOptional: true}, ], }, [FILE]: { diff --git a/types/database/models/servers/draft.ts b/types/database/models/servers/draft.ts index 91768fd12..003568023 100644 --- a/types/database/models/servers/draft.ts +++ b/types/database/models/servers/draft.ts @@ -25,6 +25,8 @@ declare class DraftModel extends Model { /** files : The files field will hold an array of files object that have not yet been uploaded and persisted within the FILE table */ files: FileInfo[]; + + metadata?: PostMetadata; } export default DraftModel;