CREATE TABLE application_custom_fields ( application_id bigint, custom_field character varying, float_value double precision, date_value date, display_value character varying, unit character varying, min_value numeric, max_value numeric, user_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone, key character varying(1024), text_value character varying(16384) ); CREATE TABLE application_question_answers ( job_post_id bigint, application_id bigint, question character varying(65535), answer character varying(65535), created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE application_stages ( application_id bigint, stage_id bigint, entered_on timestamp without time zone, exited_on timestamp without time zone, stage_name character varying ); CREATE TABLE applications ( id bigint NOT NULL, candidate_id bigint, applied_at timestamp without time zone, status character varying, prospect boolean, stage_id bigint, source_id bigint, referrer_id bigint, rejected_at timestamp without time zone, rejected_by_id bigint, rejection_reason_id bigint, pipeline_percent double precision, migrated boolean, rejected_by character varying, stage_name character varying, job_post_id bigint, prospect_pool character varying(65535), prospect_pool_stage character varying(65535), prospect_owner_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone, event_id bigint, converted_prospect_application_id bigint ); CREATE TABLE applications_jobs ( application_id bigint, job_id bigint ); CREATE TABLE approvals ( offer_id bigint, application_id bigint, job_id bigint, job_name character varying(1024), candidate_id bigint, candidate_name character varying(1024), approver_id bigint, approver_name character varying(1024), approval_type character varying(32), status character varying(32), version integer, version_final integer, group_id bigint, group_order integer, group_quorum integer, assigned_at timestamp without time zone, completed_at timestamp without time zone, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE attributes ( id bigint NOT NULL, organization_id bigint, name character varying(1024), category character varying, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE candidate_custom_fields ( candidate_id bigint, custom_field character varying, float_value double precision, date_value date, display_value character varying(1024), unit character varying, min_value numeric, max_value numeric, user_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone, key character varying(1024), text_value character varying(16384) ); CREATE TABLE candidate_email_addresses ( candidate_id bigint, value character varying(255), created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE candidate_mailing_addresses ( candidate_id bigint, value character varying(65535), created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE candidate_phone_numbers ( candidate_id bigint, value character varying(255), created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE candidate_survey_questions ( id bigint NOT NULL, question character varying ); CREATE TABLE candidate_surveys ( id bigint, organization_id bigint, submitted_at timestamp without time zone, department_id bigint, department_name character varying, office_id bigint, office_name character varying, question_1 character varying, question_2 character varying, question_3 character varying, question_4 character varying, question_5 character varying, question_6 character varying, question_7 character varying, question_8 character varying ); CREATE TABLE candidates ( id bigint NOT NULL, first_name character varying, last_name character varying, recruiter_id bigint, coordinator_id bigint, migrated boolean, recruiter character varying, coordinator character varying, company character varying(1024), title character varying(1024), created_at timestamp without time zone, updated_at timestamp without time zone, private boolean ); CREATE TABLE candidates_tags ( id bigint NOT NULL, tag_id bigint, candidate_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE departments ( id bigint NOT NULL, organization_id bigint, name character varying(1024), parent_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE educations ( candidate_id bigint, school_name character varying, degree character varying, discipline character varying, start date, "end" date, latest boolean, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE eeoc_responses ( application_id bigint, status character varying, race character varying, gender character varying, disability_status character varying, veteran_status character varying, submitted_at timestamp without time zone ); CREATE TABLE employments ( candidate_id bigint, company_name character varying, title character varying, start date, "end" date, latest boolean, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE events ( id bigint NOT NULL, name character varying(65535) ); CREATE TABLE greenhouse_usages ( user_id bigint, date date ); CREATE TABLE hiring_team ( job_id bigint, user_id bigint, role character varying, responsible boolean, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE interviewer_tags ( user_id bigint, tag character varying, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE interviewers ( interview_id bigint, user_id bigint, scorecard_id bigint, "user" character varying ); CREATE TABLE interviews ( id bigint NOT NULL, organization_id bigint, name character varying(1024), created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE job_custom_fields ( job_id bigint, custom_field character varying, float_value double precision, date_value date, display_value character varying(1024), unit character varying, min_value numeric, max_value numeric, user_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone, key character varying(1024), text_value character varying(16384) ); CREATE TABLE job_posts ( id bigint NOT NULL, job_id bigint, title character varying, live boolean, job_board_name character varying, language character varying, location character varying, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE job_snapshots ( job_id bigint, date date, hired_count integer, prospect_count integer, new_today integer, rejected_today integer, advanced_today integer, interviews_today integer ); CREATE TABLE jobs ( id bigint NOT NULL, organization_id bigint, name character varying(1024), requisition_id character varying, status character varying, opened_at timestamp without time zone, closed_at timestamp without time zone, department_id bigint, level character varying, confidential boolean, created_at timestamp without time zone, notes character varying(65535), updated_at timestamp without time zone ); CREATE TABLE jobs_attributes ( id bigint NOT NULL, job_id bigint, attribute_id bigint, active boolean, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE jobs_departments ( id bigint NOT NULL, job_id bigint, department_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE jobs_interviews ( id bigint NOT NULL, job_id bigint, stage_id bigint, interview_id bigint, "order" integer, estimated_duration integer, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE jobs_offices ( id bigint NOT NULL, job_id bigint, office_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE jobs_stages ( job_id bigint, stage_id bigint, "order" integer, name character varying, stage_alert_setting integer, created_at timestamp without time zone, updated_at timestamp without time zone, milestones character varying(1024) ); CREATE TABLE offer_custom_fields ( offer_id bigint, custom_field character varying, float_value double precision, date_value date, display_value character varying(1024), unit character varying, min_value numeric, max_value numeric, user_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone, key character varying(1024), text_value character varying(16384) ); CREATE TABLE offers ( id bigint NOT NULL, application_id bigint, status character varying, created_at timestamp without time zone, sent_at date, resolved_at timestamp without time zone, start_date timestamp without time zone, created_by character varying, updated_at timestamp without time zone ); CREATE TABLE offices ( id bigint NOT NULL, organization_id bigint, name character varying(1024), parent_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE openings ( id bigint NOT NULL, job_id bigint, opening_id character varying, opened_at timestamp without time zone, closed_at timestamp without time zone, hired_application_id bigint, close_reason character varying(255), created_at timestamp without time zone, updated_at timestamp without time zone, target_start_date date ); CREATE TABLE organizations ( id bigint NOT NULL, name character varying(1024) ); CREATE TABLE referral_question_custom_fields ( candidate_id bigint, custom_field character varying, float_value double precision, date_value date, display_value character varying(1024), unit character varying, min_value numeric, max_value numeric, user_id integer, created_at timestamp without time zone, updated_at timestamp without time zone, key character varying(1024), text_value character varying(16384) ); CREATE TABLE referrers ( id bigint NOT NULL, organization_id bigint, name character varying(1024), user_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE rejection_question_custom_fields ( application_id bigint, custom_field character varying, float_value double precision, date_value date, display_value character varying, unit character varying, min_value numeric, max_value numeric, user_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone, key character varying(1024), text_value character varying(16384) ); CREATE TABLE rejection_reasons ( id bigint NOT NULL, organization_id bigint, name character varying(1024), type character varying, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE scheduled_interviews ( id bigint NOT NULL, application_id bigint, interview_id bigint, status character varying, scheduled_by_id bigint, scheduled_at timestamp without time zone, starts_at timestamp without time zone, ends_at timestamp without time zone, all_day_start_date date, all_day_end_date date, stage_name character varying(1024), interview_name character varying(1024) ); CREATE TABLE schema_migrations ( version character varying NOT NULL ); CREATE TABLE scorecard_question_answers ( scorecard_id bigint, application_id bigint, question character varying(65535), answer character varying(65535), created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE scorecards ( id bigint NOT NULL, application_id bigint, stage_id bigint, interview_id bigint, interviewer_id bigint, submitter_id bigint, overall_recommendation character varying, submitted_at timestamp without time zone, scheduled_interview_ended_at timestamp without time zone, total_focus_attributes integer, completed_focus_attributes integer, interviewer character varying, submitter character varying, stage_name character varying, created_at timestamp without time zone, updated_at timestamp without time zone, interview_name character varying(4096) ); CREATE TABLE scorecards_attributes ( scorecard_id bigint, attribute_id bigint, rating character varying, notes character varying(65535), created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE sources ( id bigint NOT NULL, organization_id bigint, name character varying(1024), type character varying, created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE stage_snapshots ( stage_id bigint, date date, active_count integer, job_id bigint ); CREATE TABLE stages ( id bigint NOT NULL, organization_id bigint, name character varying(1024), "order" integer, active boolean ); CREATE TABLE tags ( id bigint NOT NULL, organization_id bigint, name character varying(1024), created_at timestamp without time zone, updated_at timestamp without time zone ); CREATE TABLE user_actions ( id bigint NOT NULL, job_id bigint, user_id bigint, type character varying ); CREATE TABLE users ( id bigint NOT NULL, organization_id bigint, first_name character varying, last_name character varying, email character varying, status character varying, full_name character varying, employee_id character varying, created_at timestamp without time zone, updated_at timestamp without time zone ); ALTER TABLE ONLY applications ADD CONSTRAINT applications_pkey PRIMARY KEY (id); ALTER TABLE ONLY attributes ADD CONSTRAINT attributes_pkey PRIMARY KEY (id); ALTER TABLE ONLY candidate_survey_questions ADD CONSTRAINT candidate_survey_questions_pkey PRIMARY KEY (id); ALTER TABLE ONLY candidates ADD CONSTRAINT candidates_pkey PRIMARY KEY (id); ALTER TABLE ONLY candidates_tags ADD CONSTRAINT candidates_tags_pkey PRIMARY KEY (id); ALTER TABLE ONLY departments ADD CONSTRAINT departments_pkey PRIMARY KEY (id); ALTER TABLE ONLY events ADD CONSTRAINT events_pkey PRIMARY KEY (id); ALTER TABLE ONLY interviews ADD CONSTRAINT interviews_pkey PRIMARY KEY (id); ALTER TABLE ONLY job_posts ADD CONSTRAINT job_posts_pkey PRIMARY KEY (id); ALTER TABLE ONLY jobs_attributes ADD CONSTRAINT jobs_attributes_pkey PRIMARY KEY (id); ALTER TABLE ONLY jobs_departments ADD CONSTRAINT jobs_departments_pkey PRIMARY KEY (id); ALTER TABLE ONLY jobs_interviews ADD CONSTRAINT jobs_interviews_pkey PRIMARY KEY (id); ALTER TABLE ONLY jobs_offices ADD CONSTRAINT jobs_offices_pkey PRIMARY KEY (id); ALTER TABLE ONLY jobs ADD CONSTRAINT jobs_pkey PRIMARY KEY (id); ALTER TABLE ONLY offers ADD CONSTRAINT offers_pkey PRIMARY KEY (id); ALTER TABLE ONLY offices ADD CONSTRAINT offices_pkey PRIMARY KEY (id); ALTER TABLE ONLY openings ADD CONSTRAINT openings_pkey PRIMARY KEY (id); ALTER TABLE ONLY organizations ADD CONSTRAINT organizations_pkey PRIMARY KEY (id); ALTER TABLE ONLY referrers ADD CONSTRAINT referrers_pkey PRIMARY KEY (id); ALTER TABLE ONLY rejection_reasons ADD CONSTRAINT rejection_reasons_pkey PRIMARY KEY (id); ALTER TABLE ONLY scheduled_interviews ADD CONSTRAINT scheduled_interviews_pkey PRIMARY KEY (id); ALTER TABLE ONLY scorecards ADD CONSTRAINT scorecards_pkey PRIMARY KEY (id); ALTER TABLE ONLY sources ADD CONSTRAINT sources_pkey PRIMARY KEY (id); ALTER TABLE ONLY stages ADD CONSTRAINT stages_pkey PRIMARY KEY (id); ALTER TABLE ONLY tags ADD CONSTRAINT tags_pkey PRIMARY KEY (id); ALTER TABLE ONLY user_actions ADD CONSTRAINT user_actions_pkey PRIMARY KEY (id); ALTER TABLE ONLY users ADD CONSTRAINT users_pkey PRIMARY KEY (id); ALTER TABLE ONLY application_custom_fields ADD CONSTRAINT application_custom_fields_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY application_custom_fields ADD CONSTRAINT application_custom_fields_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY application_question_answers ADD CONSTRAINT application_question_answers_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY application_question_answers ADD CONSTRAINT application_question_answers_job_post_id_fk FOREIGN KEY (job_post_id) REFERENCES job_posts(id); ALTER TABLE ONLY application_stages ADD CONSTRAINT application_stages_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY application_stages ADD CONSTRAINT application_stages_stage_id_fk FOREIGN KEY (stage_id) REFERENCES stages(id); ALTER TABLE ONLY applications ADD CONSTRAINT applications_candidate_id_fk FOREIGN KEY (candidate_id) REFERENCES candidates(id); ALTER TABLE ONLY applications ADD CONSTRAINT applications_converted_prospect_application_id_fk FOREIGN KEY (converted_prospect_application_id) REFERENCES applications(id); ALTER TABLE ONLY applications ADD CONSTRAINT applications_event_id_fk FOREIGN KEY (event_id) REFERENCES events(id); ALTER TABLE ONLY applications ADD CONSTRAINT applications_job_post_id_fk FOREIGN KEY (job_post_id) REFERENCES job_posts(id); ALTER TABLE ONLY applications_jobs ADD CONSTRAINT applications_jobs_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY applications_jobs ADD CONSTRAINT applications_jobs_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY applications ADD CONSTRAINT applications_prospect_owner_id_fk FOREIGN KEY (prospect_owner_id) REFERENCES users(id); ALTER TABLE ONLY applications ADD CONSTRAINT applications_referrer_id_fk FOREIGN KEY (referrer_id) REFERENCES referrers(id); ALTER TABLE ONLY applications ADD CONSTRAINT applications_rejected_by_id_fk FOREIGN KEY (rejected_by_id) REFERENCES users(id); ALTER TABLE ONLY applications ADD CONSTRAINT applications_rejection_reason_id_fk FOREIGN KEY (rejection_reason_id) REFERENCES rejection_reasons(id); ALTER TABLE ONLY applications ADD CONSTRAINT applications_source_id_fk FOREIGN KEY (source_id) REFERENCES sources(id); ALTER TABLE ONLY applications ADD CONSTRAINT applications_stage_id_fk FOREIGN KEY (stage_id) REFERENCES stages(id); ALTER TABLE ONLY approvals ADD CONSTRAINT approvals_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY approvals ADD CONSTRAINT approvals_approver_id_fk FOREIGN KEY (approver_id) REFERENCES users(id); ALTER TABLE ONLY approvals ADD CONSTRAINT approvals_candidate_id_fk FOREIGN KEY (candidate_id) REFERENCES candidates(id); ALTER TABLE ONLY approvals ADD CONSTRAINT approvals_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY approvals ADD CONSTRAINT approvals_offer_id_fk FOREIGN KEY (offer_id) REFERENCES offers(id); ALTER TABLE ONLY attributes ADD CONSTRAINT attributes_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY candidate_custom_fields ADD CONSTRAINT candidate_custom_fields_candidate_id_fk FOREIGN KEY (candidate_id) REFERENCES candidates(id); ALTER TABLE ONLY candidate_custom_fields ADD CONSTRAINT candidate_custom_fields_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY candidate_email_addresses ADD CONSTRAINT candidate_email_addresses_candidate_id_fk FOREIGN KEY (candidate_id) REFERENCES candidates(id); ALTER TABLE ONLY candidate_mailing_addresses ADD CONSTRAINT candidate_mailing_addresses_candidate_id_fk FOREIGN KEY (candidate_id) REFERENCES candidates(id); ALTER TABLE ONLY candidate_phone_numbers ADD CONSTRAINT candidate_phone_numbers_candidate_id_fk FOREIGN KEY (candidate_id) REFERENCES candidates(id); ALTER TABLE ONLY candidate_surveys ADD CONSTRAINT candidate_surveys_department_id_fk FOREIGN KEY (department_id) REFERENCES departments(id); ALTER TABLE ONLY candidate_surveys ADD CONSTRAINT candidate_surveys_office_id_fk FOREIGN KEY (office_id) REFERENCES offices(id); ALTER TABLE ONLY candidate_surveys ADD CONSTRAINT candidate_surveys_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY candidates ADD CONSTRAINT candidates_coordinator_id_fk FOREIGN KEY (coordinator_id) REFERENCES users(id); ALTER TABLE ONLY candidates ADD CONSTRAINT candidates_recruiter_id_fk FOREIGN KEY (recruiter_id) REFERENCES users(id); ALTER TABLE ONLY candidates_tags ADD CONSTRAINT candidates_tags_candidate_id_fk FOREIGN KEY (candidate_id) REFERENCES candidates(id); ALTER TABLE ONLY candidates_tags ADD CONSTRAINT candidates_tags_tag_id_fk FOREIGN KEY (tag_id) REFERENCES tags(id); ALTER TABLE ONLY departments ADD CONSTRAINT departments_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY eeoc_responses ADD CONSTRAINT eeoc_responses_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY greenhouse_usages ADD CONSTRAINT greenhouse_usages_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY hiring_team ADD CONSTRAINT hiring_team_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY hiring_team ADD CONSTRAINT hiring_team_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY interviewer_tags ADD CONSTRAINT interviewer_tags_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY interviewers ADD CONSTRAINT interviewers_interview_id_fk FOREIGN KEY (interview_id) REFERENCES scheduled_interviews(id); ALTER TABLE ONLY interviewers ADD CONSTRAINT interviewers_scorecard_id_fk FOREIGN KEY (scorecard_id) REFERENCES scorecards(id); ALTER TABLE ONLY interviewers ADD CONSTRAINT interviewers_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY interviews ADD CONSTRAINT interviews_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY job_custom_fields ADD CONSTRAINT job_custom_fields_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY job_custom_fields ADD CONSTRAINT job_custom_fields_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY job_posts ADD CONSTRAINT job_posts_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY job_snapshots ADD CONSTRAINT job_snapshots_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY jobs_attributes ADD CONSTRAINT jobs_attributes_attribute_id_fk FOREIGN KEY (attribute_id) REFERENCES attributes(id); ALTER TABLE ONLY jobs_attributes ADD CONSTRAINT jobs_attributes_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY jobs ADD CONSTRAINT jobs_department_id_fk FOREIGN KEY (department_id) REFERENCES departments(id); ALTER TABLE ONLY jobs_departments ADD CONSTRAINT jobs_departments_department_id_fk FOREIGN KEY (department_id) REFERENCES departments(id); ALTER TABLE ONLY jobs_departments ADD CONSTRAINT jobs_departments_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY jobs_interviews ADD CONSTRAINT jobs_interviews_interview_id_fk FOREIGN KEY (interview_id) REFERENCES interviews(id); ALTER TABLE ONLY jobs_interviews ADD CONSTRAINT jobs_interviews_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY jobs_interviews ADD CONSTRAINT jobs_interviews_stage_id_fk FOREIGN KEY (stage_id) REFERENCES stages(id); ALTER TABLE ONLY jobs_offices ADD CONSTRAINT jobs_offices_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY jobs_offices ADD CONSTRAINT jobs_offices_office_id_fk FOREIGN KEY (office_id) REFERENCES offices(id); ALTER TABLE ONLY jobs ADD CONSTRAINT jobs_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY jobs_stages ADD CONSTRAINT jobs_stages_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY jobs_stages ADD CONSTRAINT jobs_stages_stage_id_fk FOREIGN KEY (stage_id) REFERENCES stages(id); ALTER TABLE ONLY offer_custom_fields ADD CONSTRAINT offer_custom_fields_offer_id_fk FOREIGN KEY (offer_id) REFERENCES offers(id); ALTER TABLE ONLY offer_custom_fields ADD CONSTRAINT offer_custom_fields_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY offers ADD CONSTRAINT offers_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY offices ADD CONSTRAINT offices_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY openings ADD CONSTRAINT openings_hired_application_id_fk FOREIGN KEY (hired_application_id) REFERENCES applications(id); ALTER TABLE ONLY openings ADD CONSTRAINT openings_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY referral_question_custom_fields ADD CONSTRAINT referral_question_custom_fields_candidate_id_fk FOREIGN KEY (candidate_id) REFERENCES candidates(id); ALTER TABLE ONLY referral_question_custom_fields ADD CONSTRAINT referral_question_custom_fields_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY referrers ADD CONSTRAINT referrers_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY referrers ADD CONSTRAINT referrers_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY rejection_question_custom_fields ADD CONSTRAINT rejection_question_custom_fields_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY rejection_question_custom_fields ADD CONSTRAINT rejection_question_custom_fields_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY rejection_reasons ADD CONSTRAINT rejection_reasons_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY scheduled_interviews ADD CONSTRAINT scheduled_interviews_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY scheduled_interviews ADD CONSTRAINT scheduled_interviews_interview_id_fk FOREIGN KEY (interview_id) REFERENCES interviews(id); ALTER TABLE ONLY scheduled_interviews ADD CONSTRAINT scheduled_interviews_scheduled_by_id_fk FOREIGN KEY (scheduled_by_id) REFERENCES users(id); ALTER TABLE ONLY scorecard_question_answers ADD CONSTRAINT scorecard_question_answers_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY scorecard_question_answers ADD CONSTRAINT scorecard_question_answers_scorecard_id_fk FOREIGN KEY (scorecard_id) REFERENCES scorecards(id); ALTER TABLE ONLY scorecards ADD CONSTRAINT scorecards_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY scorecards_attributes ADD CONSTRAINT scorecards_attributes_attribute_id_fk FOREIGN KEY (attribute_id) REFERENCES attributes(id); ALTER TABLE ONLY scorecards_attributes ADD CONSTRAINT scorecards_attributes_scorecard_id_fk FOREIGN KEY (scorecard_id) REFERENCES scorecards(id); ALTER TABLE ONLY scorecards ADD CONSTRAINT scorecards_interview_id_fk FOREIGN KEY (interview_id) REFERENCES interviews(id); ALTER TABLE ONLY scorecards ADD CONSTRAINT scorecards_interviewer_id_fk FOREIGN KEY (interviewer_id) REFERENCES users(id); ALTER TABLE ONLY scorecards ADD CONSTRAINT scorecards_stage_id_fk FOREIGN KEY (stage_id) REFERENCES stages(id); ALTER TABLE ONLY scorecards ADD CONSTRAINT scorecards_submitter_id_fk FOREIGN KEY (submitter_id) REFERENCES users(id); ALTER TABLE ONLY sources ADD CONSTRAINT sources_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY stage_snapshots ADD CONSTRAINT stage_snapshots_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY stage_snapshots ADD CONSTRAINT stage_snapshots_stage_id_fk FOREIGN KEY (stage_id) REFERENCES stages(id); ALTER TABLE ONLY stages ADD CONSTRAINT stages_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY tags ADD CONSTRAINT tags_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY user_actions ADD CONSTRAINT user_actions_job_id_fk FOREIGN KEY (job_id) REFERENCES jobs(id); ALTER TABLE ONLY user_actions ADD CONSTRAINT user_actions_user_id_fk FOREIGN KEY (user_id) REFERENCES users(id); ALTER TABLE ONLY users ADD CONSTRAINT users_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(id);