@@ -814,39 +814,6 @@ class Database {
814814 }
815815 }
816816
817- /**
818- * scheduler 表旧版本字段是 targetId(TEXT),存 channel_session.id 的字符串形式。
819- * 新版本拆为 channelSessionId(INT) + profileId(INT)。
820- * 在 sync({alter:true}) 重建表丢列之前,把数据搬过去。
821- * 已迁移的库(没 targetId 列)跳过。
822- */
823- private async migrateSchedulerColumns ( ) {
824- const [ cols ] = await this . sequelize . query ( "PRAGMA table_info(scheduler)" ) as [ any [ ] , any ] ;
825- const names = new Set ( cols . map ( ( c : any ) => c . name ) ) ;
826- if ( ! names . has ( "targetId" ) ) return ;
827-
828- if ( ! names . has ( "channelSessionId" ) ) {
829- await this . sequelize . query ( "ALTER TABLE scheduler ADD COLUMN channelSessionId INTEGER NOT NULL DEFAULT 0" ) ;
830- }
831- if ( ! names . has ( "profileId" ) ) {
832- await this . sequelize . query ( "ALTER TABLE scheduler ADD COLUMN profileId INTEGER NOT NULL DEFAULT 0" ) ;
833- }
834- await this . sequelize . query ( `
835- UPDATE scheduler
836- SET channelSessionId = CAST(targetId AS INTEGER)
837- WHERE channelSessionId = 0 AND targetId != ''
838- ` ) ;
839- await this . sequelize . query ( `
840- UPDATE scheduler
841- SET profileId = COALESCE(
842- (SELECT cs.profileId FROM channel_session cs WHERE cs.id = scheduler.channelSessionId),
843- 0
844- )
845- WHERE profileId = 0 AND channelSessionId > 0
846- ` ) ;
847- logger . info ( "Scheduler table migrated: targetId -> channelSessionId + profileId" ) ;
848- }
849-
850817 async sync ( ) {
851818 return this . withLock ( async ( ) => {
852819 await this . state . sync ( { alter : true } ) ;
@@ -863,9 +830,6 @@ class Database {
863830 await this . channelUser . sync ( { alter } ) ;
864831 await this . sessionProfile . sync ( { alter } ) ;
865832 await this . channelSession . sync ( { alter } ) ;
866- // scheduler 旧 schema 把 channel_session.id 存在 targetId(TEXT) 里。
867- // 新 schema 拆成 channelSessionId(INT) + profileId(INT)。在 sync 重建表前先迁移数据。
868- await this . migrateSchedulerColumns ( ) ;
869833 await this . scheduler . sync ( { alter } ) ;
870834 await this . usageLogs . sync ( { alter } ) ;
871835 await this . heartbeat . sync ( { alter } ) ;
0 commit comments