Skip to content

Commit 4698e7b

Browse files
committed
feat: update database schema for search history and repository metadata
- Implement `MIGRATION_6_7` to create a new `search_history` table for storing search queries and timestamps. - Update `MIGRATION_5_6` to include additional repository metadata in the `seen_repos` table, including name, owner info, description, language, and URL. - Register `MIGRATION_6_7` in the database initialization logic.
1 parent fe68d44 commit 4698e7b

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

core/data/src/androidMain/kotlin/zed/rainxch/core/data/local/db/initDatabase.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import zed.rainxch.core.data.local.db.migrations.MIGRATION_2_3
88
import zed.rainxch.core.data.local.db.migrations.MIGRATION_3_4
99
import zed.rainxch.core.data.local.db.migrations.MIGRATION_4_5
1010
import zed.rainxch.core.data.local.db.migrations.MIGRATION_5_6
11+
import zed.rainxch.core.data.local.db.migrations.MIGRATION_6_7
1112
import zed.rainxch.core.data.local.db.migrations.MIGRATION_7_8
1213

1314
fun initDatabase(context: Context): AppDatabase {
@@ -24,6 +25,7 @@ fun initDatabase(context: Context): AppDatabase {
2425
MIGRATION_3_4,
2526
MIGRATION_4_5,
2627
MIGRATION_5_6,
28+
MIGRATION_6_7,
2729
MIGRATION_7_8,
2830
).build()
2931
}

core/data/src/androidMain/kotlin/zed/rainxch/core/data/local/db/migrations/MIGRATION_5_6.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ val MIGRATION_5_6 =
1010
"""
1111
CREATE TABLE IF NOT EXISTS seen_repos (
1212
repoId INTEGER NOT NULL PRIMARY KEY,
13+
repoName TEXT NOT NULL DEFAULT '',
14+
repoOwner TEXT NOT NULL DEFAULT '',
15+
repoOwnerAvatarUrl TEXT NOT NULL DEFAULT '',
16+
repoDescription TEXT,
17+
primaryLanguage TEXT,
18+
repoUrl TEXT NOT NULL DEFAULT '',
1319
seenAt INTEGER NOT NULL
1420
)
1521
""".trimIndent(),
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package zed.rainxch.core.data.local.db.migrations
2+
3+
import androidx.room.migration.Migration
4+
import androidx.sqlite.db.SupportSQLiteDatabase
5+
6+
val MIGRATION_6_7 =
7+
object : Migration(6, 7) {
8+
override fun migrate(db: SupportSQLiteDatabase) {
9+
db.execSQL(
10+
"""
11+
CREATE TABLE IF NOT EXISTS search_history (
12+
query TEXT NOT NULL PRIMARY KEY,
13+
searchedAt INTEGER NOT NULL
14+
)
15+
""".trimIndent(),
16+
)
17+
}
18+
}

0 commit comments

Comments
 (0)