From: Damyan Ivanov Date: Sat, 26 Sep 2020 14:25:38 +0000 (+0300) Subject: DB: move pragma execution in onConfigure() where it belongs X-Git-Tag: v0.16.0~45 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=382fca6c0438ba031995fbfd0ec43ec73d80a192;p=mobile-ledger.git DB: move pragma execution in onConfigure() where it belongs --- 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..29f41425 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java @@ -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);