Skip to content

Commit 2ce3913

Browse files
authored
fix(android): register v2→v3 and v3→v4 Room migrations, bump DB to v4 (#23)
* chore(android): commit Room schema JSONs for DB v2 and v3 * fix(android): register v2->v3 and v3->v4 migrations, bump DB to v4
1 parent 61a1c5c commit 2ce3913

7 files changed

Lines changed: 577 additions & 6 deletions

File tree

android/app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ dependencies {
167167
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0")
168168
testImplementation("com.google.truth:truth:1.4.4")
169169
testImplementation("org.json:json:20240303")
170+
testImplementation("org.xerial:sqlite-jdbc:3.45.1.0")
170171

171172
// Instrumented tests (Room migration)
172173
androidTestImplementation("androidx.test.ext:junit:1.2.1")
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 2,
5+
"identityHash": "d4abfbbd22cc59fc3cf354366d60a1a7",
6+
"entities": [
7+
{
8+
"tableName": "profiles",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `debugTiming` INTEGER NOT NULL, `socksHost` TEXT NOT NULL, `socksPort` INTEGER NOT NULL, `googleHost` TEXT NOT NULL, `sniJson` TEXT NOT NULL, `scriptKeysText` TEXT NOT NULL, `tunnelKey` TEXT NOT NULL, `isSelected` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL)",
10+
"fields": [
11+
{
12+
"fieldPath": "id",
13+
"columnName": "id",
14+
"affinity": "INTEGER",
15+
"notNull": true
16+
},
17+
{
18+
"fieldPath": "name",
19+
"columnName": "name",
20+
"affinity": "TEXT",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "debugTiming",
25+
"columnName": "debugTiming",
26+
"affinity": "INTEGER",
27+
"notNull": true
28+
},
29+
{
30+
"fieldPath": "socksHost",
31+
"columnName": "socksHost",
32+
"affinity": "TEXT",
33+
"notNull": true
34+
},
35+
{
36+
"fieldPath": "socksPort",
37+
"columnName": "socksPort",
38+
"affinity": "INTEGER",
39+
"notNull": true
40+
},
41+
{
42+
"fieldPath": "googleHost",
43+
"columnName": "googleHost",
44+
"affinity": "TEXT",
45+
"notNull": true
46+
},
47+
{
48+
"fieldPath": "sniJson",
49+
"columnName": "sniJson",
50+
"affinity": "TEXT",
51+
"notNull": true
52+
},
53+
{
54+
"fieldPath": "scriptKeysText",
55+
"columnName": "scriptKeysText",
56+
"affinity": "TEXT",
57+
"notNull": true
58+
},
59+
{
60+
"fieldPath": "tunnelKey",
61+
"columnName": "tunnelKey",
62+
"affinity": "TEXT",
63+
"notNull": true
64+
},
65+
{
66+
"fieldPath": "isSelected",
67+
"columnName": "isSelected",
68+
"affinity": "INTEGER",
69+
"notNull": true
70+
},
71+
{
72+
"fieldPath": "createdAt",
73+
"columnName": "createdAt",
74+
"affinity": "INTEGER",
75+
"notNull": true
76+
}
77+
],
78+
"primaryKey": {
79+
"autoGenerate": true,
80+
"columnNames": [
81+
"id"
82+
]
83+
},
84+
"indices": [],
85+
"foreignKeys": []
86+
}
87+
],
88+
"views": [],
89+
"setupQueries": [
90+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
91+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd4abfbbd22cc59fc3cf354366d60a1a7')"
92+
]
93+
}
94+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 3,
5+
"identityHash": "7cf2680a4a5066b2e91da28c08c7e4d0",
6+
"entities": [
7+
{
8+
"tableName": "profiles",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `debugTiming` INTEGER NOT NULL, `socksHost` TEXT NOT NULL, `socksPort` INTEGER NOT NULL, `socksUser` TEXT NOT NULL, `socksPass` TEXT NOT NULL, `googleHost` TEXT NOT NULL, `sniJson` TEXT NOT NULL, `scriptKeysText` TEXT NOT NULL, `tunnelKey` TEXT NOT NULL, `coalesceStepMs` INTEGER NOT NULL, `idleSlotsPerBucket` INTEGER NOT NULL, `isSelected` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL)",
10+
"fields": [
11+
{
12+
"fieldPath": "id",
13+
"columnName": "id",
14+
"affinity": "INTEGER",
15+
"notNull": true
16+
},
17+
{
18+
"fieldPath": "name",
19+
"columnName": "name",
20+
"affinity": "TEXT",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "debugTiming",
25+
"columnName": "debugTiming",
26+
"affinity": "INTEGER",
27+
"notNull": true
28+
},
29+
{
30+
"fieldPath": "socksHost",
31+
"columnName": "socksHost",
32+
"affinity": "TEXT",
33+
"notNull": true
34+
},
35+
{
36+
"fieldPath": "socksPort",
37+
"columnName": "socksPort",
38+
"affinity": "INTEGER",
39+
"notNull": true
40+
},
41+
{
42+
"fieldPath": "socksUser",
43+
"columnName": "socksUser",
44+
"affinity": "TEXT",
45+
"notNull": true
46+
},
47+
{
48+
"fieldPath": "socksPass",
49+
"columnName": "socksPass",
50+
"affinity": "TEXT",
51+
"notNull": true
52+
},
53+
{
54+
"fieldPath": "googleHost",
55+
"columnName": "googleHost",
56+
"affinity": "TEXT",
57+
"notNull": true
58+
},
59+
{
60+
"fieldPath": "sniJson",
61+
"columnName": "sniJson",
62+
"affinity": "TEXT",
63+
"notNull": true
64+
},
65+
{
66+
"fieldPath": "scriptKeysText",
67+
"columnName": "scriptKeysText",
68+
"affinity": "TEXT",
69+
"notNull": true
70+
},
71+
{
72+
"fieldPath": "tunnelKey",
73+
"columnName": "tunnelKey",
74+
"affinity": "TEXT",
75+
"notNull": true
76+
},
77+
{
78+
"fieldPath": "coalesceStepMs",
79+
"columnName": "coalesceStepMs",
80+
"affinity": "INTEGER",
81+
"notNull": true
82+
},
83+
{
84+
"fieldPath": "idleSlotsPerBucket",
85+
"columnName": "idleSlotsPerBucket",
86+
"affinity": "INTEGER",
87+
"notNull": true
88+
},
89+
{
90+
"fieldPath": "isSelected",
91+
"columnName": "isSelected",
92+
"affinity": "INTEGER",
93+
"notNull": true
94+
},
95+
{
96+
"fieldPath": "createdAt",
97+
"columnName": "createdAt",
98+
"affinity": "INTEGER",
99+
"notNull": true
100+
}
101+
],
102+
"primaryKey": {
103+
"autoGenerate": true,
104+
"columnNames": [
105+
"id"
106+
]
107+
},
108+
"indices": [],
109+
"foreignKeys": []
110+
}
111+
],
112+
"views": [],
113+
"setupQueries": [
114+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
115+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '7cf2680a4a5066b2e91da28c08c7e4d0')"
116+
]
117+
}
118+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 4,
5+
"identityHash": "21577208642f1e1ac37aa9674fd36d98",
6+
"entities": [
7+
{
8+
"tableName": "profiles",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `debugTiming` INTEGER NOT NULL, `socksHost` TEXT NOT NULL, `socksPort` INTEGER NOT NULL, `socksUser` TEXT NOT NULL, `socksPass` TEXT NOT NULL, `googleHost` TEXT NOT NULL, `sniJson` TEXT NOT NULL, `scriptKeysText` TEXT NOT NULL, `tunnelKey` TEXT NOT NULL, `coalesceStepMs` INTEGER NOT NULL, `idleSlotsPerBucket` INTEGER NOT NULL, `remoteUrl` TEXT, `isSelected` INTEGER NOT NULL, `createdAt` INTEGER NOT NULL)",
10+
"fields": [
11+
{
12+
"fieldPath": "id",
13+
"columnName": "id",
14+
"affinity": "INTEGER",
15+
"notNull": true
16+
},
17+
{
18+
"fieldPath": "name",
19+
"columnName": "name",
20+
"affinity": "TEXT",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "debugTiming",
25+
"columnName": "debugTiming",
26+
"affinity": "INTEGER",
27+
"notNull": true
28+
},
29+
{
30+
"fieldPath": "socksHost",
31+
"columnName": "socksHost",
32+
"affinity": "TEXT",
33+
"notNull": true
34+
},
35+
{
36+
"fieldPath": "socksPort",
37+
"columnName": "socksPort",
38+
"affinity": "INTEGER",
39+
"notNull": true
40+
},
41+
{
42+
"fieldPath": "socksUser",
43+
"columnName": "socksUser",
44+
"affinity": "TEXT",
45+
"notNull": true
46+
},
47+
{
48+
"fieldPath": "socksPass",
49+
"columnName": "socksPass",
50+
"affinity": "TEXT",
51+
"notNull": true
52+
},
53+
{
54+
"fieldPath": "googleHost",
55+
"columnName": "googleHost",
56+
"affinity": "TEXT",
57+
"notNull": true
58+
},
59+
{
60+
"fieldPath": "sniJson",
61+
"columnName": "sniJson",
62+
"affinity": "TEXT",
63+
"notNull": true
64+
},
65+
{
66+
"fieldPath": "scriptKeysText",
67+
"columnName": "scriptKeysText",
68+
"affinity": "TEXT",
69+
"notNull": true
70+
},
71+
{
72+
"fieldPath": "tunnelKey",
73+
"columnName": "tunnelKey",
74+
"affinity": "TEXT",
75+
"notNull": true
76+
},
77+
{
78+
"fieldPath": "coalesceStepMs",
79+
"columnName": "coalesceStepMs",
80+
"affinity": "INTEGER",
81+
"notNull": true
82+
},
83+
{
84+
"fieldPath": "idleSlotsPerBucket",
85+
"columnName": "idleSlotsPerBucket",
86+
"affinity": "INTEGER",
87+
"notNull": true
88+
},
89+
{
90+
"fieldPath": "remoteUrl",
91+
"columnName": "remoteUrl",
92+
"affinity": "TEXT",
93+
"notNull": false
94+
},
95+
{
96+
"fieldPath": "isSelected",
97+
"columnName": "isSelected",
98+
"affinity": "INTEGER",
99+
"notNull": true
100+
},
101+
{
102+
"fieldPath": "createdAt",
103+
"columnName": "createdAt",
104+
"affinity": "INTEGER",
105+
"notNull": true
106+
}
107+
],
108+
"primaryKey": {
109+
"autoGenerate": true,
110+
"columnNames": [
111+
"id"
112+
]
113+
},
114+
"indices": [],
115+
"foreignKeys": []
116+
}
117+
],
118+
"views": [],
119+
"setupQueries": [
120+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
121+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '21577208642f1e1ac37aa9674fd36d98')"
122+
]
123+
}
124+
}

android/app/src/main/java/com/gooserelay/gooserelayvpn/data/local/AppDatabase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import androidx.room.Database
55
import androidx.room.Room
66
import androidx.room.RoomDatabase
77

8-
@Database(entities = [ProfileEntity::class], version = 3, exportSchema = true)
8+
@Database(entities = [ProfileEntity::class], version = 4, exportSchema = true)
99
abstract class AppDatabase : RoomDatabase() {
1010
abstract fun profileDao(): ProfileDao
1111

0 commit comments

Comments
 (0)