]> git.ktnx.net Git - mobile-ledger.git/commitdiff
DB: move pragma execution in onConfigure() where it belongs
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 26 Sep 2020 14:25:38 +0000 (17:25 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 26 Sep 2020 14:25:38 +0000 (17:25 +0300)
app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java

index 307d4bc9f93425a2bdeb930f6476abb5f36ef5d2..29f4142571e4974eb5d35577ef579c995296014d 100644 (file)
@@ -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);