CREATE EXTENSION IF NOT EXISTS pgcrypto;

CREATE TABLE IF NOT EXISTS public.cluster_mirrors (
    id bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    created_at timestamptz NOT NULL DEFAULT now(),
    cluster_mirror_id uuid NOT NULL DEFAULT gen_random_uuid() UNIQUE,
    time bigint NOT NULL DEFAULT EXTRACT(EPOCH FROM now())::bigint,
    url text NOT NULL UNIQUE,
    is_active boolean NOT NULL DEFAULT true,
    priority integer NOT NULL DEFAULT 100,
    updated_at timestamptz NOT NULL DEFAULT now()
);

INSERT INTO public.cluster_mirrors (url, priority)
VALUES
    ('https://athena-db.com', 10),
    ('https://mirror1.athena-db.com', 20),
    ('https://mirror2.athena-db.com', 30),
    ('https://mirror3.athena-db.com', 40)
ON CONFLICT (url) DO NOTHING;
