mattermost-mobile/app/database/migration/server/index.ts
Rajat Dabade 647b8c8eb6
MM-60705 DB migration: added update_at column to draft table for mobile (#8237)
* MM-60705 DB migration: added update_at column to draft table for mobile

* refactor: updated docs

* refactor: reverted unwanted changes and updated default value for update_at columns

* refactor: changed the condition for excepting 0 value for update_at column
2024-10-15 19:49:22 +05:30

77 lines
2.5 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// NOTE : To implement migration, please follow this document
// https://nozbe.github.io/WatermelonDB/Advanced/Migrations.html
import {addColumns, createTable, schemaMigrations} from '@nozbe/watermelondb/Schema/migrations';
import {MM_TABLES} from '@constants/database';
const {CHANNEL_BOOKMARK, CHANNEL_INFO, DRAFT, POST} = MM_TABLES.SERVER;
export default schemaMigrations({migrations: [
{
toVersion: 5,
steps: [
addColumns({
table: DRAFT,
columns: [
{name: 'update_at', type: 'number'},
],
}),
],
},
{
toVersion: 4,
steps: [
createTable({
name: CHANNEL_BOOKMARK,
columns: [
{name: 'create_at', type: 'number'},
{name: 'update_at', type: 'number'},
{name: 'delete_at', type: 'number'},
{name: 'channel_id', type: 'string', isIndexed: true},
{name: 'owner_id', type: 'string'},
{name: 'file_id', type: 'string', isOptional: true},
{name: 'display_name', type: 'string'},
{name: 'sort_order', type: 'number'},
{name: 'link_url', type: 'string', isOptional: true},
{name: 'image_url', type: 'string', isOptional: true},
{name: 'emoji', type: 'string', isOptional: true},
{name: 'type', type: 'string'},
{name: 'original_id', type: 'string', isOptional: true},
{name: 'parent_id', type: 'string', isOptional: true},
],
}),
],
},
{
toVersion: 3,
steps: [
addColumns({
table: POST,
columns: [
{name: 'message_source', type: 'string'},
],
}),
],
},
{
toVersion: 2,
steps: [
addColumns({
table: CHANNEL_INFO,
columns: [
{name: 'files_count', type: 'number'},
],
}),
addColumns({
table: DRAFT,
columns: [
{name: 'metadata', type: 'string', isOptional: true},
],
}),
],
},
]});