CREATE TABLE IF NOT EXISTS "repo_mirrors" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
"repository_id" uuid NOT NULL UNIQUE
REFERENCES "repositories"("id") ON DELETE CASCADE,
"upstream_url" text NOT NULL,
"interval_minutes" integer NOT NULL DEFAULT 1440,
"last_synced_at" timestamp,
"last_status" text,
"last_error" text,
"is_enabled" boolean NOT NULL DEFAULT true,
"created_at" timestamp NOT NULL DEFAULT now(),
"updated_at" timestamp NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS "repo_mirror_runs" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
"mirror_id" uuid NOT NULL REFERENCES "repo_mirrors"("id") ON DELETE CASCADE,
"started_at" timestamp NOT NULL DEFAULT now(),
"finished_at" timestamp,
"status" text NOT NULL DEFAULT 'running',
"message" text,
"exit_code" integer
);
CREATE INDEX IF NOT EXISTS "repo_mirror_runs_mirror_id_idx"
ON "repo_mirror_runs" ("mirror_id", "started_at" DESC);
|