summaryrefslogtreecommitdiff
path: root/db/migrations/0214_mature_norman_osborn.sql
blob: ca5c33595ee61227b8229641697e5fd04a780365 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
CREATE TABLE "file_download_logs" (
	"id" serial PRIMARY KEY NOT NULL,
	"file_id" integer NOT NULL,
	"user_id" varchar(50) NOT NULL,
	"user_email" varchar(255),
	"user_name" varchar(100),
	"user_role" varchar(50),
	"user_ip" "inet",
	"user_agent" text,
	"file_name" varchar(255),
	"file_path" varchar(500),
	"file_size" integer,
	"downloaded_at" timestamp with time zone DEFAULT now() NOT NULL,
	"success" boolean NOT NULL,
	"error_message" text,
	"session_id" varchar(100),
	"request_id" varchar(50),
	"referer" text,
	"download_duration_ms" integer
);
--> statement-breakpoint
CREATE TABLE "user_download_stats" (
	"id" serial PRIMARY KEY NOT NULL,
	"user_id" varchar(50) NOT NULL,
	"date" timestamp with time zone NOT NULL,
	"total_downloads" integer DEFAULT 0 NOT NULL,
	"total_bytes" integer DEFAULT 0 NOT NULL,
	"unique_files" integer DEFAULT 0 NOT NULL,
	"last_download_at" timestamp with time zone
);