CREATE TABLE "analytic_event_archive" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"type" varchar(45) NOT NULL,
	"post_id" uuid NOT NULL,
	"count" integer NOT NULL,
	"from" timestamp NOT NULL,
	"to" timestamp NOT NULL
);
--> statement-breakpoint
DROP TABLE "post_stats" CASCADE;--> statement-breakpoint
DROP TABLE "post_views" CASCADE;--> statement-breakpoint
ALTER TABLE "analytic_event_archive" ADD CONSTRAINT "analytic_event_archive_post_id_posts_id_fk" FOREIGN KEY ("post_id") REFERENCES "public"."posts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "analytic_event_archive_type_index" ON "analytic_event_archive" USING btree ("type");--> statement-breakpoint
CREATE INDEX "analytic_event_archive_count_index" ON "analytic_event_archive" USING btree ("count");--> statement-breakpoint
CREATE INDEX "analytic_event_archive_from_index" ON "analytic_event_archive" USING btree ("from");--> statement-breakpoint
CREATE INDEX "analytic_event_archive_to_index" ON "analytic_event_archive" USING btree ("to");