CREATE TABLE public.file (
	id serial NOT NULL,
	user_id int4 NOT NULL,
	uuid uuid NOT NULL,
	name varchar DEFAULT '' NOT NULL,
	"size" int DEFAULT 0 NOT NULL,
	"type" varchar DEFAULT 'application/octet-stream' NOT NULL,
	modified timestamptz DEFAULT NOW() NOT NULL,
	CONSTRAINT file_pk PRIMARY KEY (id),
	CONSTRAINT file_user_fk FOREIGN KEY (user_id) REFERENCES public."user"(id) ON DELETE RESTRICT ON UPDATE RESTRICT
);

ALTER TABLE public.file ADD CONSTRAINT file_user_uuid_unique UNIQUE (user_id,"uuid");
