Improve database column references and default category handling (#563)

* Improve default category handling and add cascade to references where possible

* Minor fix for default category

* Make the default category always first in the normalization
This commit is contained in:
Mitchell Syer
2023-05-27 20:41:27 -04:00
committed by GitHub
parent 241abc3956
commit 6a7efafd9f
13 changed files with 76 additions and 31 deletions

View File

@@ -8,8 +8,9 @@ package suwayomi.tachidesk.manga.model.table
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.ReferenceOption
object CategoryMangaTable : IntIdTable() {
val category = reference("category", CategoryTable)
val manga = reference("manga", MangaTable)
val category = reference("category", CategoryTable, ReferenceOption.CASCADE)
val manga = reference("manga", MangaTable, ReferenceOption.CASCADE)
}

View File

@@ -8,6 +8,7 @@ package suwayomi.tachidesk.manga.model.table
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.ReferenceOption
import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.transactions.transaction
@@ -37,7 +38,7 @@ object ChapterTable : IntIdTable() {
val pageCount = integer("page_count").default(-1)
val manga = reference("manga", MangaTable)
val manga = reference("manga", MangaTable, ReferenceOption.CASCADE)
}
fun ChapterTable.toDataClass(chapterEntry: ResultRow) =

View File

@@ -32,7 +32,6 @@ object MangaTable : IntIdTable() {
val thumbnailUrlLastFetched = long("thumbnail_url_last_fetched").default(0)
val inLibrary = bool("in_library").default(false)
val defaultCategory = bool("default_category").default(true)
val inLibraryAt = long("in_library_at").default(0)
// the [source] field name is used by some ancestor of IntIdTable

View File

@@ -8,11 +8,12 @@ package suwayomi.tachidesk.manga.model.table
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.ReferenceOption
object PageTable : IntIdTable() {
val index = integer("index")
val url = varchar("url", 2048)
val imageUrl = varchar("imageUrl", 2048).nullable()
val chapter = reference("chapter", ChapterTable)
val chapter = reference("chapter", ChapterTable, ReferenceOption.CASCADE)
}