CREATE TABLE IF NOT EXISTS tmpfiles (
    id BIGSERIAL,
    file_name VARCHAR(255) NOT NULL,
    key VARCHAR(500) NOT NULL UNIQUE,
    presigned_url TEXT NOT NULL,
    expiration TIMESTAMP WITH TIME ZONE NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id)
);

COMMENT ON TABLE tmpfiles IS 'Temporary files table for storing files with presigned URLs and expiration times';

COMMENT ON COLUMN tmpfiles.id IS 'Unique identifier for the temporary file';
COMMENT ON COLUMN tmpfiles.file_name IS 'Name of the temporary file';
COMMENT ON COLUMN tmpfiles.key IS 'Unique key for the temporary file';
COMMENT ON COLUMN tmpfiles.presigned_url IS 'Presigned URL for accessing the temporary file';
COMMENT ON COLUMN tmpfiles.expiration IS 'Expiration timestamp for the temporary file';
COMMENT ON COLUMN tmpfiles.created_at IS 'Timestamp when the temporary file was created';

CREATE INDEX idx_tmpfiles_expiration ON tmpfiles(expiration);
CREATE INDEX idx_tmpfiles_created_at ON tmpfiles(created_at);