+ private static DB instance;
+ public static DB get() {
+ if (instance != null)
+ return instance;
+ synchronized (DB.class) {
+ if (instance != null)
+ return instance;
+
+ return instance =
+ Room.databaseBuilder(App.instance, DB.class, MobileLedgerDatabase.DB_NAME)
+ .addMigrations(new Migration[]{new Migration(51, 52) {
+ @Override
+ public void migrate(@NonNull SupportSQLiteDatabase db) {
+ db.beginTransaction();
+ try {
+ db.execSQL("create index fk_pattern_accounts_pattern on " +
+ "pattern_accounts(pattern_id);");
+ db.execSQL("create index fk_pattern_accounts_currency on " +
+ "pattern_accounts(currency);");
+ db.setTransactionSuccessful();
+ }
+ finally {
+ db.endTransaction();
+ }
+ }
+ }
+ })
+ .build();
+ }
+ }