CREATE DATABASE IF NOT EXISTS hypesearch_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE hypesearch_db;

CREATE TABLE IF NOT EXISTS keyword_tasks (
    id INT AUTO_INCREMENT PRIMARY KEY,
    keyword VARCHAR(255) NOT NULL,
    min_interval_minutes INT NOT NULL DEFAULT 30,
    max_interval_minutes INT NOT NULL DEFAULT 90,
    is_active TINYINT(1) NOT NULL DEFAULT 1,
    sort_order INT NOT NULL DEFAULT 0,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS coordinates (
    id INT AUTO_INCREMENT PRIMARY KEY,
    coordinate_name VARCHAR(100) NOT NULL,
    x INT NOT NULL,
    y INT NOT NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE KEY uniq_coordinate_name (coordinate_name)
);

INSERT INTO keyword_tasks (keyword, min_interval_minutes, max_interval_minutes, is_active, sort_order) VALUES
('Hello World', 30, 90, 1, 1),
('Hello Universe', 20, 40, 1, 2),
('Hello World', 25, 50, 1, 3);
