-- Создание таблицы для хранения партнерских ссылок
CREATE TABLE IF NOT EXISTS `affiliate_links` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `user_id` INT(11) NOT NULL,
  `affiliate_code` VARCHAR(50) NOT NULL UNIQUE,
  `affiliate_link` TEXT NOT NULL,
  `bot_branch` VARCHAR(20) NOT NULL DEFAULT 'main',
  `clicks_count` INT(11) NOT NULL DEFAULT 0,
  `created_at` DATETIME NOT NULL,
  `updated_at` DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `bot_branch` (`bot_branch`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
