MM-49540: drafts migration adding metadata (#7240)
* MM-49540: drafts migration adding metadata Adds a drafts table migration adding the column "metadata". This column is going to be primarily used to store the draft's metadata priority field. * Addresses review comments
This commit is contained in:
parent
d62c35aae1
commit
6472ce1247
5 changed files with 15 additions and 2 deletions
|
|
@ -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},
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
]});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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]: {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue