This commit is contained in:
Aria Moradi 2021-03-07 22:12:38 +03:30
parent 7157e07328
commit a59f974537
2 changed files with 7 additions and 4 deletions

View File

@ -23,10 +23,9 @@ object DBMangaer {
} }
fun makeDataBaseTables() { fun makeDataBaseTables() {
// mention db object to connect // must mention db object so the lazy block executes
DBMangaer.db val db = DBMangaer.db
// val db = DBMangaer.db db.useNestedTransactions = true
// db.useNestedTransactions = true
transaction { transaction {
SchemaUtils.createMissingTablesAndColumns( SchemaUtils.createMissingTablesAndColumns(

View File

@ -1,6 +1,7 @@
package ir.armor.tachidesk.util package ir.armor.tachidesk.util
import ir.armor.tachidesk.database.dataclass.CategoryDataClass import ir.armor.tachidesk.database.dataclass.CategoryDataClass
import ir.armor.tachidesk.database.table.CategoryMangaTable
import ir.armor.tachidesk.database.table.CategoryTable import ir.armor.tachidesk.database.table.CategoryTable
import ir.armor.tachidesk.database.table.toDataClass import ir.armor.tachidesk.database.table.toDataClass
import org.jetbrains.exposed.sql.SortOrder import org.jetbrains.exposed.sql.SortOrder
@ -49,6 +50,9 @@ fun reorderCategory(categoryId: Int, from: Int, to: Int) {
fun removeCategory(categoryId: Int) { fun removeCategory(categoryId: Int) {
transaction { transaction {
CategoryMangaTable.select { CategoryMangaTable.category eq categoryId }.forEach {
removeMangaFromCategory(it[CategoryMangaTable.manga].value, categoryId)
}
CategoryTable.deleteWhere { CategoryTable.id eq categoryId } CategoryTable.deleteWhere { CategoryTable.id eq categoryId }
} }
} }