Skip to content

Commit e014194

Browse files
committed
fix: revert db fields to previous correct values
The changes requires scheme change migration as well.
1 parent c997804 commit e014194

File tree

8 files changed

+23
-52
lines changed

8 files changed

+23
-52
lines changed

app/src/main/java/com/celzero/bravedns/database/AppDatabase.kt

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import com.celzero.bravedns.util.Constants
5353
SubscriptionStatus::class,
5454
SubscriptionStateHistory::class
5555
],
56-
version = 27,
56+
version = 26,
5757
exportSchema = false
5858
)
5959
@TypeConverters(Converters::class)
@@ -100,7 +100,6 @@ abstract class AppDatabase : RoomDatabase() {
100100
.addMigrations(MIGRATION_23_24)
101101
.addMigrations(MIGRATION_24_25)
102102
.addMigrations(MIGRATION_25_26)
103-
.addMigrations(MIGRATION_26_27)
104103
.build()
105104

106105
private val roomCallback: Callback =
@@ -1076,34 +1075,6 @@ abstract class AppDatabase : RoomDatabase() {
10761075
}
10771076
}
10781077

1079-
private val MIGRATION_26_27: Migration =
1080-
object : Migration(26, 27) {
1081-
override fun migrate(db: SupportSQLiteDatabase) {
1082-
// ProxyEndpoint
1083-
db.execSQL("UPDATE ProxyEndpoint SET proxyAppName = '' WHERE proxyAppName IS NULL")
1084-
db.execSQL("UPDATE ProxyEndpoint SET proxyIP = '' WHERE proxyIP IS NULL")
1085-
db.execSQL("UPDATE ProxyEndpoint SET userName = '' WHERE userName IS NULL")
1086-
db.execSQL("UPDATE ProxyEndpoint SET password = '' WHERE password IS NULL")
1087-
1088-
// DoHEndpoint
1089-
db.execSQL("UPDATE DoHEndpoint SET dohExplanation = '' WHERE dohExplanation IS NULL")
1090-
// DoTEndpoint
1091-
db.execSQL("UPDATE DoTEndpoint SET desc = '' WHERE desc IS NULL")
1092-
// ODoHEndpoint
1093-
db.execSQL("UPDATE ODoHEndpoint SET desc = '' WHERE desc IS NULL")
1094-
// DNSCryptEndpoint
1095-
db.execSQL("UPDATE DNSCryptEndpoint SET dnsCryptExplanation = '' WHERE dnsCryptExplanation IS NULL")
1096-
// DNSCryptRelayEndpoint
1097-
db.execSQL("UPDATE DNSCryptRelayEndpoint SET dnsCryptRelayExplanation = '' WHERE dnsCryptRelayExplanation IS NULL")
1098-
// DNSProxyEndpoint
1099-
db.execSQL("UPDATE DNSProxyEndpoint SET proxyAppName = '' WHERE proxyAppName IS NULL")
1100-
db.execSQL("UPDATE DNSProxyEndpoint SET proxyIP = '' WHERE proxyIP IS NULL")
1101-
1102-
Logger.i(LOG_TAG_APP_DB, "MIGRATION_25_26: Updated ProxyEndpoint, DNSCryptEndpoint, DNSCryptRelayEndpoint, DNSProxyEndpoint, DoHEndpoint, DoTEndpoint, ODoHEndpoint to replace NULL with empty strings")
1103-
1104-
}
1105-
}
1106-
11071078

11081079
// ref: stackoverflow.com/a/57204285
11091080
private fun doesColumnExistInTable(

app/src/main/java/com/celzero/bravedns/database/DnsCryptEndpoint.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DnsCryptEndpoint {
2424
@PrimaryKey(autoGenerate = true) var id: Int = 0
2525
var dnsCryptName: String = ""
2626
var dnsCryptURL: String = ""
27-
var dnsCryptExplanation: String = ""
27+
var dnsCryptExplanation: String? = null
2828
var isSelected: Boolean = true
2929
var isCustom: Boolean = true
3030
var modifiedDataTime: Long = INIT_TIME_MS
@@ -44,7 +44,7 @@ class DnsCryptEndpoint {
4444
id: Int,
4545
dnsCryptName: String,
4646
dnsCryptURL: String,
47-
dnsCryptExplanation: String,
47+
dnsCryptExplanation: String?,
4848
isSelected: Boolean,
4949
isCustom: Boolean,
5050
modifiedDataTime: Long,

app/src/main/java/com/celzero/bravedns/database/DnsCryptRelayEndpoint.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DnsCryptRelayEndpoint {
2424
@PrimaryKey(autoGenerate = true) var id: Int = 0
2525
var dnsCryptRelayName: String = ""
2626
var dnsCryptRelayURL: String = ""
27-
var dnsCryptRelayExplanation: String = ""
27+
var dnsCryptRelayExplanation: String? = null
2828
var isSelected: Boolean = true
2929
var isCustom: Boolean = true
3030
var modifiedDataTime: Long = INIT_TIME_MS
@@ -44,7 +44,7 @@ class DnsCryptRelayEndpoint {
4444
id: Int,
4545
dnsCryptRelayName: String,
4646
dnsCryptRelayURL: String,
47-
dnsCryptRelayExplanation: String,
47+
dnsCryptRelayExplanation: String?,
4848
isSelected: Boolean,
4949
isCustom: Boolean,
5050
modifiedDataTime: Long,

app/src/main/java/com/celzero/bravedns/database/DnsProxyEndpoint.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class DnsProxyEndpoint {
2626
@PrimaryKey(autoGenerate = true) var id: Int = 0
2727
var proxyName: String = ""
2828
var proxyType: String = ""
29-
var proxyAppName: String = ""
30-
var proxyIP: String = ""
29+
var proxyAppName: String? = null
30+
var proxyIP: String? = null
3131
var proxyPort: Int = 0
3232
var isSelected: Boolean = true
3333
var isCustom: Boolean = true
@@ -48,8 +48,8 @@ class DnsProxyEndpoint {
4848
id: Int,
4949
proxyName: String,
5050
proxyType: String,
51-
proxyAppName: String,
52-
proxyIP: String,
51+
proxyAppName: String?,
52+
proxyIP: String?,
5353
proxyPort: Int,
5454
isSelected: Boolean,
5555
isCustom: Boolean,

app/src/main/java/com/celzero/bravedns/database/DoHEndpoint.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DoHEndpoint {
2525
@PrimaryKey(autoGenerate = true) var id: Int = 0
2626
var dohName: String = ""
2727
var dohURL: String = ""
28-
var dohExplanation: String = ""
28+
var dohExplanation: String? = null
2929
var isSelected: Boolean = true
3030
var isCustom: Boolean = true
3131
var isSecure: Boolean = true
@@ -49,7 +49,7 @@ class DoHEndpoint {
4949
id: Int,
5050
dohName: String,
5151
dohURL: String,
52-
dohExplanation: String,
52+
dohExplanation: String?,
5353
isSelected: Boolean,
5454
isCustom: Boolean,
5555
isSecure: Boolean,

app/src/main/java/com/celzero/bravedns/database/DoTEndpoint.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DoTEndpoint {
2525
@PrimaryKey(autoGenerate = true) var id: Int = 0
2626
var name: String = ""
2727
var url: String = ""
28-
var desc: String = ""
28+
var desc: String? = null
2929
var isSelected: Boolean = true
3030
var isCustom: Boolean = true
3131
var isSecure: Boolean = true
@@ -49,7 +49,7 @@ class DoTEndpoint {
4949
id: Int,
5050
name: String,
5151
url: String,
52-
desc: String,
52+
desc: String?,
5353
isSelected: Boolean,
5454
isCustom: Boolean,
5555
isSecure: Boolean,

app/src/main/java/com/celzero/bravedns/database/ODoHEndpoint.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ODoHEndpoint {
2727
var proxy: String = ""
2828
var resolver: String = ""
2929
var proxyIps: String = ""
30-
var desc: String = ""
30+
var desc: String? = null
3131
var isSelected: Boolean = true
3232
var isCustom: Boolean = true
3333
var modifiedDataTime: Long = INIT_TIME_MS
@@ -53,7 +53,7 @@ class ODoHEndpoint {
5353
proxy: String,
5454
resolver: String,
5555
proxyIps: String,
56-
desc: String,
56+
desc: String?,
5757
isSelected: Boolean,
5858
isCustom: Boolean,
5959
modifiedDataTime: Long,

app/src/main/java/com/celzero/bravedns/database/ProxyEndpoint.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class ProxyEndpoint {
3030
// NONE for now, later we can add other types
3131
// ideally this should be an enum (ProxyType)
3232
var proxyType: String = ""
33-
var proxyAppName: String = ""
34-
var proxyIP: String = ""
33+
var proxyAppName: String? = null
34+
var proxyIP: String? = null
3535
var proxyPort: Int = 0
36-
var userName: String = ""
37-
var password: String = ""
36+
var userName: String? = null
37+
var password: String? = null
3838
var isSelected: Boolean = true
3939
var isCustom: Boolean = true
4040
var isUDP: Boolean = false
@@ -56,11 +56,11 @@ class ProxyEndpoint {
5656
proxyName: String,
5757
proxyMode: Int,
5858
proxyType: String,
59-
proxyAppName: String,
60-
proxyIP: String,
59+
proxyAppName: String?,
60+
proxyIP: String?,
6161
proxyPort: Int,
62-
userName: String,
63-
password: String,
62+
userName: String?,
63+
password: String?,
6464
isSelected: Boolean,
6565
isCustom: Boolean,
6666
isUDP: Boolean,

0 commit comments

Comments
 (0)