]> uap-core.de Git - rssreader.git/commitdiff
add FeedGroup
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 12 Aug 2025 10:26:02 +0000 (12:26 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 12 Aug 2025 10:26:02 +0000 (12:26 +0200)
rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt
rss-application/src/main/kotlin/de/unixwork/rssreader/FeedCollection.kt
rss-application/src/main/kotlin/de/unixwork/rssreader/FeedGroup.kt [new file with mode: 0644]

index 97d993575d6a57c750431844eeae48700e05ee10..af002faa106dc493a79d1991fc5d3cc1d50cf4f0 100644 (file)
@@ -25,11 +25,19 @@ object Database {
         stmt.close()
 
         if (!tableExists) {
-            println("Database empty — creating tables...")
+            println("Database empty: creating tables")
             conn.createStatement().use { createStmt ->
+                createStmt.addBatch("""
+                    CREATE TABLE groups (
+                        group_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
+                        name VARCHAR
+                    )
+                """.trimIndent())
+
                 createStmt.addBatch("""
                     CREATE TABLE feedcollections (
                         feedcollection_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
+                        group_id INT NOT NULL REFERENCES groups(group_id) ON DELETE CASCADE,
                         name VARCHAR,
                         update_interval INT
                     )
index 6937d931d0fd27d244d8e7b5c900226fc319854d..13762614d718c9159d5c0ceb068075106bc68f2d 100644 (file)
@@ -2,7 +2,8 @@ package de.unixwork.rssreader
 
 import de.unixwork.ui.Document
 
-class FeedCollection(name: String) : Document() {
+class FeedCollection(id: Int, name: String) : Document() {
+    val id = id
     val name = name
     val items = list<Item>("items")
 }
\ No newline at end of file
diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedGroup.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/FeedGroup.kt
new file mode 100644 (file)
index 0000000..dc597f3
--- /dev/null
@@ -0,0 +1,6 @@
+package de.unixwork.rssreader
+
+class FeedGroup(id: Int, name: String) {
+    val id = id
+    val name: String = name
+}
\ No newline at end of file