feat(data): the Room database, its four tables and their DAOs

alarms, timers, world_clocks and stopwatch_laps, with the schema exported
to app/schemas and committed so migrations can be tested from v1 onwards.

The DAOs return Flows for reads and keep every multi-step write inside a
@Transaction, so a read-modify-write cannot lose a concurrent one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
makiolajandClaude Opus 5 committed 2026-09-11 13:52:11 +02:00
1 parent a2beae94ec
commit 778d08af24
13 files changed
+787

No files matched your search

@@ -0,0 +1,30 @@
package de.jeanlucmakiola.clockula.data.db
import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.Test
import java.io.File
/**
* The exported schema is the contract a migration is reviewed against. If it is
* not committed, docs/PLAN.md §12's "migrations tested from v1" has nothing to
* test against.
*/
class SchemaExportTest {
private val schemasDir: File =
listOf(File("schemas"), File("app/schemas")).firstOrNull { it.isDirectory } ?: File("app/schemas")
@Test
fun `the version 1 schema is exported and committed`() {
val schema = File(schemasDir, "de.jeanlucmakiola.clockula.data.db.ClockulaDatabase/1.json")
assertThat(schema.isFile).isTrue()
val text = schema.readText()
assertThat(text).isNotEmpty()
assertThat(text).contains("\"version\": 1")
assertThat(text).contains("\"tableName\": \"alarms\"")
assertThat(text).contains("\"tableName\": \"timers\"")
assertThat(text).contains("\"tableName\": \"world_clocks\"")
assertThat(text).contains("\"tableName\": \"stopwatch_laps\"")
}
}