
CREATE TABLE "public"."user_history" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "user_id" uuid NOT NULL, "tenant_id" uuid NOT NULL, "account_id" uuid NOT NULL, "module" text NOT NULL, "data" text NOT NULL, "created_at" timestamp NOT NULL DEFAULT now(), "updated_at" timestamp NOT NULL DEFAULT now(), PRIMARY KEY ("id") , FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON UPDATE restrict ON DELETE restrict, FOREIGN KEY ("tenant_id") REFERENCES "public"."tenant"("id") ON UPDATE restrict ON DELETE restrict, FOREIGN KEY ("account_id") REFERENCES "public"."cloud_accounts"("id") ON UPDATE restrict ON DELETE restrict, CONSTRAINT "module_check" CHECK ("module" in ('log_query_es', 'log_query_loki', 'metrics_query_prometheus')));
CREATE EXTENSION IF NOT EXISTS pgcrypto;
