CREATE TABLE candidates (
tenant_id UUID,
candidate_id UUID DEFAULT gen_random_uuid(),
name VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL,
phone VARCHAR(20),
resume TEXT NOT NULL, -- assuming resume is stored as text
vector_embedding VECTOR(768), -- Adjust the dimensions as needed
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, candidate_id),
FOREIGN KEY (tenant_id) REFERENCES tenants(id)
);
CREATE TABLE recruiter (
tenant_id UUID,
recruiter_id UUID,
conversion_success INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, recruiter_id),
FOREIGN KEY (tenant_id, recruiter_id) REFERENCES tenant_users(tenant_id, user_id)
);
CREATE TABLE hiring_manager (
tenant_id UUID,
manager_id UUID,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, manager_id),
FOREIGN KEY (tenant_id, manager_id) REFERENCES tenant_users(tenant_id, user_id)
);
CREATE TABLE jobs (
tenant_id UUID,
job_id UUID DEFAULT gen_random_uuid(),
title VARCHAR(100) NOT NULL,
description TEXT,
status VARCHAR(50) DEFAULT 'open', -- e.g., open, closed, in_progress
hiring_manager_id UUID,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
vector_embedding VECTOR(768), -- Adjust the dimensions as needed
PRIMARY KEY (tenant_id, job_id),
FOREIGN KEY (tenant_id, hiring_manager_id) REFERENCES hiring_manager(tenant_id, manager_id)
);
CREATE TABLE candidate_jobs (
tenant_id UUID,
candidate_id UUID,
job_id UUID,
status VARCHAR(50) DEFAULT 'applied', -- status of the candidate for this job
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, candidate_id, job_id),
FOREIGN KEY (tenant_id, candidate_id) REFERENCES candidates(tenant_id, candidate_id),
FOREIGN KEY (tenant_id, job_id) REFERENCES jobs(tenant_id, job_id)
);
CREATE TABLE interviews (
tenant_id UUID,
interview_id UUID DEFAULT gen_random_uuid(),
job_id UUID,
interview_date TIMESTAMP NOT NULL,
questions JSONB NOT NULL, -- storing interview questions in JSONB format
expected_answers JSONB, -- storing expected answers in JSONB format
vector_embedding VECTOR(768), -- Adjust the dimensions as needed
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, interview_id),
FOREIGN KEY (tenant_id, job_id) REFERENCES jobs(tenant_id, job_id)
);
CREATE TABLE feedback (
tenant_id UUID,
feedback_id UUID DEFAULT gen_random_uuid(),
interview_id UUID,
user_id UUID,
feedback_text TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
vector_embedding VECTOR(768), -- Adjust the dimensions as needed
PRIMARY KEY (tenant_id, feedback_id),
FOREIGN KEY (tenant_id, interview_id) REFERENCES interviews(tenant_id, interview_id),
FOREIGN KEY (tenant_id, user_id) REFERENCES tenant_users(tenant_id, user_id)
);