import { MigrationInterface, QueryRunner } from 'typeorm'; export class CreateFeishuAssessmentSessionTable1773200000001 implements MigrationInterface { name = 'CreateFeishuAssessmentSessionTable1773200000001'; public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(` CREATE TABLE feishu_assessment_sessions ( id VARCHAR(36) PRIMARY KEY, bot_id VARCHAR(36) NOT NULL, open_id VARCHAR(255) NOT NULL, assessment_session_id VARCHAR(36) NOT NULL, status ENUM('active', 'completed', 'cancelled') DEFAULT 'active', current_question_index INT DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, INDEX idx_bot_open (bot_id, open_id), INDEX idx_assessment_session (assessment_session_id), CONSTRAINT fk_feishu_assessment_bot FOREIGN KEY (bot_id) REFERENCES feishu_bots(id) ON DELETE CASCADE ); `); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(` DROP TABLE feishu_assessment_sessions; `); } }