tijl.dev-core/migrations/00000003_uploader.up.sql
tijl 7e1c36c966
Some checks failed
build / build (push) Successful in 41s
release-tag / release-image (push) Has been cancelled
changes + add uploader
2024-08-29 12:21:38 +02:00

23 lines
741 B
SQL

CREATE TABLE app_uploader_files (
id UUID PRIMARY KEY UNIQUE NOT NULL DEFAULT gen_random_uuid(),
uid VARCHAR NOT NULL,
file_crypto VARCHAR NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
-- settings
expire TIMESTAMP NOT NULL,
max_visits INT NOT NULL,
FOREIGN KEY (uid) REFERENCES users (uid)
);
CREATE TABLE app_uploader_files_access (
file_id UUID NOT NULL,
-- info about user who accessed
uid VARCHAR DEFAULT NULL, -- link to logged in user
ip_address VARCHAR NOT NULL,
agent VARCHAR NOT NULL,
access_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
FOREIGN KEY (file_id) REFERENCES app_uploader_files (id),
FOREIGN KEY (uid) REFERENCES users (uid)
);