-- Monthly Parça Uzmanları prizes: one row per (TR-month, rank). Written by the -- expert-rewards cron (1st of month 00:00 Europe/Istanbul) when it closes the -- finished season and grants the top 3 voters a subscription extension -- (30/15/7 days). The unique index is the run-once guard — a re-run for the -- same period inserts nothing, so days are never granted twice. CREATE TABLE "oem_expert_rewards" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "period_start" timestamp with time zone NOT NULL, "user_id" uuid NOT NULL, "rank" integer NOT NULL, "points" integer NOT NULL, "reward_days" integer NOT NULL, "granted_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint ALTER TABLE "oem_expert_rewards" ADD CONSTRAINT "oem_expert_rewards_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE UNIQUE INDEX "oem_expert_rewards_period_rank_idx" ON "oem_expert_rewards" USING btree ("period_start","rank");--> statement-breakpoint CREATE INDEX "oem_expert_rewards_user_id_idx" ON "oem_expert_rewards" USING btree ("user_id");