CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    email VARCHAR(255) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    reseller_id VARCHAR(50) NOT NULL,
    created DATETIME,
    modified DATETIME
);

CREATE TABLE zones (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    reseller_id VARCHAR(50) NOT NULL,
    zone_name VARCHAR(255) NOT NULL,
    zone_id VARCHAR(255) NOT NULL,
    standby_pbx_hostname VARCHAR(255) NOT NULL,
    is_failed_over BOOLEAN DEFAULT FALSE,
    created DATETIME,
    modified DATETIME,
    FOREIGN KEY (user_id) REFERENCES users(id)
);

CREATE TABLE dns_records (
    id INT AUTO_INCREMENT PRIMARY KEY,
    zone_id INT NOT NULL,
    record_type VARCHAR(10) NOT NULL,
    name VARCHAR(255) NOT NULL,
    content TEXT NOT NULL,
    priority INT,
    created DATETIME,
    modified DATETIME,
    FOREIGN KEY (zone_id) REFERENCES zones(id)
); 