Skip to content

Commit 802c1b1

Browse files
feat: Configure Room schema for WidgetDatabase
Added the Room schema definition for the `WidgetDatabase` and configured the KSP arguments to export it. This change introduces the initial schema (version 1) for the `widgets` table, which will store widget placement and sizing information. The schema location is now set in the `app/build.gradle.kts` file.
1 parent b087d4c commit 802c1b1

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

app/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ kotlin {
132132
}
133133
}
134134

135+
// KSP configuration
136+
ksp {
137+
arg("room.schemaLocation", "$projectDir/schemas")
138+
}
135139

136140
dependencies {
137141
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 1,
5+
"identityHash": "7bb466fd015e696c59c3e92d96e53b78",
6+
"entities": [
7+
{
8+
"tableName": "widgets",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`appWidgetId` INTEGER NOT NULL, `col` INTEGER NOT NULL, `row` INTEGER NOT NULL, `width` INTEGER NOT NULL, `height` INTEGER NOT NULL, `cellsW` INTEGER NOT NULL, `cellsH` INTEGER NOT NULL, PRIMARY KEY(`appWidgetId`))",
10+
"fields": [
11+
{
12+
"fieldPath": "appWidgetId",
13+
"columnName": "appWidgetId",
14+
"affinity": "INTEGER",
15+
"notNull": true
16+
},
17+
{
18+
"fieldPath": "col",
19+
"columnName": "col",
20+
"affinity": "INTEGER",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "row",
25+
"columnName": "row",
26+
"affinity": "INTEGER",
27+
"notNull": true
28+
},
29+
{
30+
"fieldPath": "width",
31+
"columnName": "width",
32+
"affinity": "INTEGER",
33+
"notNull": true
34+
},
35+
{
36+
"fieldPath": "height",
37+
"columnName": "height",
38+
"affinity": "INTEGER",
39+
"notNull": true
40+
},
41+
{
42+
"fieldPath": "cellsW",
43+
"columnName": "cellsW",
44+
"affinity": "INTEGER",
45+
"notNull": true
46+
},
47+
{
48+
"fieldPath": "cellsH",
49+
"columnName": "cellsH",
50+
"affinity": "INTEGER",
51+
"notNull": true
52+
}
53+
],
54+
"primaryKey": {
55+
"autoGenerate": false,
56+
"columnNames": [
57+
"appWidgetId"
58+
]
59+
}
60+
}
61+
],
62+
"setupQueries": [
63+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
64+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '7bb466fd015e696c59c3e92d96e53b78')"
65+
]
66+
}
67+
}

0 commit comments

Comments
 (0)