From cf4d4e1521889352be7c89c39c6ff894977cc156 Mon Sep 17 00:00:00 2001 From: Tim Glasgow Date: Wed, 27 Jul 2022 21:36:45 -0500 Subject: [PATCH] Separate migration scripts --- squarenotsquare/realm/dbInit.js | 7 ++++--- .../realm/migrations/{Migrations.js => MigrateV1.js} | 4 ---- 2 files changed, 4 insertions(+), 7 deletions(-) rename squarenotsquare/realm/migrations/{Migrations.js => MigrateV1.js} (82%) diff --git a/squarenotsquare/realm/dbInit.js b/squarenotsquare/realm/dbInit.js index 171d525..25853b6 100644 --- a/squarenotsquare/realm/dbInit.js +++ b/squarenotsquare/realm/dbInit.js @@ -11,7 +11,8 @@ import {SystemRepo} from './entities/System'; import {UserRepo} from './entities/User'; //Migrations -import * as Migrations from './migrations/Migrations'; +import { migratev0 } from "./migrations/MigrateV0"; +import { migratev1 } from "./migrations/MigrateV1"; //keys import {generateKey} from '../libs/Random'; @@ -45,8 +46,8 @@ export async function initDB(){ if (dbRef === null){ let schemaList = [ - {schemaVersion: 0, schema: [System, User, Score], migration: Migrations.migratev0, encryptionKey: dbKey}, - {schemaVersion: 1, schema: [System, User, Score], migration: Migrations.migratev1, encryptionKey: dbKey} + {schemaVersion: 0, schema: [System, User, Score], migration: migratev0, encryptionKey: dbKey}, + {schemaVersion: 1, schema: [System, User, Score], migration: migratev1, encryptionKey: dbKey} ] let currentSchema = Realm.schemaVersion(Realm.defaultPath, dbKey); diff --git a/squarenotsquare/realm/migrations/Migrations.js b/squarenotsquare/realm/migrations/MigrateV1.js similarity index 82% rename from squarenotsquare/realm/migrations/Migrations.js rename to squarenotsquare/realm/migrations/MigrateV1.js index 0187e67..797c6e2 100644 --- a/squarenotsquare/realm/migrations/Migrations.js +++ b/squarenotsquare/realm/migrations/MigrateV1.js @@ -2,10 +2,6 @@ import {System} from '../entities/System'; import 'react-native-get-random-values'; import { v4 as uuidv4 } from 'uuid'; -export function migratev0(oldRealm, newRealm) { - //start with empty db -} - export function migratev1(oldRealm, newRealm) { if (oldRealm.schemaVersion === 0) { newRealm.create(System.name, {