/**
 * 迁移: 添加奖品表
 * 版本: 0004
 * 日期: 2025-01-10
 */

module.exports = {
  async up(manager) {
    console.log('  - 创建 Prizes 表...');
    
    await manager.executeSql(`
      CREATE TABLE IF NOT EXISTS Prizes (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        activityId INTEGER NOT NULL,
        name TEXT NOT NULL,
        level TEXT NOT NULL CHECK(level IN ('一等奖', '二等奖', '三等奖', '参与奖', '伴手礼')),
        description TEXT,
        image TEXT,
        quantity INTEGER DEFAULT 1,
        sortOrder INTEGER DEFAULT 0,
        createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
        updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP
      );
    `);
  },

  async down(manager) {
    console.log('  - 删除 Prizes 表...');
    await manager.executeSql('DROP TABLE IF EXISTS Prizes;');
  }
};
