Files
mattermost-mobile/app/database/managers/schema_manager.ts
Avinash Lingaloo a505bd5e11 MM_30476 : ADDED Schema Managers
* The migration array will hold all the migration steps.

*  The initial app release (e.g. v2 )will have an empty array and subsequent releases  (e.g.  v2.1 ) will have the steps listed in that array.

* On initialization, the database will perform the migration to accomodate for new columns/tables creation and while it will conserve the mobile phone's data, it will also make it conform to this new schema.

* If a migration fails, the migration process will rollback any changes.  This migration will be thoroughly tested in development before pushing it live.
2020-12-01 16:43:23 +04:00

23 lines
999 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {SQLiteAdapterOptions} from '@nozbe/watermelondb/adapters/sqlite';
import {defaultSchema} from '../default/schema';
import {DB_NAME} from '@constants/database';
import {migrations as defaultMigration} from '../default/migration';
import {migrations as serverMigration} from '../server/migration';
import {schemaMigrations} from '@nozbe/watermelondb/Schema/migrations';
import {serverSchema} from '../server/schema';
export const default_schema_manager:SQLiteAdapterOptions = {
dbName: DB_NAME.DEFAULT_DATABASE,
schema: defaultSchema,
...(defaultMigration.length > 0 && {migrations: schemaMigrations({migrations: defaultMigration})}),
};
export const server_schema_manager:SQLiteAdapterOptions = {
dbName: DB_NAME.SERVER_DATABASE,
schema: serverSchema,
...(serverMigration.length > 0 && {migrations: schemaMigrations({migrations: serverMigration})}),
};