CREATE TABLE "certifications" ( "id" serial PRIMARY KEY NOT NULL, "name" text NOT NULL ); --> statement-breakpoint ALTER TABLE "certifications" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint CREATE TABLE "drone_models" ( "id" serial PRIMARY KEY NOT NULL, "name" text NOT NULL ); --> statement-breakpoint ALTER TABLE "drone_models" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint CREATE TABLE "pilots" ( "id" uuid PRIMARY KEY NOT NULL, "name" text, "location" text, "latitude" double precision, "longitude" double precision, "company" text, "position" text, "description" text, "differentiation" text, "coverage_areas" text, "specialization_areas" text, "certification_ids" integer[], "drone_model_ids" integer[], "email" text ); --> statement-breakpoint ALTER TABLE "pilots" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint ALTER TABLE "pilots" ADD CONSTRAINT "pilots_id_fkey" FOREIGN KEY ("id") REFERENCES "auth"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE POLICY "select-certifications" ON "certifications" AS PERMISSIVE FOR SELECT TO "authenticated" USING (true);--> statement-breakpoint CREATE POLICY "select-drone-models" ON "drone_models" AS PERMISSIVE FOR SELECT TO "authenticated" USING (true);--> statement-breakpoint CREATE POLICY "select-own-pilot" ON "pilots" AS PERMISSIVE FOR SELECT TO "authenticated" USING ("pilots"."id" = auth.uid());--> statement-breakpoint CREATE POLICY "update-own-pilot" ON "pilots" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ("pilots"."id" = auth.uid()) WITH CHECK ("pilots"."id" = auth.uid());--> statement-breakpoint CREATE POLICY "insert-pilot" ON "pilots" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("pilots"."id" = auth.uid());