[
  {
    "type": "create_table",
    "description": "Create bsNotes table for backstock notes",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'bsNotes'",
    "sql": "CREATE TABLE `bsNotes` (`id` INT AUTO_INCREMENT PRIMARY KEY, `authorEmployeeId` INT, `authorName` VARCHAR(100), `title` VARCHAR(200), `content` TEXT NOT NULL, `contentHtml` TEXT, `isPinned` TINYINT DEFAULT 0, `startDate` DATE NOT NULL, `endDate` DATE, `createdAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `updatedAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `deletedAt` TIMESTAMP NULL, INDEX idx_author (authorEmployeeId), INDEX idx_pinned (isPinned), INDEX idx_dates (startDate, endDate), INDEX idx_deleted (deletedAt)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
  },
  {
    "type": "create_table",
    "description": "Create bsNote_Reactions table for note likes",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'bsNote_Reactions'",
    "sql": "CREATE TABLE `bsNote_Reactions` (`id` INT AUTO_INCREMENT PRIMARY KEY, `noteId` INT NOT NULL, `employeeId` INT NOT NULL, `reactionType` ENUM('like', 'heart') DEFAULT 'like', `createdAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY uk_note_employee (noteId, employeeId, reactionType), INDEX idx_note (noteId), FOREIGN KEY (noteId) REFERENCES bsNotes(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
  },
  {
    "type": "create_table",
    "description": "Create bsNote_Comments table for note comments/replies",
    "database": "{{store}}",
    "check_query": "SHOW TABLES LIKE 'bsNote_Comments'",
    "sql": "CREATE TABLE `bsNote_Comments` (`id` INT AUTO_INCREMENT PRIMARY KEY, `noteId` INT NOT NULL, `employeeId` INT NOT NULL, `employeeName` VARCHAR(100), `comment` VARCHAR(2000) NOT NULL, `createdAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, INDEX idx_note (noteId), INDEX idx_employee (employeeId), FOREIGN KEY (noteId) REFERENCES bsNotes(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
  }
]
