import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
+import net.ktnx.mobileledger.BuildConfig;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
public class MobileLedgerDatabase extends SQLiteOpenHelper {
private static final String DB_NAME = "MoLe.db";
- private static final int LATEST_REVISION = 39;
+ private static final int LATEST_REVISION = 40;
private static final String CREATE_DB_SQL = "create_db";
private final Application mContext;
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- debug("db", "onUpgrade called");
+ debug("db",
+ String.format(Locale.US, "needs upgrade from version %d to version %d", oldVersion,
+ newVersion));
for (int i = oldVersion + 1; i <= newVersion; i++)
applyRevision(db, i);
}
public void onOpen(SQLiteDatabase db) {
super.onOpen(db);
db.execSQL("pragma case_sensitive_like=ON;");
- db.execSQL("PRAGMA foreign_keys=ON");
+ if (BuildConfig.DEBUG)
+ db.execSQL("PRAGMA foreign_keys=ON");
}
private void applyRevision(SQLiteDatabase db, int rev_no) {