X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Futils%2FMobileLedgerDatabase.java;h=1c66f07d99c44351aace1e100ecdd198eaade6d3;hb=e20e0d8049c843abfd8b9e2fd9da7461f9f8ab1c;hp=307d4bc9f93425a2bdeb930f6476abb5f36ef5d2;hpb=f0fecef867dd49fe41fc733c11418f95a270be4a;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java b/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java index 307d4bc9..1c66f07d 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java @@ -1,5 +1,5 @@ /* - * Copyright © 2020 Damyan Ivanov. + * Copyright © 2021 Damyan Ivanov. * This file is part of MoLe. * MoLe is free software: you can distribute it and/or modify it * under the term of the GNU General Public License as published by @@ -38,8 +38,8 @@ import static net.ktnx.mobileledger.utils.Logger.debug; public class MobileLedgerDatabase extends SQLiteOpenHelper { public static final MutableLiveData initComplete = new MutableLiveData<>(false); - private static final String DB_NAME = "MoLe.db"; - private static final int LATEST_REVISION = 40; + public static final String DB_NAME = "MoLe.db"; + private static final int LATEST_REVISION = 55; private static final String CREATE_DB_SQL = "create_db"; private final Application mContext; @@ -56,6 +56,13 @@ public class MobileLedgerDatabase extends SQLiteOpenHelper { applyRevisionFile(db, CREATE_DB_SQL); } + @Override + public void onConfigure(SQLiteDatabase db) { + super.onConfigure(db); + db.execSQL("pragma case_sensitive_like=ON;"); + if (BuildConfig.DEBUG) + db.execSQL("PRAGMA foreign_keys=ON"); + } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { debug("db", @@ -64,14 +71,6 @@ public class MobileLedgerDatabase extends SQLiteOpenHelper { for (int i = oldVersion + 1; i <= newVersion; i++) applyRevision(db, i); } - @Override - public void onOpen(SQLiteDatabase db) { - super.onOpen(db); - db.execSQL("pragma case_sensitive_like=ON;"); - if (BuildConfig.DEBUG) - db.execSQL("PRAGMA foreign_keys=ON"); - } - private void applyRevision(SQLiteDatabase db, int rev_no) { String rev_file = String.format(Locale.US, "sql_%d", rev_no);