22 lines
1.1 KiB
SQL
22 lines
1.1 KiB
SQL
-- 009_job_post_images.sql
|
|
-- Cover images of job posts, stored IN the database (bytea) rather than on the
|
|
-- container filesystem, which is ephemeral in production — a disk-backed image
|
|
-- would vanish on every redeploy. One row per post: the PK doubles as the FK,
|
|
-- so a re-upload is a plain replace. 5 MB cap and type checks are enforced by
|
|
-- the API layer (backend/job/job_post/views.py save_job_image).
|
|
--
|
|
-- Idempotent, applied automatically at startup by alembic_setup.run_manual_sql()
|
|
-- and recorded in manual_migrations. Matches the SQLModel JobPostImages model in
|
|
-- backend/job/job_post/models.py (needed here because prod boots with
|
|
-- DB_AUTOGENERATE=false and never autogenerates new tables).
|
|
|
|
CREATE TABLE IF NOT EXISTS app.job_post_images (
|
|
job_post_id uuid PRIMARY KEY REFERENCES app.job_posts(id) ON DELETE CASCADE,
|
|
content_type varchar NOT NULL,
|
|
file_name varchar,
|
|
data bytea NOT NULL,
|
|
uploaded_by uuid REFERENCES app.users(id),
|
|
created_at timestamptz NOT NULL DEFAULT NOW(),
|
|
updated_at timestamptz NOT NULL DEFAULT NOW()
|
|
);
|