From f84edb7860a36bb69cff544c1fc240b514dcdc61 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 25 Mar 2021 07:07:04 +0600 Subject: [PATCH] fix in db --- .../plugins/captcha/db/CaptchaChatsSettingsRepo.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/db/CaptchaChatsSettingsRepo.kt b/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/db/CaptchaChatsSettingsRepo.kt index 6ce9875..4f1369f 100644 --- a/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/db/CaptchaChatsSettingsRepo.kt +++ b/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/db/CaptchaChatsSettingsRepo.kt @@ -2,6 +2,7 @@ package dev.inmo.plagubot.plugins.captcha.db import dev.inmo.micro_utils.repos.exposed.* import dev.inmo.plagubot.plugins.captcha.provider.CaptchaProvider +import dev.inmo.plagubot.plugins.captcha.provider.SimpleCaptchaProvider import dev.inmo.plagubot.plugins.captcha.settings.* import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.toChatId @@ -14,13 +15,17 @@ private val captchaProviderSerialFormat = Json { ignoreUnknownKeys = true } +private val defaultCaptchaProviderValue = captchaProviderSerialFormat.encodeToString(CaptchaProvider.serializer(), SimpleCaptchaProvider()) + class CaptchaChatsSettingsRepo( override val database: Database ) : AbstractExposedCRUDRepo( tableName = "CaptchaChatsSettingsRepo" ) { private val chatIdColumn = long("chatId") - private val captchaProviderColumn = text("captchaProvider") + private val captchaProviderColumn = text("captchaProvider").apply { + default(defaultCaptchaProviderValue) + } private val autoRemoveCommandsColumn = bool("autoRemoveCommands") override val primaryKey = PrimaryKey(chatIdColumn)