Skip to content

Commit

Permalink
feat(mysql): add initialization for teach/schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Oct 15, 2020
1 parent 1078fcd commit c11add2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-schedule/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface Schedule {
session: Session
}

extendDatabase(MysqlDatabase, (Database) => {
extendDatabase<typeof MysqlDatabase>('koishi-plugin-mysql', (Database) => {
Object.assign(Database.tables.schedule = [
'PRIMARY KEY (`id`) USING BTREE',
], {
Expand Down
20 changes: 19 additions & 1 deletion packages/plugin-teach/src/database/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,26 @@ extendDatabase<typeof MysqlDatabase>('koishi-plugin-mysql', {
},
})

extendDatabase<typeof MysqlDatabase>('koishi-plugin-mysql', ({ listFields }) => {
extendDatabase<typeof MysqlDatabase>('koishi-plugin-mysql', ({ listFields, tables }) => {
listFields.push('dialogue.groups', 'dialogue.predecessors')

Object.assign(tables.dialogue = [
'PRIMARY KEY (`id`) USING BTREE',
], {
id: `INT(11) UNSIGNED NOT NULL AUTO_INCREMENT`,
flag: `INT(10) UNSIGNED NOT NULL DEFAULT '0'`,
probS: `DECIMAL(4,3) UNSIGNED NOT NULL DEFAULT '1.000'`,
probA: `DECIMAL(4,3) UNSIGNED NOT NULL DEFAULT '0.000'`,
startTime: `INT(10) NOT NULL DEFAULT '0'`,
endTime: `INT(10) NOT NULL DEFAULT '0'`,
groups: `TINYTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci'`,
original: `TINYTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci'`,
question: `TINYTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci'`,
answer: `TEXT(65535) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci'`,
predecessors: `TINYTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci'`,
successorTimeout: `INT(10) UNSIGNED NOT NULL DEFAULT '0'`,
writer: `BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'`,
})
})

export default function apply(ctx: Context, config: Dialogue.Config) {
Expand Down

0 comments on commit c11add2

Please sign in to comment.