-- Create dashboards table
CREATE TABLE IF NOT EXISTS dashboards (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    code VARCHAR(100) NOT NULL UNIQUE,
    priority INTEGER DEFAULT 0,
    metabase_api_key TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    CONSTRAINT unique_dashboard_code UNIQUE (code)
);

-- Create index on code for faster lookups
CREATE INDEX IF NOT EXISTS idx_dashboards_code ON dashboards(code);

-- Create index on priority for ordered fetching
CREATE INDEX IF NOT EXISTS idx_dashboards_priority ON dashboards(priority);