DROP VIEW "public"."v_surveys";--> statement-breakpoint
ALTER TABLE "auth"."users" ADD COLUMN "state" integer;--> statement-breakpoint
ALTER TABLE "auth"."users" ADD COLUMN "municipality" integer;--> statement-breakpoint
ALTER TABLE "auth"."users" ADD COLUMN "parish" integer;--> statement-breakpoint
ALTER TABLE "auth"."users" ADD CONSTRAINT "users_state_states_id_fk" FOREIGN KEY ("state") REFERENCES "public"."states"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "auth"."users" ADD CONSTRAINT "users_municipality_municipalities_id_fk" FOREIGN KEY ("municipality") REFERENCES "public"."municipalities"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "auth"."users" ADD CONSTRAINT "users_parish_parishes_id_fk" FOREIGN KEY ("parish") REFERENCES "public"."parishes"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
CREATE VIEW "public"."v_surveys" AS (select id as survey_id, title, description, created_at, closing_date, target_audience from surveys
where published = true);