50 lines
2.2 KiB
SQL
50 lines
2.2 KiB
SQL
-- 043_reference_check.sql
|
|
-- Annexure G - Employment Reference Check Form as its own table
|
|
-- (backend/reference_check/models.py, ReferenceCheck). One row per referee, so
|
|
-- a candidate can have several. recruiter_id and candidate_id both point at
|
|
-- users.id (recruiters and candidates are users in this system); created_by is
|
|
-- the logged-in user who filled the form.
|
|
--
|
|
-- The table name is mixed case at the user's request, so it must stay quoted
|
|
-- ("Reference_Check") in any raw SQL. FK / index names follow the db_setup
|
|
-- NAMING_CONVENTION so a dev DB that autogenerated first is a no-op.
|
|
--
|
|
-- Idempotent, applied at startup by alembic_setup.run_manual_sql(). Needed
|
|
-- because prod boots with DB_AUTOGENERATE=false and never autogenerates tables.
|
|
|
|
CREATE TABLE IF NOT EXISTS app."Reference_Check" (
|
|
id uuid PRIMARY KEY,
|
|
recruiter_id uuid,
|
|
candidate_id uuid,
|
|
position_applied varchar,
|
|
referee_name varchar,
|
|
date_time timestamptz,
|
|
referee_title varchar,
|
|
referee_organization varchar,
|
|
relationship_duration varchar,
|
|
scope_of_relationship varchar,
|
|
work_approach varchar,
|
|
leadership varchar,
|
|
communication varchar,
|
|
agility varchar,
|
|
signoff_referee_name varchar,
|
|
signoff_designation varchar,
|
|
signoff_date date,
|
|
created_by uuid,
|
|
created_at timestamptz NOT NULL DEFAULT NOW(),
|
|
updated_at timestamptz NOT NULL DEFAULT NOW(),
|
|
is_deleted boolean NOT NULL DEFAULT false,
|
|
CONSTRAINT "fk_Reference_Check_recruiter_id_users"
|
|
FOREIGN KEY (recruiter_id) REFERENCES app.users (id),
|
|
CONSTRAINT "fk_Reference_Check_candidate_id_users"
|
|
FOREIGN KEY (candidate_id) REFERENCES app.users (id),
|
|
CONSTRAINT "fk_Reference_Check_created_by_users"
|
|
FOREIGN KEY (created_by) REFERENCES app.users (id)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS "ix_Reference_Check_recruiter_id"
|
|
ON app."Reference_Check" (recruiter_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS "ix_Reference_Check_candidate_id"
|
|
ON app."Reference_Check" (candidate_id);
|