CREATE TABLE "analytic_event" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"type" varchar(45) NOT NULL,
	"post_id" uuid NOT NULL,
	"user_id" uuid,
	"ip" "inet",
	"user_agent" varchar(255),
	"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "analytic_event" ADD CONSTRAINT "analytic_event_post_id_posts_id_fk" FOREIGN KEY ("post_id") REFERENCES "public"."posts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "analytic_event" ADD CONSTRAINT "analytic_event_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "analytic_event_type_index" ON "analytic_event" USING btree ("type");--> statement-breakpoint
CREATE INDEX "analytic_event_ip_index" ON "analytic_event" USING btree ("ip");--> statement-breakpoint
CREATE INDEX "analytic_event_user_agent_index" ON "analytic_event" USING btree ("user_agent");--> statement-breakpoint
CREATE INDEX "analytic_event_created_at_index" ON "analytic_event" USING btree ("created_at");