You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
reya-render/db-migration-uploaded-rende...

25 lines
1016 B

-- IN: Table for uploaded files
CREATE TABLE IF NOT EXISTS uploaded_files (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(id) ON DELETE CASCADE NOT NULL,
original_name VARCHAR(255) NOT NULL,
file_path VARCHAR(500) NOT NULL,
upload_status VARCHAR(50) DEFAULT 'PENDING',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
render_job_id UUID -- nullable, links to rendered_files
);
-- OUT: Table for rendered files corresponding to uploads
CREATE TABLE IF NOT EXISTS rendered_files (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
uploaded_file_id UUID REFERENCES uploaded_files(id) ON DELETE CASCADE NOT NULL,
render_status VARCHAR(50) DEFAULT 'PENDING',
output_file_path VARCHAR(500),
rendered_at TIMESTAMP,
error_message TEXT
);
-- Some useful indices
CREATE INDEX IF NOT EXISTS idx_uploaded_files_user_id ON uploaded_files(user_id);
CREATE INDEX IF NOT EXISTS idx_rendered_files_uploaded_file_id ON rendered_files(uploaded_file_id);