From df2c62aca0406ba0e8e4613e06f55f1259bb8129 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 4 Feb 2016 07:40:18 +0100 Subject: [PATCH] Conditionally create database indices Refs #256 --- .../main/java/eu/faircode/netguard/DatabaseHelper.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java b/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java index d18f28ab..9471ec8a 100644 --- a/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java +++ b/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java @@ -171,9 +171,9 @@ public class DatabaseHelper extends SQLiteOpenHelper { db.execSQL("ALTER TABLE log ADD COLUMN data TEXT"); db.execSQL("DROP INDEX idx_log_source"); db.execSQL("DROP INDEX idx_log_dest"); - db.execSQL("CREATE INDEX idx_log_source ON log(saddr)"); - db.execSQL("CREATE INDEX idx_log_dest ON log(daddr)"); - db.execSQL("CREATE INDEX idx_log_uid ON log(uid)"); + db.execSQL("CREATE INDEX IF NOT EXISTS idx_log_source ON log(saddr)"); + db.execSQL("CREATE INDEX IF NOT EXISTS idx_log_dest ON log(daddr)"); + db.execSQL("CREATE INDEX IF NOT EXISTS idx_log_uid ON log(uid)"); oldVersion = 8; } if (oldVersion < 9) { @@ -193,8 +193,8 @@ public class DatabaseHelper extends SQLiteOpenHelper { oldVersion = 12; } if (oldVersion < 13) { - db.execSQL("CREATE INDEX idx_log_dport ON log(dport)"); - db.execSQL("CREATE INDEX idx_log_dname ON log(dname)"); + db.execSQL("CREATE INDEX IF NOT EXISTS idx_log_dport ON log(dport)"); + db.execSQL("CREATE INDEX IF NOT EXISTS idx_log_dname ON log(dname)"); oldVersion = 13; } if (oldVersion < 14) {