COMMENT ON SCHEMA IS 'standard public schema'; CREATE TABLE agency_question_custom_fields ( application_id bigint, custom_field character varying, boolean_value boolean, float_value double precision, date_value timestamp without time zone, 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, text_value character varying ); 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, sent_demographic_questions boolean ); 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 demographic_answer_option_translations ( id bigint NOT NULL, demographic_answer_option_id bigint NOT NULL, language character varying NOT NULL, name character varying NOT NULL ); CREATE TABLE demographic_answer_options ( id bigint NOT NULL, demographic_question_id bigint NOT NULL, active boolean NOT NULL, free_form boolean NOT NULL, name character varying ); CREATE TABLE demographic_answers ( id bigint NOT NULL, application_id bigint NOT NULL, demographic_question_id bigint NOT NULL, demographic_answer_option_id bigint, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL ); CREATE TABLE demographic_free_form_answers ( id bigint NOT NULL, demographic_answer_id bigint NOT NULL, text character varying NOT NULL, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL ); CREATE TABLE demographic_question_sets ( id bigint NOT NULL, organization_id bigint NOT NULL, title character varying NOT NULL, description character varying, active boolean NOT NULL ); CREATE TABLE demographic_question_translations ( id bigint NOT NULL, demographic_question_id bigint NOT NULL, language character varying NOT NULL, name character varying NOT NULL ); CREATE TABLE demographic_questions ( id bigint NOT NULL, organization_id bigint NOT NULL, active boolean NOT NULL, demographic_question_set_id bigint, name character varying, required boolean, answer_type character varying ); 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 gdpr_consent_decisions ( candidate_id bigint NOT NULL, decision character varying NOT NULL, decided_at timestamp without time zone NOT NULL ); CREATE TABLE gdpr_consent_requests ( candidate_id bigint NOT NULL, status character varying NOT NULL, token character varying NOT NULL, requested_at timestamp without time zone NOT NULL ); CREATE TABLE gdpr_office_rules ( office_id bigint NOT NULL, retention_period bigint NOT NULL ); CREATE TABLE gho_assigned_tasks ( id bigint NOT NULL, task_name character varying NOT NULL, task_description character varying, task_category character varying(255) NOT NULL, assigned_for_id integer NOT NULL, assigned_by_id integer, completed_at timestamp without time zone, due_date_relative_days integer, assign_days_before integer NOT NULL, calculated_due_date date, calculated_assign_date date, attachment_required boolean NOT NULL, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, assigned_employee_id bigint, third_party_system_email character varying, assigned_custom_field_id integer, assigned_coworker_employee_id integer, completed_by_employee_id integer, completed_by_third_party_system_email character varying, assignee_updated_at timestamp without time zone, assigned_at timestamp without time zone ); CREATE TABLE gho_custom_field_values ( id bigint NOT NULL, employee_id bigint NOT NULL, custom_field_id bigint NOT NULL, custom_field_permanent_field_id character varying(255), custom_field_field_type character varying(255), value character varying, value_employee_id integer, value_date date, value_updated_at timestamp without time zone, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL ); CREATE TABLE gho_custom_fields ( id bigint NOT NULL, permanent_field_id character varying(255), name character varying(255), field_type character varying(255), created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL ); CREATE TABLE gho_employee_roles ( role_id bigint, employee_id bigint NOT NULL ); CREATE TABLE gho_employees ( id bigint NOT NULL, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, personal_email character varying, work_email character varying, start_date date, termination_date date, employment_status character varying, manager_id bigint, hr_manager_id bigint, title character varying, global_role character varying, n_direct_reports bigint, department character varying, location character varying, legal_name_first_name character varying, legal_name_middle_name character varying, legal_name_last_name character varying, legal_name_suffix character varying, preferred_first_name character varying, preferred_last_name character varying ); CREATE TABLE gho_roles ( id bigint NOT NULL, name character varying(255) NOT NULL ); CREATE TABLE gho_user_activities ( employee_id bigint NOT NULL, hourly_last_sign_in_at timestamp without time zone ); 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_post_questions ( job_post_id bigint, question character varying(65535), created_at timestamp without time zone, updated_at timestamp without time zone ); 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, eeoc_enabled boolean, indeed_feed boolean, linked_in_feed boolean, glassdoor_feed boolean, first_published 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, name character varying, category character varying ); 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, interview_name character varying ); 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 opening_custom_fields ( opening_id bigint NOT NULL, 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, text_value character varying ); 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 prospect_pool_stages ( id bigint NOT NULL, prospect_pool_id bigint NOT NULL, name character varying NOT NULL, priority integer NOT NULL, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL ); CREATE TABLE prospect_pool_transitions ( application_id bigint NOT NULL, user_id bigint NOT NULL, old_prospect_pool_id bigint, old_prospect_stage_id bigint, new_prospect_pool_id bigint, new_prospect_stage_id bigint, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL ); CREATE TABLE prospect_pools ( id bigint NOT NULL, name character varying NOT NULL, active boolean NOT NULL, description character varying, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL ); 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, scorecard_question_id bigint ); CREATE TABLE scorecard_questions ( id bigint NOT NULL, interview_kit_id bigint, question character varying NOT NULL, answer_type character varying NOT NULL, active boolean NOT NULL, priority integer, required boolean, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, focus_attributes character varying ); 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, attribute_name character varying, attribute_category character varying ); 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 user_candidate_links ( user_id bigint, candidate_id bigint, created_at timestamp without time zone, updated_at timestamp without time zone ); 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 demographic_answer_option_translations ADD CONSTRAINT demographic_answer_option_translations_pkey PRIMARY KEY (id); ALTER TABLE ONLY demographic_answer_options ADD CONSTRAINT demographic_answer_options_pkey PRIMARY KEY (id); ALTER TABLE ONLY demographic_answers ADD CONSTRAINT demographic_answers_pkey PRIMARY KEY (id); ALTER TABLE ONLY demographic_free_form_answers ADD CONSTRAINT demographic_free_form_answers_pkey PRIMARY KEY (id); ALTER TABLE ONLY demographic_question_sets ADD CONSTRAINT demographic_question_sets_pkey PRIMARY KEY (id); ALTER TABLE ONLY demographic_question_translations ADD CONSTRAINT demographic_question_translations_pkey PRIMARY KEY (id); ALTER TABLE ONLY demographic_questions ADD CONSTRAINT demographic_questions_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 gho_assigned_tasks ADD CONSTRAINT gho_assigned_tasks_pkey PRIMARY KEY (id); ALTER TABLE ONLY gho_custom_field_values ADD CONSTRAINT gho_custom_field_values_pkey PRIMARY KEY (id); ALTER TABLE ONLY gho_custom_fields ADD CONSTRAINT gho_custom_fields_pkey PRIMARY KEY (id); ALTER TABLE ONLY gho_employees ADD CONSTRAINT gho_employees_pkey PRIMARY KEY (id); ALTER TABLE ONLY gho_roles ADD CONSTRAINT gho_roles_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 scorecard_questions ADD CONSTRAINT scorecard_questions_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 agency_question_custom_fields ADD CONSTRAINT agency_question_custom_fields_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY agency_question_custom_fields ADD CONSTRAINT agency_question_custom_fields_user_id_fk FOREIGN KEY (user_id) REFERENCES users(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 demographic_answer_option_translations ADD CONSTRAINT demographic_answer_option_translations_demographic_answer_optio FOREIGN KEY (demographic_answer_option_id) REFERENCES demographic_answer_options(id); ALTER TABLE ONLY demographic_answer_options ADD CONSTRAINT demographic_answer_options_demographic_question_id_fk FOREIGN KEY (demographic_question_id) REFERENCES demographic_questions(id); ALTER TABLE ONLY demographic_answers ADD CONSTRAINT demographic_answers_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY demographic_answers ADD CONSTRAINT demographic_answers_demographic_answer_option_id_fk FOREIGN KEY (demographic_answer_option_id) REFERENCES demographic_answer_options(id); ALTER TABLE ONLY demographic_answers ADD CONSTRAINT demographic_answers_demographic_question_id_fk FOREIGN KEY (demographic_question_id) REFERENCES demographic_questions(id); ALTER TABLE ONLY demographic_free_form_answers ADD CONSTRAINT demographic_free_form_answers_demographic_answer_id_fk FOREIGN KEY (demographic_answer_id) REFERENCES demographic_answers(id); ALTER TABLE ONLY demographic_question_translations ADD CONSTRAINT demographic_question_translations_demographic_question_id_fk FOREIGN KEY (demographic_question_id) REFERENCES demographic_questions(id); ALTER TABLE ONLY demographic_questions ADD CONSTRAINT demographic_questions_demographic_question_set_id_fk FOREIGN KEY (demographic_question_set_id) REFERENCES demographic_question_sets(id); ALTER TABLE ONLY demographic_questions ADD CONSTRAINT demographic_questions_organization_id_fk FOREIGN KEY (organization_id) REFERENCES organizations(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 demographic_question_sets ADD CONSTRAINT fk_rails_6f74cafdba FOREIGN KEY (organization_id) REFERENCES organizations(id); ALTER TABLE ONLY gdpr_consent_decisions ADD CONSTRAINT gdpr_consent_decisions_candidate_id_fk FOREIGN KEY (candidate_id) REFERENCES candidates(id); ALTER TABLE ONLY gdpr_consent_requests ADD CONSTRAINT gdpr_consent_requests_candidate_id_fk FOREIGN KEY (candidate_id) REFERENCES candidates(id); ALTER TABLE ONLY gdpr_office_rules ADD CONSTRAINT gdpr_office_rules_office_id_fk FOREIGN KEY (office_id) REFERENCES offices(id); ALTER TABLE ONLY gho_custom_field_values ADD CONSTRAINT gho_custom_field_values_custom_field_id_fk FOREIGN KEY (custom_field_id) REFERENCES gho_custom_fields(id); ALTER TABLE ONLY gho_custom_field_values ADD CONSTRAINT gho_custom_field_values_employee_id_fk FOREIGN KEY (employee_id) REFERENCES gho_employees(id); ALTER TABLE ONLY gho_custom_field_values ADD CONSTRAINT gho_custom_field_values_value_employee_id_fk FOREIGN KEY (value_employee_id) REFERENCES gho_employees(id); ALTER TABLE ONLY gho_employee_roles ADD CONSTRAINT gho_employee_roles_employee_id_fk FOREIGN KEY (employee_id) REFERENCES gho_employees(id); ALTER TABLE ONLY gho_employee_roles ADD CONSTRAINT gho_employee_roles_role_id_fk FOREIGN KEY (role_id) REFERENCES gho_roles(id); ALTER TABLE ONLY gho_user_activities ADD CONSTRAINT gho_user_activities_employee_id_fk FOREIGN KEY (employee_id) REFERENCES gho_employees(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_post_questions ADD CONSTRAINT job_post_questions_job_post_id_fk FOREIGN KEY (job_post_id) REFERENCES job_posts(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 opening_custom_fields ADD CONSTRAINT opening_custom_fields_opening_id_fk FOREIGN KEY (opening_id) REFERENCES openings(id); ALTER TABLE ONLY opening_custom_fields ADD CONSTRAINT opening_custom_fields_user_id_fk FOREIGN KEY (user_id) REFERENCES users(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 prospect_pool_transitions ADD CONSTRAINT prospect_pool_transitions_application_id_fk FOREIGN KEY (application_id) REFERENCES applications(id); ALTER TABLE ONLY prospect_pool_transitions ADD CONSTRAINT prospect_pool_transitions_user_id_fk FOREIGN KEY (user_id) REFERENCES users(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 scorecard_question_answers ADD CONSTRAINT scorecard_question_answers_scorecard_question_id_fk FOREIGN KEY (scorecard_question_id) REFERENCES scorecard_questions(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 user_candidate_links ADD CONSTRAINT user_candidate_links_candidate_id_fk FOREIGN KEY (candidate_id) REFERENCES candidates(id); ALTER TABLE ONLY user_candidate_links ADD CONSTRAINT user_candidate_links_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);