Commit d82539b1 authored by Max Lv's avatar Max Lv

Drop the table if the database upgrading failed. #987

parent 7922159e
...@@ -46,6 +46,7 @@ import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper ...@@ -46,6 +46,7 @@ import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
import com.j256.ormlite.dao.Dao import com.j256.ormlite.dao.Dao
import com.j256.ormlite.support.ConnectionSource import com.j256.ormlite.support.ConnectionSource
import com.j256.ormlite.table.TableUtils import com.j256.ormlite.table.TableUtils
import com.github.shadowsocks.ShadowsocksApplication.app
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
import scala.collection.mutable import scala.collection.mutable
...@@ -81,6 +82,8 @@ class DBHelper(val context: Context) ...@@ -81,6 +82,8 @@ class DBHelper(val context: Context)
onCreate(database, connectionSource) onCreate(database, connectionSource)
return return
} }
try {
if (oldVersion < 8) { if (oldVersion < 8) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN udpdns SMALLINT;") profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN udpdns SMALLINT;")
} }
...@@ -141,6 +144,13 @@ class DBHelper(val context: Context) ...@@ -141,6 +144,13 @@ class DBHelper(val context: Context)
} else if (oldVersion < 19) { } else if (oldVersion < 19) {
profileDao.executeRawNoArgs("UPDATE `profile` SET kcpPort = 8399 WHERE kcpPort = 0;") profileDao.executeRawNoArgs("UPDATE `profile` SET kcpPort = 8399 WHERE kcpPort = 0;")
} }
} catch {
case ex: Exception =>
app.track(ex)
profileDao.executeRawNoArgs("DROP TABLE IF EXISTS 'profile';")
onCreate(database, connectionSource)
return
}
} }
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment