HR-ATS-Portal/backend/migrations/manual/010_cv_bank_files.sql

22 lines
1.0 KiB
SQL

-- 010_cv_bank_files.sql
-- PDF bytes of CV-bank entries, stored IN the database. The bank's metadata
-- row lives in app.manual_upload_candidate (apply_via = 'cv_bank'); keeping
-- the file itself on the container filesystem would lose every stored CV on
-- redeploy, so bank uploads write the bytes here instead and no disk file is
-- created at all. PK doubles as the FK: one file per bank row, removed
-- automatically with it.
--
-- Idempotent, applied automatically at startup by alembic_setup.run_manual_sql()
-- and recorded in manual_migrations (prod boots with DB_AUTOGENERATE=false and
-- never autogenerates tables). Matches CvBankFiles in
-- backend/job/candidate/models.py.
CREATE TABLE IF NOT EXISTS app.cv_bank_files (
manual_upload_candidate_id uuid PRIMARY KEY
REFERENCES app.manual_upload_candidate(id) ON DELETE CASCADE,
content_type varchar NOT NULL DEFAULT 'application/pdf',
file_name varchar,
data bytea NOT NULL,
created_at timestamptz NOT NULL DEFAULT NOW()
);