-- Name: bank_detail_changes bank_detail_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.bank_detail_changes
    ADD CONSTRAINT bank_detail_changes_pkey PRIMARY KEY (id);


--
-- Name: branches branches_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.branches
    ADD CONSTRAINT branches_pkey PRIMARY KEY (branch_id);


--
-- Name: budgets budgets_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.budgets
    ADD CONSTRAINT budgets_pkey PRIMARY KEY (budget_id);


--
-- Name: calendar_accounts calendar_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.calendar_accounts
    ADD CONSTRAINT calendar_accounts_pkey PRIMARY KEY (id);


--
-- Name: calendar_availability calendar_availability_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.calendar_availability
    ADD CONSTRAINT calendar_availability_pkey PRIMARY KEY (id);


--
-- Name: calendar_categories calendar_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.calendar_categories
    ADD CONSTRAINT calendar_categories_pkey PRIMARY KEY (id);


--
-- Name: calendar_event_documents calendar_event_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.calendar_event_documents
    ADD CONSTRAINT calendar_event_documents_pkey PRIMARY KEY (id);


--
-- Name: calendar_event_permissions calendar_event_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.calendar_event_permissions
    ADD CONSTRAINT calendar_event_permissions_pkey PRIMARY KEY (id);


--
-- Name: calendar_events calendar_events_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.calendar_events
    ADD CONSTRAINT calendar_events_pkey PRIMARY KEY (id);


--
-- Name: career_paths career_paths_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.career_paths
    ADD CONSTRAINT career_paths_pkey PRIMARY KEY (id);


--
-- Name: career_steps career_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.career_steps
    ADD CONSTRAINT career_steps_pkey PRIMARY KEY (id);


--
-- Name: case_evidence case_evidence_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.case_evidence
    ADD CONSTRAINT case_evidence_pkey PRIMARY KEY (id);


--
-- Name: case_instructions case_instructions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.case_instructions
    ADD CONSTRAINT case_instructions_pkey PRIMARY KEY (case_instruction_id);


--
-- Name: case_notes case_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.case_notes
    ADD CONSTRAINT case_notes_pkey PRIMARY KEY (id);


--
-- Name: case_participants case_participants_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.case_participants
    ADD CONSTRAINT case_participants_pkey PRIMARY KEY (id);


--
-- Name: case_tasks case_tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.case_tasks
    ADD CONSTRAINT case_tasks_pkey PRIMARY KEY (id);


--
-- Name: cases cases_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.cases
    ADD CONSTRAINT cases_pkey PRIMARY KEY (case_id);


--
-- Name: cash_sessions cash_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.cash_sessions
    ADD CONSTRAINT cash_sessions_pkey PRIMARY KEY (id);


--
-- Name: certificate_templates certificate_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.certificate_templates
    ADD CONSTRAINT certificate_templates_pkey PRIMARY KEY (id);


--
-- Name: check_ins check_ins_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.check_ins
    ADD CONSTRAINT check_ins_pkey PRIMARY KEY (id);


--
-- Name: clarification_requests clarification_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.clarification_requests
    ADD CONSTRAINT clarification_requests_pkey PRIMARY KEY (clarification_id);


--
-- Name: clarification_responses clarification_responses_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.clarification_responses
    ADD CONSTRAINT clarification_responses_pkey PRIMARY KEY (response_id);


--
-- Name: client_payment_restrictions client_payment_restrictions_client_user_id_org_id_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.client_payment_restrictions
    ADD CONSTRAINT client_payment_restrictions_client_user_id_org_id_key UNIQUE (client_user_id, org_id);


--
-- Name: client_payment_restrictions client_payment_restrictions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.client_payment_restrictions
    ADD CONSTRAINT client_payment_restrictions_pkey PRIMARY KEY (restriction_id);


--
-- Name: client_portal_tokens client_portal_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.client_portal_tokens
    ADD CONSTRAINT client_portal_tokens_pkey PRIMARY KEY (token_id);


--
-- Name: client_portal_tokens client_portal_tokens_token_hash_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.client_portal_tokens
    ADD CONSTRAINT client_portal_tokens_token_hash_key UNIQUE (token_hash);


--
-- Name: clients clients_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.clients
    ADD CONSTRAINT clients_pkey PRIMARY KEY (client_id);


--
-- Name: companies companies_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.companies
    ADD CONSTRAINT companies_pkey PRIMARY KEY (id);


--
-- Name: competencies competencies_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.competencies
    ADD CONSTRAINT competencies_pkey PRIMARY KEY (id);


--
-- Name: competency_assessments competency_assessments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.competency_assessments
    ADD CONSTRAINT competency_assessments_pkey PRIMARY KEY (id);


--
-- Name: contract_approvals contract_approvals_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.contract_approvals
    ADD CONSTRAINT contract_approvals_pkey PRIMARY KEY (id);


--
-- Name: contract_versions contract_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.contract_versions
    ADD CONSTRAINT contract_versions_pkey PRIMARY KEY (id);


--
-- Name: contracts contracts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.contracts
    ADD CONSTRAINT contracts_pkey PRIMARY KEY (id);


--
-- Name: corrective_actions corrective_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.corrective_actions
    ADD CONSTRAINT corrective_actions_pkey PRIMARY KEY (id);


--
-- Name: countries countries_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.countries
    ADD CONSTRAINT countries_pkey PRIMARY KEY (id);


--
-- Name: country_holidays country_holidays_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.country_holidays
    ADD CONSTRAINT country_holidays_pkey PRIMARY KEY (id);


--
-- Name: credit_alerts credit_alerts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.credit_alerts
    ADD CONSTRAINT credit_alerts_pkey PRIMARY KEY (alert_id);


--
-- Name: credit_approval_requests credit_approval_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.credit_approval_requests
    ADD CONSTRAINT credit_approval_requests_pkey PRIMARY KEY (request_id);


--
-- Name: credit_limit_history credit_limit_history_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.credit_limit_history
    ADD CONSTRAINT credit_limit_history_pkey PRIMARY KEY (history_id);


--
-- Name: custom_field_values custom_field_values_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.custom_field_values
    ADD CONSTRAINT custom_field_values_pkey PRIMARY KEY (id);


--
-- Name: custom_fields custom_fields_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.custom_fields
    ADD CONSTRAINT custom_fields_pkey PRIMARY KEY (id);


--
-- Name: customer_credit_limits customer_credit_limits_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customer_credit_limits
    ADD CONSTRAINT customer_credit_limits_pkey PRIMARY KEY (credit_limit_id);


--
-- Name: customer_history customer_history_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customer_history
    ADD CONSTRAINT customer_history_pkey PRIMARY KEY (id);


--
-- Name: customer_reminder_preferences customer_reminder_preferences_customer_id_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customer_reminder_preferences
    ADD CONSTRAINT customer_reminder_preferences_customer_id_key UNIQUE (customer_id);


--
-- Name: customer_reminder_preferences customer_reminder_preferences_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customer_reminder_preferences
    ADD CONSTRAINT customer_reminder_preferences_pkey PRIMARY KEY (preference_id);


--
-- Name: customer_settings customer_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customer_settings
    ADD CONSTRAINT customer_settings_pkey PRIMARY KEY (id);


--
-- Name: customers customers_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customers
    ADD CONSTRAINT customers_pkey PRIMARY KEY (customer_id);


--
-- Name: dashboard_card_permissions dashboard_card_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.dashboard_card_permissions
    ADD CONSTRAINT dashboard_card_permissions_pkey PRIMARY KEY (id);


--
-- Name: deduction_rates deduction_rates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.deduction_rates
    ADD CONSTRAINT deduction_rates_pkey PRIMARY KEY (deduction_rate_id);


--
-- Name: deduction_types deduction_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.deduction_types
    ADD CONSTRAINT deduction_types_pkey PRIMARY KEY (deduction_type_id);


--
-- Name: demo_graph_data demo_graph_data_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.demo_graph_data
    ADD CONSTRAINT demo_graph_data_pkey PRIMARY KEY (id);


--
-- Name: departments departments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.departments
    ADD CONSTRAINT departments_pkey PRIMARY KEY (department_id);


--
-- Name: detail_view_elements detail_view_elements_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.detail_view_elements
    ADD CONSTRAINT detail_view_elements_pkey PRIMARY KEY (id);


--
-- Name: detail_views detail_views_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.detail_views
    ADD CONSTRAINT detail_views_pkey PRIMARY KEY (id);


--
-- Name: disciplinary_actions disciplinary_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.disciplinary_actions
    ADD CONSTRAINT disciplinary_actions_pkey PRIMARY KEY (id);


--
-- Name: disciplinary_cases disciplinary_cases_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.disciplinary_cases
    ADD CONSTRAINT disciplinary_cases_pkey PRIMARY KEY (id);


--
-- Name: discount_rules discount_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.discount_rules
    ADD CONSTRAINT discount_rules_pkey PRIMARY KEY (discount_rule_id);


--
-- Name: dispatch_lines dispatch_lines_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.dispatch_lines
    ADD CONSTRAINT dispatch_lines_pkey PRIMARY KEY (dispatch_line_id);


--
-- Name: dispatch_notes dispatch_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.dispatch_notes
    ADD CONSTRAINT dispatch_notes_pkey PRIMARY KEY (dispatch_note_id);


--
-- Name: districts districts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.districts
    ADD CONSTRAINT districts_pkey PRIMARY KEY (id);


--
-- Name: document_categories document_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.document_categories
    ADD CONSTRAINT document_categories_pkey PRIMARY KEY (id);


--
-- Name: document_comments document_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.document_comments
    ADD CONSTRAINT document_comments_pkey PRIMARY KEY (document_comment_id);


--
-- Name: document_folders document_folders_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.document_folders
    ADD CONSTRAINT document_folders_pkey PRIMARY KEY (id);


--
-- Name: document_metadata document_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.document_metadata
    ADD CONSTRAINT document_metadata_pkey PRIMARY KEY (document_metadata_id);


--
-- Name: document_permissions document_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.document_permissions
    ADD CONSTRAINT document_permissions_pkey PRIMARY KEY (document_permission_id);


--
-- Name: document_tags document_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.document_tags
    ADD CONSTRAINT document_tags_pkey PRIMARY KEY (document_tag_id);


--
-- Name: document_versions document_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.document_versions
    ADD CONSTRAINT document_versions_pkey PRIMARY KEY (document_version_id);


--
-- Name: documents documents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.documents
    ADD CONSTRAINT documents_pkey PRIMARY KEY (document_id);


--
-- Name: element_options element_options_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.element_options
    ADD CONSTRAINT element_options_pkey PRIMARY KEY (id);


--
-- Name: element_types element_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.element_types
    ADD CONSTRAINT element_types_pkey PRIMARY KEY (id);


--
-- Name: email_templates email_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.email_templates
    ADD CONSTRAINT email_templates_pkey PRIMARY KEY (template_id);


--
-- Name: email_templates email_templates_unique_scope; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.email_templates
    ADD CONSTRAINT email_templates_unique_scope UNIQUE (template_code, org_id, group_id, branch_id, department_id);


--
-- Name: employee_authorized_locations employee_authorized_locations_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employee_authorized_locations
    ADD CONSTRAINT employee_authorized_locations_pkey PRIMARY KEY (id);


--
-- Name: employee_certificates employee_certificates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employee_certificates
    ADD CONSTRAINT employee_certificates_pkey PRIMARY KEY (id);


--
-- Name: employee_competencies employee_competencies_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employee_competencies
    ADD CONSTRAINT employee_competencies_pkey PRIMARY KEY (id);


--
-- Name: employee_custom_fields employee_custom_fields_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employee_custom_fields
    ADD CONSTRAINT employee_custom_fields_pkey PRIMARY KEY (id);


--
-- Name: employee_custom_values employee_custom_values_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employee_custom_values
    ADD CONSTRAINT employee_custom_values_pkey PRIMARY KEY (id);


--
-- Name: employee_documents employee_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employee_documents
    ADD CONSTRAINT employee_documents_pkey PRIMARY KEY (id);


--
-- Name: employee_exits employee_exits_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employee_exits
    ADD CONSTRAINT employee_exits_pkey PRIMARY KEY (id);


--
-- Name: employee_items employee_items_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employee_items
    ADD CONSTRAINT employee_items_pkey PRIMARY KEY (id);


--
-- Name: employee_location_changes employee_location_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employee_location_changes
    ADD CONSTRAINT employee_location_changes_pkey PRIMARY KEY (id);


--
-- Name: employee_shifts employee_shifts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employee_shifts
    ADD CONSTRAINT employee_shifts_pkey PRIMARY KEY (id);


--
-- Name: employee_types employee_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employee_types
    ADD CONSTRAINT employee_types_pkey PRIMARY KEY (id);


--
-- Name: employees2locations employees2locations_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employees2locations
    ADD CONSTRAINT employees2locations_pkey PRIMARY KEY (id);


--
-- Name: employees2users employees2users_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.employees2users
    ADD CONSTRAINT employees2users_pkey PRIMARY KEY (id);


--
-- Name: event_categories event_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.event_categories
    ADD CONSTRAINT event_categories_pkey PRIMARY KEY (id);


--
-- Name: exit_approvals exit_approvals_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.exit_approvals
    ADD CONSTRAINT exit_approvals_pkey PRIMARY KEY (id);


--
-- Name: exit_clearances exit_clearances_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.exit_clearances
    ADD CONSTRAINT exit_clearances_pkey PRIMARY KEY (id);


--
-- Name: exit_feedback exit_feedback_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.exit_feedback
    ADD CONSTRAINT exit_feedback_pkey PRIMARY KEY (id);


--
-- Name: exit_interviews exit_interviews_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.exit_interviews
    ADD CONSTRAINT exit_interviews_pkey PRIMARY KEY (id);


--
-- Name: expense_types expense_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.expense_types
    ADD CONSTRAINT expense_types_pkey PRIMARY KEY (id);


--
-- Name: expenses expenses_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.expenses
    ADD CONSTRAINT expenses_pkey PRIMARY KEY (expense_id);


--
-- Name: feedback_notes feedback_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.feedback_notes
    ADD CONSTRAINT feedback_notes_pkey PRIMARY KEY (id);


--
-- Name: feedback_requests feedback_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.feedback_requests
    ADD CONSTRAINT feedback_requests_pkey PRIMARY KEY (id);


--
-- Name: field_definitions field_definitions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.field_definitions
    ADD CONSTRAINT field_definitions_pkey PRIMARY KEY (id);


--
-- Name: final_settlements final_settlements_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.final_settlements
    ADD CONSTRAINT final_settlements_pkey PRIMARY KEY (id);


--
-- Name: fishbone_diagrams fishbone_diagrams_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.fishbone_diagrams
    ADD CONSTRAINT fishbone_diagrams_pkey PRIMARY KEY (id);


--
-- Name: form_buttons form_buttons_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.form_buttons
    ADD CONSTRAINT form_buttons_pkey PRIMARY KEY (id);


--
-- Name: form_categories form_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.form_categories
    ADD CONSTRAINT form_categories_pkey PRIMARY KEY (id);


--
-- Name: form_certificates form_certificates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.form_certificates
    ADD CONSTRAINT form_certificates_pkey PRIMARY KEY (id);


--
-- Name: form_definitions form_definitions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.form_definitions
    ADD CONSTRAINT form_definitions_pkey PRIMARY KEY (id);


--
-- Name: form_submission_reviews form_submission_reviews_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.form_submission_reviews
    ADD CONSTRAINT form_submission_reviews_pkey PRIMARY KEY (id);


--
-- Name: form_submission_values form_submission_values_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.form_submission_values
    ADD CONSTRAINT form_submission_values_pkey PRIMARY KEY (id);


--
-- Name: form_submissions form_submissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.form_submissions
    ADD CONSTRAINT form_submissions_pkey PRIMARY KEY (id);


--
-- Name: form_wizard_steps form_wizard_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.form_wizard_steps
    ADD CONSTRAINT form_wizard_steps_pkey PRIMARY KEY (id);


--
-- Name: form_wizards form_wizards_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.form_wizards
    ADD CONSTRAINT form_wizards_pkey PRIMARY KEY (id);


--
-- Name: forms forms_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.forms
    ADD CONSTRAINT forms_pkey PRIMARY KEY (id);


--
-- Name: goal_alignment goal_alignment_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goal_alignment
    ADD CONSTRAINT goal_alignment_pkey PRIMARY KEY (id);


--
-- Name: goal_documents goal_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goal_documents
    ADD CONSTRAINT goal_documents_pkey PRIMARY KEY (id);


--
-- Name: goal_milestones goal_milestones_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goal_milestones
    ADD CONSTRAINT goal_milestones_pkey PRIMARY KEY (id);


--
-- Name: goal_score_labels goal_score_labels_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goal_score_labels
    ADD CONSTRAINT goal_score_labels_pkey PRIMARY KEY (id);


--
-- Name: goal_templates goal_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goal_templates
    ADD CONSTRAINT goal_templates_pkey PRIMARY KEY (id);


--
-- Name: goods_receipt_lines goods_receipt_lines_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goods_receipt_lines
    ADD CONSTRAINT goods_receipt_lines_pkey PRIMARY KEY (goods_receipt_line_id);


--
-- Name: goods_receipts goods_receipts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goods_receipts
    ADD CONSTRAINT goods_receipts_pkey PRIMARY KEY (goods_receipt_id);


--
-- Name: graphs graphs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.graphs
    ADD CONSTRAINT graphs_pkey PRIMARY KEY (id);


--
-- Name: group_column_permissions group_column_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.group_column_permissions
    ADD CONSTRAINT group_column_permissions_pkey PRIMARY KEY (group_column_permission_id);


--
-- Name: group_module_permissions group_module_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.group_module_permissions
    ADD CONSTRAINT group_module_permissions_pkey PRIMARY KEY (group_module_permission_id);


--
-- Name: group_table_permissions group_table_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.group_table_permissions
    ADD CONSTRAINT group_table_permissions_pkey PRIMARY KEY (group_table_permission_id);


--
-- Name: groups groups_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.groups
    ADD CONSTRAINT groups_pkey PRIMARY KEY (group_id);


--
-- Name: idp_providers idp_providers_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.idp_providers
    ADD CONSTRAINT idp_providers_pkey PRIMARY KEY (provider_code);


--
-- Name: import_export_configs import_export_configs_name_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.import_export_configs
    ADD CONSTRAINT import_export_configs_name_key UNIQUE (name);


--
-- Name: import_export_configs import_export_configs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.import_export_configs
    ADD CONSTRAINT import_export_configs_pkey PRIMARY KEY (config_id);


--
-- Name: incident_alert_rules incident_alert_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.incident_alert_rules
    ADD CONSTRAINT incident_alert_rules_pkey PRIMARY KEY (id);


--
-- Name: ingredients ingredients_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ingredients
    ADD CONSTRAINT ingredients_pkey PRIMARY KEY (ingredients_id);


--
-- Name: ingredients_to_products ingredients_to_products_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ingredients_to_products
    ADD CONSTRAINT ingredients_to_products_pkey PRIMARY KEY (ingredients_to_products_id);


--
-- Name: inspection_assignment_rules inspection_assignment_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inspection_assignment_rules
    ADD CONSTRAINT inspection_assignment_rules_pkey PRIMARY KEY (id);


--
-- Name: inspection_requests inspection_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inspection_requests
    ADD CONSTRAINT inspection_requests_pkey PRIMARY KEY (id);


--
-- Name: interview_logs interview_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.interview_logs
    ADD CONSTRAINT interview_logs_pkey PRIMARY KEY (id);


--
-- Name: interviews interviews_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.interviews
    ADD CONSTRAINT interviews_pkey PRIMARY KEY (interview_id);


--
-- Name: inventory_breaks inventory_breaks_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_breaks
    ADD CONSTRAINT inventory_breaks_pkey PRIMARY KEY (inventory_break_id);


--
-- Name: inventory inventory_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory
    ADD CONSTRAINT inventory_pkey PRIMARY KEY (inventory_id);


--
-- Name: inventory_receive inventory_receive_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_receive
    ADD CONSTRAINT inventory_receive_pkey PRIMARY KEY (inventory_receive_id);


--
-- Name: inventory_txn inventory_txn_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_txn
    ADD CONSTRAINT inventory_txn_pkey PRIMARY KEY (inventory_txn_id);


--
-- Name: invitations invitations_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invitations
    ADD CONSTRAINT invitations_pkey PRIMARY KEY (invitation_id);


--
-- Name: invoice_payments invoice_payments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoice_payments
    ADD CONSTRAINT invoice_payments_pkey PRIMARY KEY (id);


--
-- Name: invoice_settings invoice_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoice_settings
    ADD CONSTRAINT invoice_settings_pkey PRIMARY KEY (id);


--
-- Name: invoice_templates invoice_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoice_templates
    ADD CONSTRAINT invoice_templates_pkey PRIMARY KEY (invoice_template_id);


--
-- Name: invoice_types invoice_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoice_types
    ADD CONSTRAINT invoice_types_pkey PRIMARY KEY (invoice_type_id);


--
-- Name: invoices invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_pkey PRIMARY KEY (invoice_id);


--
-- Name: items items_item_id_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.items
    ADD CONSTRAINT items_item_id_key UNIQUE (item_id);


--
-- Name: job_opening_templates job_opening_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.job_opening_templates
    ADD CONSTRAINT job_opening_templates_pkey PRIMARY KEY (id);


--
-- Name: kanban_boards kanban_boards_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.kanban_boards
    ADD CONSTRAINT kanban_boards_pkey PRIMARY KEY (id);


--
-- Name: kanban_columns kanban_columns_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.kanban_columns
    ADD CONSTRAINT kanban_columns_pkey PRIMARY KEY (id);


--
-- Name: kanban_comments kanban_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.kanban_comments
    ADD CONSTRAINT kanban_comments_pkey PRIMARY KEY (id);


--
-- Name: kanban_tasks kanban_tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.kanban_tasks
    ADD CONSTRAINT kanban_tasks_pkey PRIMARY KEY (id);


--
-- Name: leave_balances leave_balances_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.leave_balances
    ADD CONSTRAINT leave_balances_pkey PRIMARY KEY (leave_balance_id);


--
-- Name: leave_requests leave_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.leave_requests
    ADD CONSTRAINT leave_requests_pkey PRIMARY KEY (leave_request_id);


--
-- Name: leave_types leave_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.leave_types
    ADD CONSTRAINT leave_types_pkey PRIMARY KEY (leave_type_id);


--
-- Name: legacy_resources legacy_resources_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.legacy_resources
    ADD CONSTRAINT legacy_resources_pkey PRIMARY KEY (id);


--
-- Name: line_items line_items_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.line_items
    ADD CONSTRAINT line_items_pkey PRIMARY KEY (id);


--
-- Name: lineitems_payments lineitems_payments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.lineitems_payments
    ADD CONSTRAINT lineitems_payments_pkey PRIMARY KEY (sales_receipt_id);


--
-- Name: locations locations_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.locations
    ADD CONSTRAINT locations_pkey PRIMARY KEY (id);


--
-- Name: meeting_links meeting_links_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.meeting_links
    ADD CONSTRAINT meeting_links_pkey PRIMARY KEY (id);


--
-- Name: models models_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.models
    ADD CONSTRAINT models_pkey PRIMARY KEY (model_id);


--
-- Name: modules modules_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.modules
    ADD CONSTRAINT modules_pkey PRIMARY KEY (module_id);


--
-- Name: notification_log notification_log_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.notification_log
    ADD CONSTRAINT notification_log_pkey PRIMARY KEY (id);


--
-- Name: notification_queue notification_queue_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.notification_queue
    ADD CONSTRAINT notification_queue_pkey PRIMARY KEY (id);


--
-- Name: numbering_sequences numbering_sequences_unique; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.numbering_sequences
    ADD CONSTRAINT numbering_sequences_unique UNIQUE (org_id, type, year);


--
-- Name: ohs_action_signoffs ohs_action_signoffs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_action_signoffs
    ADD CONSTRAINT ohs_action_signoffs_pkey PRIMARY KEY (id);


--
-- Name: ohs_actions ohs_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_actions
    ADD CONSTRAINT ohs_actions_pkey PRIMARY KEY (id);


--
-- Name: ohs_assignment_rules ohs_assignment_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_assignment_rules
    ADD CONSTRAINT ohs_assignment_rules_pkey PRIMARY KEY (id);


--
-- Name: ohs_compliance_logs ohs_compliance_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_compliance_logs
    ADD CONSTRAINT ohs_compliance_logs_pkey PRIMARY KEY (id);


--
-- Name: ohs_compliance_tasks ohs_compliance_tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_compliance_tasks
    ADD CONSTRAINT ohs_compliance_tasks_pkey PRIMARY KEY (id);


--
-- Name: ohs_emergency_contacts ohs_emergency_contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_emergency_contacts
    ADD CONSTRAINT ohs_emergency_contacts_pkey PRIMARY KEY (id);


--
-- Name: ohs_emergency_drills ohs_emergency_drills_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_emergency_drills
    ADD CONSTRAINT ohs_emergency_drills_pkey PRIMARY KEY (id);


--
-- Name: ohs_fault_trees ohs_fault_trees_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_fault_trees
    ADD CONSTRAINT ohs_fault_trees_pkey PRIMARY KEY (id);


--
-- Name: ohs_field_incidents ohs_field_incidents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_field_incidents
    ADD CONSTRAINT ohs_field_incidents_pkey PRIMARY KEY (id);


--
-- Name: ohs_five_whys ohs_five_whys_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_five_whys
    ADD CONSTRAINT ohs_five_whys_pkey PRIMARY KEY (id);


--
-- Name: ohs_hazard_types ohs_hazard_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_hazard_types
    ADD CONSTRAINT ohs_hazard_types_pkey PRIMARY KEY (id);


--
-- Name: ohs_hazards ohs_hazards_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_hazards
    ADD CONSTRAINT ohs_hazards_pkey PRIMARY KEY (id);


--
-- Name: ohs_health_checks ohs_health_checks_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_health_checks
    ADD CONSTRAINT ohs_health_checks_pkey PRIMARY KEY (id);


--
-- Name: ohs_incident_custom_fields ohs_incident_custom_fields_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_incident_custom_fields
    ADD CONSTRAINT ohs_incident_custom_fields_pkey PRIMARY KEY (id);


--
-- Name: ohs_incident_files ohs_incident_files_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_incident_files
    ADD CONSTRAINT ohs_incident_files_pkey PRIMARY KEY (id);


--
-- Name: ohs_incident_logs ohs_incident_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_incident_logs
    ADD CONSTRAINT ohs_incident_logs_pkey PRIMARY KEY (id);


--
-- Name: ohs_incident_signoffs ohs_incident_signoffs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_incident_signoffs
    ADD CONSTRAINT ohs_incident_signoffs_pkey PRIMARY KEY (id);


--
-- Name: ohs_incident_statuses ohs_incident_statuses_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_incident_statuses
    ADD CONSTRAINT ohs_incident_statuses_pkey PRIMARY KEY (id);


--
-- Name: ohs_incident_types ohs_incident_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_incident_types
    ADD CONSTRAINT ohs_incident_types_pkey PRIMARY KEY (id);


--
-- Name: ohs_incidents ohs_incidents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_incidents
    ADD CONSTRAINT ohs_incidents_pkey PRIMARY KEY (id);


--
-- Name: ohs_inspection_audits ohs_inspection_audits_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_inspection_audits
    ADD CONSTRAINT ohs_inspection_audits_pkey PRIMARY KEY (id);


--
-- Name: ohs_inspection_items ohs_inspection_items_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_inspection_items
    ADD CONSTRAINT ohs_inspection_items_pkey PRIMARY KEY (id);


--
-- Name: ohs_inspection_templates ohs_inspection_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_inspection_templates
    ADD CONSTRAINT ohs_inspection_templates_pkey PRIMARY KEY (id);


--
-- Name: ohs_inspection_types ohs_inspection_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_inspection_types
    ADD CONSTRAINT ohs_inspection_types_pkey PRIMARY KEY (id);


--
-- Name: ohs_inspections ohs_inspections_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_inspections
    ADD CONSTRAINT ohs_inspections_pkey PRIMARY KEY (id);


--
-- Name: ohs_issues ohs_issues_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_issues
    ADD CONSTRAINT ohs_issues_pkey PRIMARY KEY (id);


--
-- Name: ohs_jsa_reviewers ohs_jsa_reviewers_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_jsa_reviewers
    ADD CONSTRAINT ohs_jsa_reviewers_pkey PRIMARY KEY (id);


--
-- Name: ohs_jsa_signoffs ohs_jsa_signoffs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_jsa_signoffs
    ADD CONSTRAINT ohs_jsa_signoffs_pkey PRIMARY KEY (id);


--
-- Name: ohs_jsa_step_files ohs_jsa_step_files_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_jsa_step_files
    ADD CONSTRAINT ohs_jsa_step_files_pkey PRIMARY KEY (id);


--
-- Name: ohs_jsa_steps ohs_jsa_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_jsa_steps
    ADD CONSTRAINT ohs_jsa_steps_pkey PRIMARY KEY (id);


--
-- Name: ohs_jsa_training ohs_jsa_training_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_jsa_training
    ADD CONSTRAINT ohs_jsa_training_pkey PRIMARY KEY (id);


--
-- Name: ohs_jsa_versions ohs_jsa_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_jsa_versions
    ADD CONSTRAINT ohs_jsa_versions_pkey PRIMARY KEY (id);


--
-- Name: ohs_jsas ohs_jsas_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_jsas
    ADD CONSTRAINT ohs_jsas_pkey PRIMARY KEY (id);


--
-- Name: ohs_medicals ohs_medicals_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_medicals
    ADD CONSTRAINT ohs_medicals_pkey PRIMARY KEY (id);


--
-- Name: ohs_needs_expectations ohs_needs_expectations_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_needs_expectations
    ADD CONSTRAINT ohs_needs_expectations_pkey PRIMARY KEY (id);


--
-- Name: ohs_regulations ohs_regulations_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_regulations
    ADD CONSTRAINT ohs_regulations_pkey PRIMARY KEY (id);


--
-- Name: ohs_risk_matrices ohs_risk_matrices_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_risk_matrices
    ADD CONSTRAINT ohs_risk_matrices_pkey PRIMARY KEY (id);


--
-- Name: ohs_risk_reviews ohs_risk_reviews_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_risk_reviews
    ADD CONSTRAINT ohs_risk_reviews_pkey PRIMARY KEY (id);


--
-- Name: ohs_root_causes ohs_root_causes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_root_causes
    ADD CONSTRAINT ohs_root_causes_pkey PRIMARY KEY (id);


--
-- Name: ohs_severities ohs_severities_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_severities
    ADD CONSTRAINT ohs_severities_pkey PRIMARY KEY (id);


--
-- Name: ohs_stakeholders ohs_stakeholders_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_stakeholders
    ADD CONSTRAINT ohs_stakeholders_pkey PRIMARY KEY (id);


--
-- Name: ohs_training_requirements ohs_training_requirements_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ohs_training_requirements
    ADD CONSTRAINT ohs_training_requirements_pkey PRIMARY KEY (id);


--
-- Name: one_time_service_costs one_time_service_costs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.one_time_service_costs
    ADD CONSTRAINT one_time_service_costs_pkey PRIMARY KEY (one_time_service_cost_id);


--
-- Name: one_time_tokens one_time_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.one_time_tokens
    ADD CONSTRAINT one_time_tokens_pkey PRIMARY KEY (token_id);


--
-- Name: open_positions open_positions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.open_positions
    ADD CONSTRAINT open_positions_pkey PRIMARY KEY (open_position_id);


--
-- Name: orgs orgs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.orgs
    ADD CONSTRAINT orgs_pkey PRIMARY KEY (org_id);


--
-- Name: overtime_rules overtime_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.overtime_rules
    ADD CONSTRAINT overtime_rules_pkey PRIMARY KEY (id);


--
-- Name: page_configs page_configs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.page_configs
    ADD CONSTRAINT page_configs_pkey PRIMARY KEY (id);


--
-- Name: payment_items payment_items_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_items
    ADD CONSTRAINT payment_items_pkey PRIMARY KEY (payment_item_id);


--
-- Name: payment_providers payment_providers_org_id_provider_name_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_providers
    ADD CONSTRAINT payment_providers_org_id_provider_name_key UNIQUE (org_id, provider_name);


--
-- Name: payment_providers payment_providers_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_providers
    ADD CONSTRAINT payment_providers_pkey PRIMARY KEY (provider_id);


--
-- Name: payment_reminder_config payment_reminder_config_org_id_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_reminder_config
    ADD CONSTRAINT payment_reminder_config_org_id_key UNIQUE (org_id);


--
-- Name: payment_reminder_config payment_reminder_config_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_reminder_config
    ADD CONSTRAINT payment_reminder_config_pkey PRIMARY KEY (config_id);


--
-- Name: payment_reminders payment_reminders_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_reminders
    ADD CONSTRAINT payment_reminders_pkey PRIMARY KEY (reminder_id);


--
-- Name: payment_request payment_request_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_request
    ADD CONSTRAINT payment_request_pkey PRIMARY KEY (id);


--
-- Name: payment_transactions payment_transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_transactions
    ADD CONSTRAINT payment_transactions_pkey PRIMARY KEY (transaction_id);


--
-- Name: payment_types payment_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_types
    ADD CONSTRAINT payment_types_pkey PRIMARY KEY (id);


--
-- Name: payment_webhooks payment_webhooks_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_webhooks
    ADD CONSTRAINT payment_webhooks_pkey PRIMARY KEY (webhook_id);


--
-- Name: payments payments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payments
    ADD CONSTRAINT payments_pkey PRIMARY KEY (payment_id);


--
-- Name: payroll_anomalies payroll_anomalies_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payroll_anomalies
    ADD CONSTRAINT payroll_anomalies_pkey PRIMARY KEY (id);


--
-- Name: payslip_deductions payslip_deductions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payslip_deductions
    ADD CONSTRAINT payslip_deductions_pkey PRIMARY KEY (payslip_deduction_id);


--
-- Name: payslips payslips_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payslips
    ADD CONSTRAINT payslips_pkey PRIMARY KEY (payslip_id);


--
-- Name: performance_goals performance_goals_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.performance_goals
    ADD CONSTRAINT performance_goals_pkey PRIMARY KEY (id);


--
-- Name: performance_reviews performance_reviews_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.performance_reviews
    ADD CONSTRAINT performance_reviews_pkey PRIMARY KEY (id);


--
-- Name: permissions permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.permissions
    ADD CONSTRAINT permissions_pkey PRIMARY KEY (id);


--
-- Name: permit_applications permit_applications_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.permit_applications
    ADD CONSTRAINT permit_applications_pkey PRIMARY KEY (id);


--
-- Name: permit_documents permit_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.permit_documents
    ADD CONSTRAINT permit_documents_pkey PRIMARY KEY (id);


--
-- Name: permit_inspections permit_inspections_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.permit_inspections
    ADD CONSTRAINT permit_inspections_pkey PRIMARY KEY (id);


--
-- Name: permit_signatures permit_signatures_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.permit_signatures
    ADD CONSTRAINT permit_signatures_pkey PRIMARY KEY (id);


--
-- Name: permit_types permit_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.permit_types
    ADD CONSTRAINT permit_types_pkey PRIMARY KEY (id);


--
-- Name: policies policies_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.policies
    ADD CONSTRAINT policies_pkey PRIMARY KEY (policy_id);


--
-- Name: policy_acknowledgments policy_acknowledgments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.policy_acknowledgments
    ADD CONSTRAINT policy_acknowledgments_pkey PRIMARY KEY (id);


--
-- Name: policy_approvals policy_approvals_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.policy_approvals
    ADD CONSTRAINT policy_approvals_pkey PRIMARY KEY (id);


--
-- Name: policy_targets policy_targets_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.policy_targets
    ADD CONSTRAINT policy_targets_pkey PRIMARY KEY (id);


--
-- Name: policy_templates policy_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.policy_templates
    ADD CONSTRAINT policy_templates_pkey PRIMARY KEY (id);


--
-- Name: pos_settings pos_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.pos_settings
    ADD CONSTRAINT pos_settings_pkey PRIMARY KEY (pos_settings_id);


--
-- Name: procurement_requests procurement_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.procurement_requests
    ADD CONSTRAINT procurement_requests_pkey PRIMARY KEY (procurement_request_id);


--
-- Name: procurements procurements_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.procurements
    ADD CONSTRAINT procurements_pkey PRIMARY KEY (procurement_id);


--
-- Name: product_batch_number product_batch_number_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.product_batch_number
    ADD CONSTRAINT product_batch_number_pkey PRIMARY KEY (product_batch_number_id);


--
-- Name: product_categories product_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.product_categories
    ADD CONSTRAINT product_categories_pkey PRIMARY KEY (category_id);


--
-- Name: product_daily_rec product_daily_rec_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.product_daily_rec
    ADD CONSTRAINT product_daily_rec_pkey PRIMARY KEY (product_daily_rec_id);


--
-- Name: product_discounts product_discounts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.product_discounts
    ADD CONSTRAINT product_discounts_pkey PRIMARY KEY (discount_id);


--
-- Name: products_2_categories products_2_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.products_2_categories
    ADD CONSTRAINT products_2_categories_pkey PRIMARY KEY (product_category_id);


--
-- Name: products_2_taxcodes products_2_taxcodes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.products_2_taxcodes
    ADD CONSTRAINT products_2_taxcodes_pkey PRIMARY KEY (product_tax_code_id);


--
-- Name: products products_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.products
    ADD CONSTRAINT products_pkey PRIMARY KEY (product_id);


--
-- Name: products_to_vendors products_to_vendors_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.products_to_vendors
    ADD CONSTRAINT products_to_vendors_pkey PRIMARY KEY (products_to_vendor_id);


--
-- Name: program_default_group_permissions program_default_group_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_default_group_permissions
    ADD CONSTRAINT program_default_group_permissions_pkey PRIMARY KEY (program_default_permission_id);


--
-- Name: program_default_groups program_default_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_default_groups
    ADD CONSTRAINT program_default_groups_pkey PRIMARY KEY (program_default_group_id);


--
-- Name: program_default_groups program_default_groups_program_id_group_name_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_default_groups
    ADD CONSTRAINT program_default_groups_program_id_group_name_key UNIQUE (program_id, group_name);


--
-- Name: program_enrollments program_enrollments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_enrollments
    ADD CONSTRAINT program_enrollments_pkey PRIMARY KEY (program_enrollment_id);


--
-- Name: program_enrollments program_enrollments_program_id_org_id_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_enrollments
    ADD CONSTRAINT program_enrollments_program_id_org_id_key UNIQUE (program_id, org_id);


--
-- Name: program_modules program_modules_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_modules
    ADD CONSTRAINT program_modules_pkey PRIMARY KEY (program_module_id);


--
-- Name: programs programs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.programs
    ADD CONSTRAINT programs_pkey PRIMARY KEY (program_id);


--
-- Name: projects projects_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.projects
    ADD CONSTRAINT projects_pkey PRIMARY KEY (id);


--
-- Name: properties properties_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.properties
    ADD CONSTRAINT properties_pkey PRIMARY KEY (id);


--
-- Name: property_rates property_rates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.property_rates
    ADD CONSTRAINT property_rates_pkey PRIMARY KEY (id);


--
-- Name: purchase_order_lines purchase_order_lines_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_order_lines
    ADD CONSTRAINT purchase_order_lines_pkey PRIMARY KEY (purchase_order_line_id);


--
-- Name: purchase_orders purchase_orders_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_orders
    ADD CONSTRAINT purchase_orders_pkey PRIMARY KEY (purchase_order_id);


--
-- Name: push_subscriptions push_subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.push_subscriptions
    ADD CONSTRAINT push_subscriptions_pkey PRIMARY KEY (id);


--
-- Name: quotation_actions quotation_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotation_actions
    ADD CONSTRAINT quotation_actions_pkey PRIMARY KEY (action_id);


--
-- Name: quotation_settings quotation_settings_org_id_template_id_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotation_settings
    ADD CONSTRAINT quotation_settings_org_id_template_id_key UNIQUE (org_id, template_id);


--
-- Name: quotation_settings quotation_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotation_settings
    ADD CONSTRAINT quotation_settings_pkey PRIMARY KEY (quotation_setting_id);


--
-- Name: quotations quotations_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotations
    ADD CONSTRAINT quotations_pkey PRIMARY KEY (quotation_id);


--
-- Name: rate_invoices rate_invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rate_invoices
    ADD CONSTRAINT rate_invoices_pkey PRIMARY KEY (id);


--
-- Name: rate_limits rate_limits_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rate_limits
    ADD CONSTRAINT rate_limits_pkey PRIMARY KEY (key);


--
-- Name: rate_payments rate_payments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rate_payments
    ADD CONSTRAINT rate_payments_pkey PRIMARY KEY (id);


--
-- Name: ratepayers ratepayers_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ratepayers
    ADD CONSTRAINT ratepayers_pkey PRIMARY KEY (id);


--
-- Name: receipts receipts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.receipts
    ADD CONSTRAINT receipts_pkey PRIMARY KEY (id);


--
-- Name: refresh_tokens refresh_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.refresh_tokens
    ADD CONSTRAINT refresh_tokens_pkey PRIMARY KEY (token_id);


--
-- Name: reimbursement_claims reimbursement_claims_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.reimbursement_claims
    ADD CONSTRAINT reimbursement_claims_pkey PRIMARY KEY (id);


--
-- Name: resource_types resource_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.resource_types
    ADD CONSTRAINT resource_types_pkey PRIMARY KEY (id);


--
-- Name: resources resources_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.resources
    ADD CONSTRAINT resources_pkey PRIMARY KEY (id);


--
-- Name: resources resources_resource_type_id_resource_id_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.resources
    ADD CONSTRAINT resources_resource_type_id_resource_id_key UNIQUE (resource_type_id, resource_id);


--
-- Name: review_calibrations review_calibrations_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.review_calibrations
    ADD CONSTRAINT review_calibrations_pkey PRIMARY KEY (id);


--
-- Name: review_cycles review_cycles_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.review_cycles
    ADD CONSTRAINT review_cycles_pkey PRIMARY KEY (id);


--
-- Name: review_documents review_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.review_documents
    ADD CONSTRAINT review_documents_pkey PRIMARY KEY (id);


--
-- Name: review_schedules review_schedules_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.review_schedules
    ADD CONSTRAINT review_schedules_pkey PRIMARY KEY (id);


--
-- Name: rfq_approval_instances rfq_approval_instances_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_approval_instances
    ADD CONSTRAINT rfq_approval_instances_pkey PRIMARY KEY (approval_instance_id);


--
-- Name: rfq_approval_levels rfq_approval_levels_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_approval_levels
    ADD CONSTRAINT rfq_approval_levels_pkey PRIMARY KEY (rfq_approval_levels_id);


--
-- Name: rfq_attachments rfq_attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_attachments
    ADD CONSTRAINT rfq_attachments_pkey PRIMARY KEY (rfq_attachment_id);


--
-- Name: rfq_awards rfq_awards_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_awards
    ADD CONSTRAINT rfq_awards_pkey PRIMARY KEY (award_id);


--
-- Name: rfq_contracts rfq_contracts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_contracts
    ADD CONSTRAINT rfq_contracts_pkey PRIMARY KEY (contract_id);


--
-- Name: rfq_conversations rfq_conversations_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_conversations
    ADD CONSTRAINT rfq_conversations_pkey PRIMARY KEY (conversation_id);


--
-- Name: rfq_events rfq_events_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_events
    ADD CONSTRAINT rfq_events_pkey PRIMARY KEY (event_id);


--
-- Name: rfq_headers rfq_headers_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_headers
    ADD CONSTRAINT rfq_headers_pkey PRIMARY KEY (rfq_id);


--
-- Name: rfq_invites rfq_invites_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_invites
    ADD CONSTRAINT rfq_invites_pkey PRIMARY KEY (invite_id);


--
-- Name: rfq_items rfq_items_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_items
    ADD CONSTRAINT rfq_items_pkey PRIMARY KEY (id);


--
-- Name: rfq_message_attachments rfq_message_attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_message_attachments
    ADD CONSTRAINT rfq_message_attachments_pkey PRIMARY KEY (message_attachment_id);


--
-- Name: rfq_messages rfq_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_messages
    ADD CONSTRAINT rfq_messages_pkey PRIMARY KEY (message_id);


--
-- Name: rfq_scoring_notes rfq_scoring_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_scoring_notes
    ADD CONSTRAINT rfq_scoring_notes_pkey PRIMARY KEY (note_id);


--
-- Name: rfq_sections rfq_sections_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_sections
    ADD CONSTRAINT rfq_sections_pkey PRIMARY KEY (rfq_section_id);


--
-- Name: rfq_shortlists rfq_shortlists_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_shortlists
    ADD CONSTRAINT rfq_shortlists_pkey PRIMARY KEY (shortlist_id);


--
-- Name: rfq_shortlists rfq_shortlists_rfq_id_vendor_id_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_shortlists
    ADD CONSTRAINT rfq_shortlists_rfq_id_vendor_id_key UNIQUE (rfq_id, vendor_id);


--
-- Name: rfq_template_attachments rfq_template_attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_template_attachments
    ADD CONSTRAINT rfq_template_attachments_pkey PRIMARY KEY (rfq_template_attachment_id);


--
-- Name: rfq_template_sections rfq_template_sections_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_template_sections
    ADD CONSTRAINT rfq_template_sections_pkey PRIMARY KEY (rfq_template_section_id);


--
-- Name: rfq_templates rfq_templates_code_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_templates
    ADD CONSTRAINT rfq_templates_code_key UNIQUE (code);


--
-- Name: rfq_templates rfq_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_templates
    ADD CONSTRAINT rfq_templates_pkey PRIMARY KEY (rfq_template_id);


--
-- Name: rfqs rfqs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfqs
    ADD CONSTRAINT rfqs_pkey PRIMARY KEY (id);


--
-- Name: risk_assessment_files risk_assessment_files_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.risk_assessment_files
    ADD CONSTRAINT risk_assessment_files_pkey PRIMARY KEY (id);


--
-- Name: risk_assessment_hazards risk_assessment_hazards_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.risk_assessment_hazards
    ADD CONSTRAINT risk_assessment_hazards_pkey PRIMARY KEY (id);


--
-- Name: risk_assessment_ppe risk_assessment_ppe_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.risk_assessment_ppe
    ADD CONSTRAINT risk_assessment_ppe_pkey PRIMARY KEY (id);


--
-- Name: risk_assessment_signoffs risk_assessment_signoffs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.risk_assessment_signoffs
    ADD CONSTRAINT risk_assessment_signoffs_pkey PRIMARY KEY (id);


--
-- Name: risk_assessment_types risk_assessment_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.risk_assessment_types
    ADD CONSTRAINT risk_assessment_types_pkey PRIMARY KEY (id);


--
-- Name: risk_assessments risk_assessments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.risk_assessments
    ADD CONSTRAINT risk_assessments_pkey PRIMARY KEY (id);


--
-- Name: risk_categories risk_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.risk_categories
    ADD CONSTRAINT risk_categories_pkey PRIMARY KEY (id);


--
-- Name: risk_identifications risk_identifications_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.risk_identifications
    ADD CONSTRAINT risk_identifications_pkey PRIMARY KEY (id);


--
-- Name: role_competencies role_competencies_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.role_competencies
    ADD CONSTRAINT role_competencies_pkey PRIMARY KEY (id);


--
-- Name: safety_alert_files safety_alert_files_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.safety_alert_files
    ADD CONSTRAINT safety_alert_files_pkey PRIMARY KEY (id);


--
-- Name: safety_alert_logs safety_alert_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.safety_alert_logs
    ADD CONSTRAINT safety_alert_logs_pkey PRIMARY KEY (id);


--
-- Name: safety_alerts safety_alerts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.safety_alerts
    ADD CONSTRAINT safety_alerts_pkey PRIMARY KEY (id);


--
-- Name: safety_document_versions safety_document_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.safety_document_versions
    ADD CONSTRAINT safety_document_versions_pkey PRIMARY KEY (id);


--
-- Name: safety_documents safety_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.safety_documents
    ADD CONSTRAINT safety_documents_pkey PRIMARY KEY (id);


--
-- Name: safety_field_incidents safety_field_incidents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.safety_field_incidents
    ADD CONSTRAINT safety_field_incidents_pkey PRIMARY KEY (id);


--
-- Name: safety_incident_files safety_incident_files_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.safety_incident_files
    ADD CONSTRAINT safety_incident_files_pkey PRIMARY KEY (id);


--
-- Name: safety_incident_types safety_incident_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.safety_incident_types
    ADD CONSTRAINT safety_incident_types_pkey PRIMARY KEY (id);


--
-- Name: safety_incidents safety_incidents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.safety_incidents
    ADD CONSTRAINT safety_incidents_pkey PRIMARY KEY (id);


--
-- Name: salaries salaries_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.salaries
    ADD CONSTRAINT salaries_pkey PRIMARY KEY (salary_id);


--
-- Name: sales_receipts sales_receipts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.sales_receipts
    ADD CONSTRAINT sales_receipts_pkey PRIMARY KEY (sales_receipt_id);


--
-- Name: sales_tax_types sales_tax_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.sales_tax_types
    ADD CONSTRAINT sales_tax_types_pkey PRIMARY KEY (salestax_id);


--
-- Name: scheduled_reports scheduled_reports_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.scheduled_reports
    ADD CONSTRAINT scheduled_reports_pkey PRIMARY KEY (id);


--
-- Name: service_connections service_connections_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.service_connections
    ADD CONSTRAINT service_connections_pkey PRIMARY KEY (id);


--
-- Name: service_types service_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.service_types
    ADD CONSTRAINT service_types_pkey PRIMARY KEY (id);


--
-- Name: sessions sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.sessions
    ADD CONSTRAINT sessions_pkey PRIMARY KEY (session_id);


--
-- Name: settings settings_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.settings
    ADD CONSTRAINT settings_pkey PRIMARY KEY (id);


--
-- Name: shift_swaps shift_swaps_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.shift_swaps
    ADD CONSTRAINT shift_swaps_pkey PRIMARY KEY (id);


--
-- Name: shifts shifts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.shifts
    ADD CONSTRAINT shifts_pkey PRIMARY KEY (id);


--
-- Name: software_info software_info_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.software_info
    ADD CONSTRAINT software_info_pkey PRIMARY KEY (software_info_id);


--
-- Name: storage_connectors storage_connectors_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.storage_connectors
    ADD CONSTRAINT storage_connectors_pkey PRIMARY KEY (storage_connector_id);


--
-- Name: supervisor_types supervisor_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.supervisor_types
    ADD CONSTRAINT supervisor_types_pkey PRIMARY KEY (id);


--
-- Name: table_column_settings table_column_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.table_column_settings
    ADD CONSTRAINT table_column_settings_pkey PRIMARY KEY (id);


--
-- Name: table_views table_views_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.table_views
    ADD CONSTRAINT table_views_pkey PRIMARY KEY (id);


--
-- Name: tasks tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.tasks
    ADD CONSTRAINT tasks_pkey PRIMARY KEY (id);


--
-- Name: tax_core_request tax_core_request_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.tax_core_request
    ADD CONSTRAINT tax_core_request_pkey PRIMARY KEY (id);


--
-- Name: tax_core_response tax_core_response_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.tax_core_response
    ADD CONSTRAINT tax_core_response_pkey PRIMARY KEY (id);


--
-- Name: tax_ledger tax_ledger_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.tax_ledger
    ADD CONSTRAINT tax_ledger_pkey PRIMARY KEY (id);


--
-- Name: taxcore_configurations taxcore_configurations_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.taxcore_configurations
    ADD CONSTRAINT taxcore_configurations_pkey PRIMARY KEY (taxcore_config_id);


--
-- Name: taxcore_queue taxcore_queue_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.taxcore_queue
    ADD CONSTRAINT taxcore_queue_pkey PRIMARY KEY (queue_id);


--
-- Name: taxcore_submissions taxcore_submissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.taxcore_submissions
    ADD CONSTRAINT taxcore_submissions_pkey PRIMARY KEY (submission_id);


--
-- Name: tenant_admins tenant_admins_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.tenant_admins
    ADD CONSTRAINT tenant_admins_pkey PRIMARY KEY (id);


--
-- Name: tenant_idp_configs tenant_idp_configs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.tenant_idp_configs
    ADD CONSTRAINT tenant_idp_configs_pkey PRIMARY KEY (root_org_id, provider_code);


--
-- Name: tenant_module_settings tenant_module_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.tenant_module_settings
    ADD CONSTRAINT tenant_module_settings_pkey PRIMARY KEY (id);


--
-- Name: tenant_modules tenant_modules_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.tenant_modules
    ADD CONSTRAINT tenant_modules_pkey PRIMARY KEY (id);


--
-- Name: tenant_tables tenant_tables_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.tenant_tables
    ADD CONSTRAINT tenant_tables_pkey PRIMARY KEY (id);


--
-- Name: tenants tenants_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.tenants
    ADD CONSTRAINT tenants_pkey PRIMARY KEY (id);


--
-- Name: time_clock_aggregates time_clock_aggregates_org_id_user_id_start_date_end_date_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.time_clock_aggregates
    ADD CONSTRAINT time_clock_aggregates_org_id_user_id_start_date_end_date_key UNIQUE (org_id, user_id, start_date, end_date);


--
-- Name: time_clock_aggregates time_clock_aggregates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.time_clock_aggregates
    ADD CONSTRAINT time_clock_aggregates_pkey PRIMARY KEY (time_clock_aggregate_id);


--
-- Name: time_clocks time_clocks_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.time_clocks
    ADD CONSTRAINT time_clocks_pkey PRIMARY KEY (time_clocks_id);


--
-- Name: time_entries time_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.time_entries
    ADD CONSTRAINT time_entries_pkey PRIMARY KEY (time_entry_id);


--
-- Name: timesheets timesheets_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.timesheets
    ADD CONSTRAINT timesheets_pkey PRIMARY KEY (id);


--
-- Name: training_answers training_answers_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_answers
    ADD CONSTRAINT training_answers_pkey PRIMARY KEY (id);


--
-- Name: training_badges training_badges_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_badges
    ADD CONSTRAINT training_badges_pkey PRIMARY KEY (id);


--
-- Name: training_bookmarks training_bookmarks_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_bookmarks
    ADD CONSTRAINT training_bookmarks_pkey PRIMARY KEY (id);


--
-- Name: training_categories training_categories_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_categories
    ADD CONSTRAINT training_categories_pkey PRIMARY KEY (id);


--
-- Name: training_certificates training_certificates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_certificates
    ADD CONSTRAINT training_certificates_pkey PRIMARY KEY (id);


--
-- Name: training_contents training_contents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_contents
    ADD CONSTRAINT training_contents_pkey PRIMARY KEY (id);


--
-- Name: training_courses training_courses_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_courses
    ADD CONSTRAINT training_courses_pkey PRIMARY KEY (id);


--
-- Name: training_enrollments training_enrollments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_enrollments
    ADD CONSTRAINT training_enrollments_pkey PRIMARY KEY (id);


--
-- Name: training_feedback training_feedback_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_feedback
    ADD CONSTRAINT training_feedback_pkey PRIMARY KEY (id);


--
-- Name: training_path_courses training_path_courses_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_path_courses
    ADD CONSTRAINT training_path_courses_pkey PRIMARY KEY (id);


--
-- Name: training_paths training_paths_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_paths
    ADD CONSTRAINT training_paths_pkey PRIMARY KEY (id);


--
-- Name: training_questions training_questions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_questions
    ADD CONSTRAINT training_questions_pkey PRIMARY KEY (id);


--
-- Name: training_quizzes training_quizzes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_quizzes
    ADD CONSTRAINT training_quizzes_pkey PRIMARY KEY (id);


--
-- Name: training_results training_results_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_results
    ADD CONSTRAINT training_results_pkey PRIMARY KEY (id);


--
-- Name: training_sessions training_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.training_sessions
    ADD CONSTRAINT training_sessions_pkey PRIMARY KEY (id);


--
-- Name: customer_credit_limits unique_customer_org_credit_limit; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customer_credit_limits
    ADD CONSTRAINT unique_customer_org_credit_limit UNIQUE (customer_id, org_id, isdeleted);


--
-- Name: document_metadata uq_document_metadata_doc_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.document_metadata
    ADD CONSTRAINT uq_document_metadata_doc_key UNIQUE (document_id, metadata_key);


--
-- Name: document_tags uq_document_tag; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.document_tags
    ADD CONSTRAINT uq_document_tag UNIQUE (document_id, tag);


--
-- Name: rfq_scoring_notes uq_rfq_scoring_notes_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_scoring_notes
    ADD CONSTRAINT uq_rfq_scoring_notes_key UNIQUE (rfq_id, vendor_id, criterion_key);


--
-- Name: taxcore_configurations uq_taxcore_config_org; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.taxcore_configurations
    ADD CONSTRAINT uq_taxcore_config_org UNIQUE (org_id);


--
-- Name: user_2fa user_2fa_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_2fa
    ADD CONSTRAINT user_2fa_pkey PRIMARY KEY (id);


--
-- Name: user_board_settings user_board_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_board_settings
    ADD CONSTRAINT user_board_settings_pkey PRIMARY KEY (id);


--
-- Name: user_branch_memberships user_branch_memberships_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_branch_memberships
    ADD CONSTRAINT user_branch_memberships_pkey PRIMARY KEY (membership_id);


--
-- Name: user_branch_memberships user_branch_memberships_user_id_branch_id_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_branch_memberships
    ADD CONSTRAINT user_branch_memberships_user_id_branch_id_key UNIQUE (user_id, branch_id);


--
-- Name: user_column_permissions user_column_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_column_permissions
    ADD CONSTRAINT user_column_permissions_pkey PRIMARY KEY (user_column_permission_id);


--
-- Name: user_emails user_emails_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_emails
    ADD CONSTRAINT user_emails_pkey PRIMARY KEY (user_email_id);


--
-- Name: user_emails user_emails_user_id_email_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_emails
    ADD CONSTRAINT user_emails_user_id_email_key UNIQUE (user_id, email);


--
-- Name: user_faces user_faces_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_faces
    ADD CONSTRAINT user_faces_pkey PRIMARY KEY (id);


--
-- Name: user_group_memberships user_group_memberships_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_group_memberships
    ADD CONSTRAINT user_group_memberships_pkey PRIMARY KEY (membership_id);


--
-- Name: user_identities user_identities_provider_code_subject_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_identities
    ADD CONSTRAINT user_identities_provider_code_subject_key UNIQUE (provider_code, subject);


--
-- Name: user_mfa_factors user_mfa_factors_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_mfa_factors
    ADD CONSTRAINT user_mfa_factors_pkey PRIMARY KEY (factor_id);


--
-- Name: user_mfa_totp user_mfa_totp_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_mfa_totp
    ADD CONSTRAINT user_mfa_totp_pkey PRIMARY KEY (factor_id);


--
-- Name: user_mfa_webauthn user_mfa_webauthn_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_mfa_webauthn
    ADD CONSTRAINT user_mfa_webauthn_pkey PRIMARY KEY (factor_id);


--
-- Name: user_module_permissions user_module_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_module_permissions
    ADD CONSTRAINT user_module_permissions_pkey PRIMARY KEY (user_module_permission_id);


--
-- Name: user_org_memberships user_org_memberships_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_org_memberships
    ADD CONSTRAINT user_org_memberships_pkey PRIMARY KEY (membership_id);


--
-- Name: user_org_memberships user_org_memberships_user_id_org_id_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_org_memberships
    ADD CONSTRAINT user_org_memberships_user_id_org_id_key UNIQUE (user_id, org_id);


--
-- Name: user_passkeys user_passkeys_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_passkeys
    ADD CONSTRAINT user_passkeys_pkey PRIMARY KEY (id);


--
-- Name: user_passwords user_passwords_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_passwords
    ADD CONSTRAINT user_passwords_pkey PRIMARY KEY (user_id);


--
-- Name: user_phones user_phones_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_phones
    ADD CONSTRAINT user_phones_pkey PRIMARY KEY (phone_id);


--
-- Name: user_phones user_phones_user_id_phone_number_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_phones
    ADD CONSTRAINT user_phones_user_id_phone_number_key UNIQUE (user_id, phone_number);


--
-- Name: user_recovery_codes user_recovery_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_recovery_codes
    ADD CONSTRAINT user_recovery_codes_pkey PRIMARY KEY (user_id, code_hash);


--
-- Name: user_settings user_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_settings
    ADD CONSTRAINT user_settings_pkey PRIMARY KEY (id);


--
-- Name: user_table_permissions user_table_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_table_permissions
    ADD CONSTRAINT user_table_permissions_pkey PRIMARY KEY (user_table_permission_id);


--
-- Name: user_tokens user_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_tokens
    ADD CONSTRAINT user_tokens_pkey PRIMARY KEY (id);


--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (user_id);


--
-- Name: users_profiles users_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.users_profiles
    ADD CONSTRAINT users_profiles_pkey PRIMARY KEY (user_profile_id);


--
-- Name: vehicle_makes vehicle_makes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vehicle_makes
    ADD CONSTRAINT vehicle_makes_pkey PRIMARY KEY (id);


--
-- Name: vehicle_models vehicle_models_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vehicle_models
    ADD CONSTRAINT vehicle_models_pkey PRIMARY KEY (id);


--
-- Name: vehicle_report_comments vehicle_report_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vehicle_report_comments
    ADD CONSTRAINT vehicle_report_comments_pkey PRIMARY KEY (id);


--
-- Name: vehicle_report_parts vehicle_report_parts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vehicle_report_parts
    ADD CONSTRAINT vehicle_report_parts_pkey PRIMARY KEY (id);


--
-- Name: vehicle_reports vehicle_reports_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vehicle_reports
    ADD CONSTRAINT vehicle_reports_pkey PRIMARY KEY (id);


--
-- Name: vehicle_services vehicle_services_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vehicle_services
    ADD CONSTRAINT vehicle_services_pkey PRIMARY KEY (id);


--
-- Name: vehicle_trip_points vehicle_trip_points_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vehicle_trip_points
    ADD CONSTRAINT vehicle_trip_points_pkey PRIMARY KEY (id);


--
-- Name: vehicle_trips vehicle_trips_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vehicle_trips
    ADD CONSTRAINT vehicle_trips_pkey PRIMARY KEY (id);


--
-- Name: vehicle_types vehicle_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vehicle_types
    ADD CONSTRAINT vehicle_types_pkey PRIMARY KEY (id);


--
-- Name: vehicles vehicles_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vehicles
    ADD CONSTRAINT vehicles_pkey PRIMARY KEY (id);


--
-- Name: vendor_addresses vendor_addresses_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_addresses
    ADD CONSTRAINT vendor_addresses_pkey PRIMARY KEY (vendor_address_id);


--
-- Name: vendor_bank_accounts vendor_bank_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_bank_accounts
    ADD CONSTRAINT vendor_bank_accounts_pkey PRIMARY KEY (vendor_bank_account_id);


--
-- Name: vendor_capabilities vendor_capabilities_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_capabilities
    ADD CONSTRAINT vendor_capabilities_pkey PRIMARY KEY (vendor_capability_id);


--
-- Name: vendor_certificates vendor_certificates_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_certificates
    ADD CONSTRAINT vendor_certificates_pkey PRIMARY KEY (vendor_certificate_id);


--
-- Name: vendor_contacts vendor_contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_contacts
    ADD CONSTRAINT vendor_contacts_pkey PRIMARY KEY (vendor_contact_id);


--
-- Name: vendor_documents vendor_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_documents
    ADD CONSTRAINT vendor_documents_pkey PRIMARY KEY (vendor_document_id);


--
-- Name: vendor_emails vendor_emails_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_emails
    ADD CONSTRAINT vendor_emails_pkey PRIMARY KEY (vendor_email_id);


--
-- Name: vendor_invoices vendor_invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_invoices
    ADD CONSTRAINT vendor_invoices_pkey PRIMARY KEY (vendor_invoice_id);


--
-- Name: vendor_performance_metrics vendor_performance_metrics_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_performance_metrics
    ADD CONSTRAINT vendor_performance_metrics_pkey PRIMARY KEY (vendor_performance_metric_id);


--
-- Name: vendor_phone_numbers vendor_phone_numbers_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_phone_numbers
    ADD CONSTRAINT vendor_phone_numbers_pkey PRIMARY KEY (vendor_phone_id);


--
-- Name: vendor_quote_items vendor_quote_items_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_quote_items
    ADD CONSTRAINT vendor_quote_items_pkey PRIMARY KEY (quote_item_id);


--
-- Name: vendor_quotes vendor_quotes_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_quotes
    ADD CONSTRAINT vendor_quotes_pkey PRIMARY KEY (quote_id);


--
-- Name: vendor_supporting_docs vendor_supporting_docs_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_supporting_docs
    ADD CONSTRAINT vendor_supporting_docs_pkey PRIMARY KEY (vendor_supporting_doc_id);


--
-- Name: vendors vendors_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendors
    ADD CONSTRAINT vendors_pkey PRIMARY KEY (vendor_id);


--
-- Name: view_filters view_filters_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.view_filters
    ADD CONSTRAINT view_filters_pkey PRIMARY KEY (id);


--
-- Name: violation_types violation_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.violation_types
    ADD CONSTRAINT violation_types_pkey PRIMARY KEY (id);


--
-- Name: work_types work_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.work_types
    ADD CONSTRAINT work_types_pkey PRIMARY KEY (work_type_id);


--
-- Name: workcom_inspection_types workcom_inspection_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workcom_inspection_types
    ADD CONSTRAINT workcom_inspection_types_pkey PRIMARY KEY (id);


--
-- Name: workcom_inspections workcom_inspections_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workcom_inspections
    ADD CONSTRAINT workcom_inspections_pkey PRIMARY KEY (id);


--
-- Name: workflow_approvals workflow_approvals_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workflow_approvals
    ADD CONSTRAINT workflow_approvals_pkey PRIMARY KEY (id);


--
-- Name: workflow_event_triggers workflow_event_triggers_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workflow_event_triggers
    ADD CONSTRAINT workflow_event_triggers_pkey PRIMARY KEY (id);


--
-- Name: workflow_instances workflow_instances_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workflow_instances
    ADD CONSTRAINT workflow_instances_pkey PRIMARY KEY (id);


--
-- Name: workflow_states workflow_states_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workflow_states
    ADD CONSTRAINT workflow_states_pkey PRIMARY KEY (id);


--
-- Name: workflow_step_types workflow_step_types_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workflow_step_types
    ADD CONSTRAINT workflow_step_types_pkey PRIMARY KEY (id);


--
-- Name: workflow_steps workflow_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workflow_steps
    ADD CONSTRAINT workflow_steps_pkey PRIMARY KEY (id);


--
-- Name: workflow_tasks workflow_tasks_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workflow_tasks
    ADD CONSTRAINT workflow_tasks_pkey PRIMARY KEY (id);


--
-- Name: workflow_transitions workflow_transitions_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workflow_transitions
    ADD CONSTRAINT workflow_transitions_pkey PRIMARY KEY (id);


--
-- Name: workflow_triggers workflow_triggers_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workflow_triggers
    ADD CONSTRAINT workflow_triggers_pkey PRIMARY KEY (id);


--
-- Name: workflows workflows_name_key; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workflows
    ADD CONSTRAINT workflows_name_key UNIQUE (name);


--
-- Name: workflows workflows_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workflows
    ADD CONSTRAINT workflows_pkey PRIMARY KEY (id);


--
-- Name: workplace_registrations workplace_registrations_pkey; Type: CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.workplace_registrations
    ADD CONSTRAINT workplace_registrations_pkey PRIMARY KEY (id);


--
-- Name: audit_logs_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX audit_logs_branch_idx ON public.audit_logs USING btree (branch_id);


--
-- Name: audit_logs_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX audit_logs_tenant_idx ON public.audit_logs USING btree (tenant_id);


--
-- Name: calendar_accounts_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX calendar_accounts_branch_idx ON public.calendar_accounts USING btree (branch_id);


--
-- Name: calendar_accounts_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX calendar_accounts_tenant_idx ON public.calendar_accounts USING btree (tenant_id);


--
-- Name: calendar_availability_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX calendar_availability_branch_idx ON public.calendar_availability USING btree (branch_id);


--
-- Name: calendar_availability_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX calendar_availability_tenant_idx ON public.calendar_availability USING btree (tenant_id);


--
-- Name: calendar_event_documents_org_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX calendar_event_documents_org_idx ON public.calendar_event_documents USING btree (org_id);


--
-- Name: calendar_event_permissions_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX calendar_event_permissions_branch_idx ON public.calendar_event_permissions USING btree (branch_id);


--
-- Name: calendar_event_permissions_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX calendar_event_permissions_tenant_idx ON public.calendar_event_permissions USING btree (tenant_id);


--
-- Name: calendar_events_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX calendar_events_branch_idx ON public.calendar_events USING btree (branch_id);


--
-- Name: calendar_events_category_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX calendar_events_category_idx ON public.calendar_events USING btree (category_id);


--
-- Name: calendar_events_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX calendar_events_tenant_idx ON public.calendar_events USING btree (tenant_id);


--
-- Name: corrective_actions_incident_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX corrective_actions_incident_idx ON public.corrective_actions USING btree (incident_id);


--
-- Name: dcp_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX dcp_branch_idx ON public.dashboard_card_permissions USING btree (branch_id);


--
-- Name: dcp_group_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX dcp_group_idx ON public.dashboard_card_permissions USING btree (group_id);


--
-- Name: dcp_slug_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX dcp_slug_idx ON public.dashboard_card_permissions USING btree (card_slug);


--
-- Name: dcp_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX dcp_tenant_idx ON public.dashboard_card_permissions USING btree (tenant_id);


--
-- Name: dcp_user_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX dcp_user_idx ON public.dashboard_card_permissions USING btree (user_id);


--
-- Name: detail_views_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX detail_views_branch_idx ON public.detail_views USING btree (branch_id);


--
-- Name: detail_views_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX detail_views_tenant_idx ON public.detail_views USING btree (tenant_id);


--
-- Name: discount_rules_category_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX discount_rules_category_idx ON public.discount_rules USING btree (category_id) WHERE (category_id IS NOT NULL);


--
-- Name: discount_rules_org_type_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX discount_rules_org_type_idx ON public.discount_rules USING btree (org_id, discount_type);


--
-- Name: discount_rules_product_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX discount_rules_product_idx ON public.discount_rules USING btree (product_id) WHERE (product_id IS NOT NULL);


--
-- Name: document_categories_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX document_categories_branch_idx ON public.document_categories USING btree (branch_id);


--
-- Name: document_categories_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX document_categories_tenant_idx ON public.document_categories USING btree (tenant_id);


--
-- Name: documents_category_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX documents_category_idx ON public.documents USING btree (category_id);


--
-- Name: dve_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX dve_branch_idx ON public.detail_view_elements USING btree (branch_id);


--
-- Name: dve_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX dve_tenant_idx ON public.detail_view_elements USING btree (tenant_id);


--
-- Name: dve_view_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX dve_view_idx ON public.detail_view_elements USING btree (detail_view_id);


--
-- Name: fishbone_diagrams_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX fishbone_diagrams_branch_idx ON public.fishbone_diagrams USING btree (branch_id);


--
-- Name: fishbone_diagrams_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX fishbone_diagrams_tenant_idx ON public.fishbone_diagrams USING btree (tenant_id);


--
-- Name: form_buttons_form_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX form_buttons_form_idx ON public.form_buttons USING btree (form_id);


--
-- Name: form_submission_reviews_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX form_submission_reviews_branch_idx ON public.form_submission_reviews USING btree (branch_id);


--
-- Name: form_submission_reviews_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX form_submission_reviews_tenant_idx ON public.form_submission_reviews USING btree (tenant_id);


--
-- Name: form_wizards_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX form_wizards_branch_idx ON public.form_wizards USING btree (branch_id);


--
-- Name: form_wizards_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX form_wizards_tenant_idx ON public.form_wizards USING btree (tenant_id);


--
-- Name: forms_share_slug_unique; Type: INDEX; Schema: public; Owner: taf
--

CREATE UNIQUE INDEX forms_share_slug_unique ON public.forms USING btree (share_slug) WHERE (share_slug IS NOT NULL);


--
-- Name: fws_form_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX fws_form_idx ON public.form_wizard_steps USING btree (form_id);


--
-- Name: fws_wizard_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX fws_wizard_idx ON public.form_wizard_steps USING btree (wizard_id);


--
-- Name: graphs_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX graphs_branch_idx ON public.graphs USING btree (branch_id);


--
-- Name: graphs_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX graphs_tenant_idx ON public.graphs USING btree (tenant_id);


--
-- Name: idx_clarification_responses_clarification; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_clarification_responses_clarification ON public.clarification_responses USING btree (clarification_id);


--
-- Name: idx_clarification_responses_user; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_clarification_responses_user ON public.clarification_responses USING btree (user_id);


--
-- Name: idx_clarifications_client; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_clarifications_client ON public.clarification_requests USING btree (client_user_id);


--
-- Name: idx_clarifications_org_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_clarifications_org_id ON public.clarification_requests USING btree (org_id);


--
-- Name: idx_clarifications_reference; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_clarifications_reference ON public.clarification_requests USING btree (reference_id, reference_table);


--
-- Name: idx_clarifications_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_clarifications_status ON public.clarification_requests USING btree (status);


--
-- Name: idx_client_restrictions_client; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_client_restrictions_client ON public.client_payment_restrictions USING btree (client_user_id);


--
-- Name: idx_client_restrictions_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_client_restrictions_org ON public.client_payment_restrictions USING btree (org_id);


--
-- Name: idx_credit_alerts_created; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_alerts_created ON public.credit_alerts USING btree (created_at DESC);


--
-- Name: idx_credit_alerts_credit_limit; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_alerts_credit_limit ON public.credit_alerts USING btree (credit_limit_id);


--
-- Name: idx_credit_alerts_customer; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_alerts_customer ON public.credit_alerts USING btree (customer_id);


--
-- Name: idx_credit_alerts_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_alerts_org ON public.credit_alerts USING btree (org_id);


--
-- Name: idx_credit_alerts_severity; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_alerts_severity ON public.credit_alerts USING btree (severity);


--
-- Name: idx_credit_alerts_type; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_alerts_type ON public.credit_alerts USING btree (alert_type);


--
-- Name: idx_credit_alerts_unacknowledged; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_alerts_unacknowledged ON public.credit_alerts USING btree (acknowledged) WHERE (acknowledged = false);


--
-- Name: idx_credit_approval_requests_created; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_approval_requests_created ON public.credit_approval_requests USING btree (created_at DESC);


--
-- Name: idx_credit_approval_requests_customer; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_approval_requests_customer ON public.credit_approval_requests USING btree (customer_id);


--
-- Name: idx_credit_approval_requests_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_approval_requests_org ON public.credit_approval_requests USING btree (org_id);


--
-- Name: idx_credit_approval_requests_reference; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_approval_requests_reference ON public.credit_approval_requests USING btree (reference_type, reference_id);


--
-- Name: idx_credit_approval_requests_requested_by; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_approval_requests_requested_by ON public.credit_approval_requests USING btree (requested_by);


--
-- Name: idx_credit_approval_requests_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_approval_requests_status ON public.credit_approval_requests USING btree (status) WHERE ((status)::text = 'pending'::text);


--
-- Name: idx_credit_limit_history_change_type; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_limit_history_change_type ON public.credit_limit_history USING btree (change_type);


--
-- Name: idx_credit_limit_history_created; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_limit_history_created ON public.credit_limit_history USING btree (created_at DESC);


--
-- Name: idx_credit_limit_history_credit_limit; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_limit_history_credit_limit ON public.credit_limit_history USING btree (credit_limit_id);


--
-- Name: idx_credit_limit_history_customer; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_limit_history_customer ON public.credit_limit_history USING btree (customer_id);


--
-- Name: idx_credit_limit_history_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_credit_limit_history_org ON public.credit_limit_history USING btree (org_id);


--
-- Name: idx_customer_credit_limits_customer; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_customer_credit_limits_customer ON public.customer_credit_limits USING btree (customer_id) WHERE (isdeleted = false);


--
-- Name: idx_customer_credit_limits_on_hold; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_customer_credit_limits_on_hold ON public.customer_credit_limits USING btree (is_on_hold) WHERE ((isdeleted = false) AND (is_on_hold = true));


--
-- Name: idx_customer_credit_limits_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_customer_credit_limits_org ON public.customer_credit_limits USING btree (org_id) WHERE (isdeleted = false);


--
-- Name: idx_customer_credit_limits_utilization; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_customer_credit_limits_utilization ON public.customer_credit_limits USING btree (utilized_credit, credit_limit) WHERE (isdeleted = false);


--
-- Name: idx_customer_reminder_prefs_customer; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_customer_reminder_prefs_customer ON public.customer_reminder_preferences USING btree (customer_id) WHERE (isdeleted = false);


--
-- Name: idx_customer_reminder_prefs_opted_out; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_customer_reminder_prefs_opted_out ON public.customer_reminder_preferences USING btree (opted_out) WHERE (opted_out = true);


--
-- Name: idx_customer_reminder_prefs_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_customer_reminder_prefs_org ON public.customer_reminder_preferences USING btree (org_id) WHERE (isdeleted = false);


--
-- Name: idx_dispatch_lines_note; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_dispatch_lines_note ON public.dispatch_lines USING btree (dispatch_note_id) WHERE (isdeleted = false);


--
-- Name: idx_dispatch_lines_product; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_dispatch_lines_product ON public.dispatch_lines USING btree (product_id) WHERE (isdeleted = false);


--
-- Name: idx_dispatch_notes_from; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_dispatch_notes_from ON public.dispatch_notes USING btree (from_branch_id) WHERE (isdeleted = false);


--
-- Name: idx_dispatch_notes_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_dispatch_notes_org ON public.dispatch_notes USING btree (org_id) WHERE (isdeleted = false);


--
-- Name: idx_dispatch_notes_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_dispatch_notes_status ON public.dispatch_notes USING btree (status) WHERE (isdeleted = false);


--
-- Name: idx_dispatch_notes_to; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_dispatch_notes_to ON public.dispatch_notes USING btree (to_branch_id) WHERE (isdeleted = false);


--
-- Name: idx_dispatch_number_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE UNIQUE INDEX idx_dispatch_number_org ON public.dispatch_notes USING btree (org_id, dispatch_number) WHERE (isdeleted = false);


--
-- Name: idx_doc_metadata_case_lookup; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_doc_metadata_case_lookup ON public.document_metadata USING btree (metadata_value) WHERE ((metadata_key)::text = 'case_id'::text);


--
-- Name: idx_doc_metadata_client_lookup; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_doc_metadata_client_lookup ON public.document_metadata USING btree (metadata_value) WHERE ((metadata_key)::text = 'client_id'::text);


--
-- Name: idx_doc_metadata_doc; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_doc_metadata_doc ON public.document_metadata USING btree (document_id);


--
-- Name: idx_doc_metadata_doc_key; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_doc_metadata_doc_key ON public.document_metadata USING btree (document_id, metadata_key);


--
-- Name: idx_doc_metadata_key; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_doc_metadata_key ON public.document_metadata USING btree (metadata_key);


--
-- Name: idx_doc_metadata_value; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_doc_metadata_value ON public.document_metadata USING btree (metadata_value) WHERE (searchable = true);


--
-- Name: idx_doc_tags_system; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_doc_tags_system ON public.document_tags USING btree (tag) WHERE ((tag_type)::text = 'system'::text);


--
-- Name: idx_document_tags_doc; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_document_tags_doc ON public.document_tags USING btree (document_id);


--
-- Name: idx_document_tags_parent; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_document_tags_parent ON public.document_tags USING btree (parent_tag_id);


--
-- Name: idx_document_tags_tag; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_document_tags_tag ON public.document_tags USING btree (tag);


--
-- Name: idx_documents_parent; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_documents_parent ON public.documents USING btree (parent_document_id) WHERE (parent_document_id IS NOT NULL);


--
-- Name: idx_email_templates_active; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_email_templates_active ON public.email_templates USING btree (is_active) WHERE (isdeleted = false);


--
-- Name: idx_email_templates_category; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_email_templates_category ON public.email_templates USING btree (category) WHERE (isdeleted = false);


--
-- Name: idx_email_templates_code; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_email_templates_code ON public.email_templates USING btree (template_code) WHERE (isdeleted = false);


--
-- Name: idx_email_templates_default; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_email_templates_default ON public.email_templates USING btree (is_default) WHERE (isdeleted = false);


--
-- Name: idx_email_templates_lookup_branch; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_email_templates_lookup_branch ON public.email_templates USING btree (template_code, org_id, branch_id, is_active) WHERE (isdeleted = false);


--
-- Name: idx_email_templates_lookup_group; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_email_templates_lookup_group ON public.email_templates USING btree (template_code, org_id, group_id, is_active) WHERE (isdeleted = false);


--
-- Name: idx_email_templates_lookup_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_email_templates_lookup_org ON public.email_templates USING btree (template_code, org_id, is_active) WHERE (isdeleted = false);


--
-- Name: idx_email_templates_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_email_templates_org ON public.email_templates USING btree (org_id) WHERE (isdeleted = false);


--
-- Name: idx_email_templates_priority; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_email_templates_priority ON public.email_templates USING btree (priority DESC) WHERE (isdeleted = false);


--
-- Name: idx_goods_receipts_date; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_goods_receipts_date ON public.goods_receipts USING btree (received_date) WHERE (isdeleted = false);


--
-- Name: idx_goods_receipts_po; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_goods_receipts_po ON public.goods_receipts USING btree (purchase_order_id) WHERE (isdeleted = false);


--
-- Name: idx_gr_lines_po_line; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_gr_lines_po_line ON public.goods_receipt_lines USING btree (purchase_order_line_id) WHERE (isdeleted = false);


--
-- Name: idx_gr_lines_receipt; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_gr_lines_receipt ON public.goods_receipt_lines USING btree (goods_receipt_id) WHERE (isdeleted = false);


--
-- Name: idx_import_export_configs_name; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_import_export_configs_name ON public.import_export_configs USING btree (name) WHERE (isdeleted = false);


--
-- Name: idx_import_export_configs_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_import_export_configs_org ON public.import_export_configs USING btree (org_id) WHERE (isdeleted = false);


--
-- Name: idx_import_export_configs_table; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_import_export_configs_table ON public.import_export_configs USING btree (table_name) WHERE (isdeleted = false);


--
-- Name: idx_import_export_configs_type; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_import_export_configs_type ON public.import_export_configs USING btree (type) WHERE (isdeleted = false);


--
-- Name: idx_inventory_breaks_branch; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_inventory_breaks_branch ON public.inventory_breaks USING btree (branch_id) WHERE (isdeleted = false);


--
-- Name: idx_inventory_breaks_date; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_inventory_breaks_date ON public.inventory_breaks USING btree (break_date) WHERE (isdeleted = false);


--
-- Name: idx_inventory_breaks_product; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_inventory_breaks_product ON public.inventory_breaks USING btree (product_id) WHERE (isdeleted = false);


--
-- Name: idx_invoices_advance_payment_for; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_invoices_advance_payment_for ON public.invoices USING btree (advance_payment_for_invoice_id);


--
-- Name: idx_invoices_aging_lookup; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_invoices_aging_lookup ON public.invoices USING btree (org_id, invoice_date, status) WHERE ((isdeleted = false) AND (amount > (0)::numeric));


--
-- Name: idx_invoices_invoice_date; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_invoices_invoice_date ON public.invoices USING btree (invoice_date);


--
-- Name: idx_invoices_is_proforma; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_invoices_is_proforma ON public.invoices USING btree (is_proforma);


--
-- Name: idx_invoices_org_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_invoices_org_id ON public.invoices USING btree (org_id);


--
-- Name: idx_invoices_reference_lookup; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_invoices_reference_lookup ON public.invoices USING btree (reference_table, reference_id) WHERE (isdeleted = false);


--
-- Name: idx_invoices_refund_for; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_invoices_refund_for ON public.invoices USING btree (refund_for_invoice_id);


--
-- Name: idx_invoices_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_invoices_status ON public.invoices USING btree (status);


--
-- Name: idx_invoices_submission_fk; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_invoices_submission_fk ON public.invoices USING btree (taxcore_submission_id_fk) WHERE (taxcore_submission_id_fk IS NOT NULL);


--
-- Name: idx_invoices_taxcore_submission; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_invoices_taxcore_submission ON public.invoices USING btree (taxcore_submission_id);


--
-- Name: idx_lineitems_payments_case_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_lineitems_payments_case_id ON public.lineitems_payments USING btree (case_id);


--
-- Name: idx_lineitems_payments_customer_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_lineitems_payments_customer_id ON public.lineitems_payments USING btree (customer_id);


--
-- Name: idx_mvmt_history_date; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_mvmt_history_date ON public.inventory_movement_history USING btree (movement_date);


--
-- Name: idx_mvmt_history_location; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_mvmt_history_location ON public.inventory_movement_history USING btree (location_id);


--
-- Name: idx_mvmt_history_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_mvmt_history_org ON public.inventory_movement_history USING btree (org_id);


--
-- Name: idx_mvmt_history_product; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_mvmt_history_product ON public.inventory_movement_history USING btree (product_id);


--
-- Name: idx_payment_items_method; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_items_method ON public.payment_items USING btree (method);


--
-- Name: idx_payment_items_payment_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_items_payment_id ON public.payment_items USING btree (payment_id);


--
-- Name: idx_payment_providers_active; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_providers_active ON public.payment_providers USING btree (is_active);


--
-- Name: idx_payment_providers_org_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_providers_org_id ON public.payment_providers USING btree (org_id);


--
-- Name: idx_payment_reminder_config_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_reminder_config_org ON public.payment_reminder_config USING btree (org_id) WHERE (isdeleted = false);


--
-- Name: idx_payment_reminders_channel; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_reminders_channel ON public.payment_reminders USING btree (channel, status) WHERE (isdeleted = false);


--
-- Name: idx_payment_reminders_customer; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_reminders_customer ON public.payment_reminders USING btree (customer_id, sent_at) WHERE (isdeleted = false);


--
-- Name: idx_payment_reminders_invoice; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_reminders_invoice ON public.payment_reminders USING btree (invoice_id, sent_at) WHERE (isdeleted = false);


--
-- Name: idx_payment_reminders_metadata; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_reminders_metadata ON public.payment_reminders USING gin (metadata) WHERE (isdeleted = false);


--
-- Name: idx_payment_reminders_org_stage; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_reminders_org_stage ON public.payment_reminders USING btree (org_id, reminder_stage, sent_at) WHERE (isdeleted = false);


--
-- Name: idx_payment_reminders_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_reminders_status ON public.payment_reminders USING btree (status, sent_at) WHERE (isdeleted = false);


--
-- Name: idx_payment_txn_client; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_txn_client ON public.payment_transactions USING btree (client_user_id);


--
-- Name: idx_payment_txn_created_at; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_txn_created_at ON public.payment_transactions USING btree (created_at);


--
-- Name: idx_payment_txn_invoice_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_txn_invoice_id ON public.payment_transactions USING btree (invoice_id);


--
-- Name: idx_payment_txn_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_txn_org ON public.payment_transactions USING btree (org_id);


--
-- Name: idx_payment_txn_payment_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_txn_payment_id ON public.payment_transactions USING btree (payment_id);


--
-- Name: idx_payment_txn_provider_ref; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_txn_provider_ref ON public.payment_transactions USING btree (provider_transaction_id);


--
-- Name: idx_payment_txn_quotation_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_txn_quotation_id ON public.payment_transactions USING btree (quotation_id);


--
-- Name: idx_payment_txn_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payment_txn_status ON public.payment_transactions USING btree (status);


--
-- Name: idx_payments_payment_date; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payments_payment_date ON public.payments USING btree (payment_date) WHERE (isdeleted = false);


--
-- Name: idx_payments_payment_method; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payments_payment_method ON public.payments USING btree (org_id, payment_method) WHERE (isdeleted = false);


--
-- Name: idx_payments_reference; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_payments_reference ON public.payments USING btree (reference_table, reference_id);


--
-- Name: idx_po_lines_po; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_po_lines_po ON public.purchase_order_lines USING btree (purchase_order_id) WHERE (isdeleted = false);


--
-- Name: idx_po_lines_product; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_po_lines_product ON public.purchase_order_lines USING btree (product_id) WHERE (isdeleted = false);


--
-- Name: idx_portal_tokens_expires_at; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_portal_tokens_expires_at ON public.client_portal_tokens USING btree (expires_at);


--
-- Name: idx_portal_tokens_reference; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_portal_tokens_reference ON public.client_portal_tokens USING btree (reference_id, reference_table);


--
-- Name: idx_portal_tokens_token_hash; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_portal_tokens_token_hash ON public.client_portal_tokens USING btree (token_hash);


--
-- Name: idx_portal_tokens_user_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_portal_tokens_user_id ON public.client_portal_tokens USING btree (user_id);


--
-- Name: idx_products_category; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_products_category ON public.products USING btree (org_id, category_id) WHERE (isdeleted = false);


--
-- Name: idx_purchase_orders_org_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_purchase_orders_org_status ON public.purchase_orders USING btree (org_id, status) WHERE (isdeleted = false);


--
-- Name: idx_purchase_orders_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_purchase_orders_status ON public.purchase_orders USING btree (status) WHERE (isdeleted = false);


--
-- Name: idx_quotation_actions_created_at; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_quotation_actions_created_at ON public.quotation_actions USING btree (created_at);


--
-- Name: idx_quotation_actions_quotation_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_quotation_actions_quotation_id ON public.quotation_actions USING btree (quotation_id);


--
-- Name: idx_quotation_actions_type; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_quotation_actions_type ON public.quotation_actions USING btree (action_type);


--
-- Name: idx_quotation_actions_user_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_quotation_actions_user_id ON public.quotation_actions USING btree (user_id);


--
-- Name: idx_quotation_settings_org_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_quotation_settings_org_id ON public.quotation_settings USING btree (org_id);


--
-- Name: idx_quotations_client_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_quotations_client_id ON public.quotations USING btree (client_id);


--
-- Name: idx_quotations_created_by; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_quotations_created_by ON public.quotations USING btree (created_by);


--
-- Name: idx_quotations_customer_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_quotations_customer_org ON public.quotations USING btree (customer_id, org_id) WHERE (isdeleted = false);


--
-- Name: idx_quotations_date; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_quotations_date ON public.quotations USING btree (date);


--
-- Name: idx_quotations_org_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_quotations_org_id ON public.quotations USING btree (org_id);


--
-- Name: idx_quotations_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_quotations_status ON public.quotations USING btree (status);


--
-- Name: idx_rfq_attachments_rfq; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_attachments_rfq ON public.rfq_attachments USING btree (rfq_id);


--
-- Name: idx_rfq_awards_rfq; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_awards_rfq ON public.rfq_awards USING btree (rfq_id);


--
-- Name: idx_rfq_contracts_number; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_contracts_number ON public.rfq_contracts USING btree (contract_number);


--
-- Name: idx_rfq_contracts_rfq; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_contracts_rfq ON public.rfq_contracts USING btree (rfq_id);


--
-- Name: idx_rfq_contracts_vendor; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_contracts_vendor ON public.rfq_contracts USING btree (vendor_id);


--
-- Name: idx_rfq_conversations_rfq; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_conversations_rfq ON public.rfq_conversations USING btree (rfq_id);


--
-- Name: idx_rfq_conversations_scope; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_conversations_scope ON public.rfq_conversations USING btree (rfq_id, audience);


--
-- Name: idx_rfq_conversations_vendor; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_conversations_vendor ON public.rfq_conversations USING btree (rfq_id, vendor_id) WHERE (vendor_id IS NOT NULL);


--
-- Name: idx_rfq_events_payload_gin; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_events_payload_gin ON public.rfq_events USING gin (payload);


--
-- Name: idx_rfq_events_rfq; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_events_rfq ON public.rfq_events USING btree (rfq_id, created_at);


--
-- Name: idx_rfq_headers_org_type; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_headers_org_type ON public.rfq_headers USING btree (org_id, type);


--
-- Name: idx_rfq_headers_status_due; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_headers_status_due ON public.rfq_headers USING btree (status, due_at);


--
-- Name: idx_rfq_invites_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_invites_status ON public.rfq_invites USING btree (rfq_id, status);


--
-- Name: idx_rfq_items_rfq; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_items_rfq ON public.rfq_items USING btree (rfq_id);


--
-- Name: idx_rfq_items_specs; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_items_specs ON public.rfq_items USING gin (required_specs);


--
-- Name: idx_rfq_message_attachments_msg; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_message_attachments_msg ON public.rfq_message_attachments USING btree (message_id);


--
-- Name: idx_rfq_messages_conv; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_messages_conv ON public.rfq_messages USING btree (conversation_id, created_at);


--
-- Name: idx_rfq_messages_rfq; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_messages_rfq ON public.rfq_messages USING btree (rfq_id, created_at);


--
-- Name: idx_rfq_messages_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_messages_status ON public.rfq_messages USING btree (status);


--
-- Name: idx_rfq_scoring_notes_rfq; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_scoring_notes_rfq ON public.rfq_scoring_notes USING btree (rfq_id);


--
-- Name: idx_rfq_sections_rfq; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_sections_rfq ON public.rfq_sections USING btree (rfq_id);


--
-- Name: idx_rfq_shortlists_rfq; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_shortlists_rfq ON public.rfq_shortlists USING btree (rfq_id);


--
-- Name: idx_rfq_template_attachments_template; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_template_attachments_template ON public.rfq_template_attachments USING btree (rfq_template_id, sort_order) WHERE (is_deleted = false);


--
-- Name: idx_rfq_template_sections_template; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_template_sections_template ON public.rfq_template_sections USING btree (rfq_template_id, sort_order) WHERE (is_deleted = false);


--
-- Name: idx_rfq_templates_org_name; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_rfq_templates_org_name ON public.rfq_templates USING btree (org_id, lower((name)::text)) WHERE (is_deleted = false);


--
-- Name: idx_sales_receipts_buyer_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_sales_receipts_buyer_id ON public.sales_receipts USING btree (buyer_id);


--
-- Name: idx_sales_receipts_case_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_sales_receipts_case_id ON public.sales_receipts USING btree (case_id);


--
-- Name: idx_sales_receipts_cashier_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_sales_receipts_cashier_id ON public.sales_receipts USING btree (cashier_id);


--
-- Name: idx_sales_receipts_invoice_id; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_sales_receipts_invoice_id ON public.sales_receipts USING btree (invoice_id);


--
-- Name: idx_sales_receipts_submission; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_sales_receipts_submission ON public.sales_receipts USING btree (taxcore_submission_id) WHERE (taxcore_submission_id IS NOT NULL);


--
-- Name: idx_taxcore_config_active; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_config_active ON public.taxcore_configurations USING btree (org_id, is_active);


--
-- Name: idx_taxcore_config_expiry; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_config_expiry ON public.taxcore_configurations USING btree (certificate_expires_at) WHERE (certificate_expires_at IS NOT NULL);


--
-- Name: idx_taxcore_queue_locked; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_queue_locked ON public.taxcore_queue USING btree (locked_by, locked_at) WHERE (status = 'processing'::text);


--
-- Name: idx_taxcore_queue_next_retry; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_queue_next_retry ON public.taxcore_queue USING btree (next_retry_at, priority) WHERE (status = 'queued'::text);


--
-- Name: idx_taxcore_queue_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_queue_org ON public.taxcore_queue USING btree (org_id, status);


--
-- Name: idx_taxcore_queue_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_queue_status ON public.taxcore_queue USING btree (status, priority, next_retry_at);


--
-- Name: idx_taxcore_queue_submission; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_queue_submission ON public.taxcore_queue USING btree (submission_id);


--
-- Name: idx_taxcore_submissions_created; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_submissions_created ON public.taxcore_submissions USING btree (created_at DESC);


--
-- Name: idx_taxcore_submissions_invoice; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_submissions_invoice ON public.taxcore_submissions USING btree (reference_id) WHERE (reference_table = 'invoices'::text);


--
-- Name: idx_taxcore_submissions_org; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_submissions_org ON public.taxcore_submissions USING btree (org_id, created_at DESC);


--
-- Name: idx_taxcore_submissions_pending; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_submissions_pending ON public.taxcore_submissions USING btree (status, created_at) WHERE (status = ANY (ARRAY['pending'::text, 'retrying'::text]));


--
-- Name: idx_taxcore_submissions_ref; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_submissions_ref ON public.taxcore_submissions USING btree (reference_table, reference_id);


--
-- Name: idx_taxcore_submissions_sales_receipt; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_submissions_sales_receipt ON public.taxcore_submissions USING btree (reference_id) WHERE (reference_table = 'sales_receipts'::text);


--
-- Name: idx_taxcore_submissions_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_taxcore_submissions_status ON public.taxcore_submissions USING btree (status, org_id);


--
-- Name: idx_vendor_addresses_vendor; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_vendor_addresses_vendor ON public.vendor_addresses USING btree (vendor_id, address_type) WHERE (isdeleted = false);


--
-- Name: idx_vendor_capabilities_vendor; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_vendor_capabilities_vendor ON public.vendor_capabilities USING btree (vendor_id) WHERE (isdeleted = false);


--
-- Name: idx_vendor_certificates_vendor; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_vendor_certificates_vendor ON public.vendor_certificates USING btree (vendor_id) WHERE (isdeleted = false);


--
-- Name: idx_vendor_contacts_vendor; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_vendor_contacts_vendor ON public.vendor_contacts USING btree (vendor_id) WHERE (isdeleted = false);


--
-- Name: idx_vendor_documents_vendor; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_vendor_documents_vendor ON public.vendor_documents USING btree (vendor_id) WHERE (isdeleted = false);


--
-- Name: idx_vendor_performance_vendor_period; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_vendor_performance_vendor_period ON public.vendor_performance_metrics USING btree (vendor_id, period_end DESC);


--
-- Name: idx_vendor_quote_items_quote; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_vendor_quote_items_quote ON public.vendor_quote_items USING btree (quote_id);


--
-- Name: idx_vendor_quotes_rfq_vendor; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_vendor_quotes_rfq_vendor ON public.vendor_quotes USING btree (rfq_id, vendor_id);


--
-- Name: idx_vendor_quotes_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_vendor_quotes_status ON public.vendor_quotes USING btree (rfq_id, status);


--
-- Name: idx_vendor_supporting_docs_vendor; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_vendor_supporting_docs_vendor ON public.vendor_supporting_docs USING btree (vendor_id) WHERE (isdeleted = false);


--
-- Name: idx_vendors_org_status; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_vendors_org_status ON public.vendors USING btree (org_id, lifecycle_status);


--
-- Name: idx_webhooks_created_at; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_webhooks_created_at ON public.payment_webhooks USING btree (created_at);


--
-- Name: idx_webhooks_processed; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_webhooks_processed ON public.payment_webhooks USING btree (processed);


--
-- Name: idx_webhooks_provider; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_webhooks_provider ON public.payment_webhooks USING btree (provider_name);


--
-- Name: idx_webhooks_transaction; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX idx_webhooks_transaction ON public.payment_webhooks USING btree (transaction_id);


--
-- Name: inspection_requests_workplace_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX inspection_requests_workplace_idx ON public.inspection_requests USING btree (workplace_id);


--
-- Name: kanban_boards_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_boards_branch_idx ON public.kanban_boards USING btree (branch_id);


--
-- Name: kanban_boards_cat_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_boards_cat_idx ON public.kanban_boards USING btree (calendar_category_id);


--
-- Name: kanban_boards_project_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_boards_project_idx ON public.kanban_boards USING btree (project_id);


--
-- Name: kanban_boards_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_boards_tenant_idx ON public.kanban_boards USING btree (tenant_id);


--
-- Name: kanban_columns_board_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_columns_board_idx ON public.kanban_columns USING btree (board_id);


--
-- Name: kanban_columns_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_columns_branch_idx ON public.kanban_columns USING btree (branch_id);


--
-- Name: kanban_columns_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_columns_tenant_idx ON public.kanban_columns USING btree (tenant_id);


--
-- Name: kanban_comments_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_comments_branch_idx ON public.kanban_comments USING btree (branch_id);


--
-- Name: kanban_comments_task_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_comments_task_idx ON public.kanban_comments USING btree (task_id);


--
-- Name: kanban_comments_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_comments_tenant_idx ON public.kanban_comments USING btree (tenant_id);


--
-- Name: kanban_tasks_assignee_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_tasks_assignee_idx ON public.kanban_tasks USING btree (assignee_id);


--
-- Name: kanban_tasks_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_tasks_branch_idx ON public.kanban_tasks USING btree (branch_id);


--
-- Name: kanban_tasks_column_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_tasks_column_idx ON public.kanban_tasks USING btree (column_id);


--
-- Name: kanban_tasks_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX kanban_tasks_tenant_idx ON public.kanban_tasks USING btree (tenant_id);


--
-- Name: legacy_resources_name_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE UNIQUE INDEX legacy_resources_name_idx ON public.legacy_resources USING btree (name);


--
-- Name: meeting_links_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX meeting_links_branch_idx ON public.meeting_links USING btree (branch_id);


--
-- Name: meeting_links_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX meeting_links_tenant_idx ON public.meeting_links USING btree (tenant_id);


--
-- Name: ohs_action_signoffs_item_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_action_signoffs_item_idx ON public.ohs_action_signoffs USING btree (item_id);


--
-- Name: ohs_fault_trees_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_fault_trees_branch_idx ON public.ohs_fault_trees USING btree (branch_id);


--
-- Name: ohs_fault_trees_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_fault_trees_tenant_idx ON public.ohs_fault_trees USING btree (tenant_id);


--
-- Name: ohs_incident_logs_incident_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_incident_logs_incident_idx ON public.ohs_incident_logs USING btree (incident_id);


--
-- Name: ohs_incident_signoffs_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_incident_signoffs_idx ON public.ohs_incident_signoffs USING btree (incident_id);


--
-- Name: ohs_issues_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_issues_branch_idx ON public.ohs_issues USING btree (branch_id);


--
-- Name: ohs_issues_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_issues_tenant_idx ON public.ohs_issues USING btree (tenant_id);


--
-- Name: ohs_jsa_reviewers_jsa_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_jsa_reviewers_jsa_idx ON public.ohs_jsa_reviewers USING btree (jsa_id);


--
-- Name: ohs_jsa_signoffs_jsa_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_jsa_signoffs_jsa_idx ON public.ohs_jsa_signoffs USING btree (jsa_id);


--
-- Name: ohs_jsa_step_files_step_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_jsa_step_files_step_idx ON public.ohs_jsa_step_files USING btree (jsa_step_id);


--
-- Name: ohs_jsa_steps_jsa_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_jsa_steps_jsa_idx ON public.ohs_jsa_steps USING btree (jsa_id);


--
-- Name: ohs_jsa_training_jsa_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_jsa_training_jsa_idx ON public.ohs_jsa_training USING btree (jsa_id);


--
-- Name: ohs_jsa_versions_jsa_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_jsa_versions_jsa_idx ON public.ohs_jsa_versions USING btree (jsa_id);


--
-- Name: ohs_stakeholders_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_stakeholders_branch_idx ON public.ohs_stakeholders USING btree (branch_id);


--
-- Name: ohs_stakeholders_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_stakeholders_tenant_idx ON public.ohs_stakeholders USING btree (tenant_id);


--
-- Name: ohs_training_requirements_course_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_training_requirements_course_idx ON public.ohs_training_requirements USING btree (course_id);


--
-- Name: ohs_training_requirements_location_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_training_requirements_location_idx ON public.ohs_training_requirements USING btree (location_id);


--
-- Name: ohs_training_requirements_project_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_training_requirements_project_idx ON public.ohs_training_requirements USING btree (project_id);


--
-- Name: ohs_training_requirements_role_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX ohs_training_requirements_role_idx ON public.ohs_training_requirements USING btree (role_id);


--
-- Name: one_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX one_branch_idx ON public.ohs_needs_expectations USING btree (branch_id);


--
-- Name: one_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX one_tenant_idx ON public.ohs_needs_expectations USING btree (tenant_id);


--
-- Name: orgs_by_parent; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX orgs_by_parent ON public.orgs USING btree (parent_org_id);


--
-- Name: orgs_by_root; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX orgs_by_root ON public.orgs USING btree (root_org_id);


--
-- Name: orgs_path_gist; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX orgs_path_gist ON public.orgs USING gist (path);


--
-- Name: page_configs_page_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX page_configs_page_idx ON public.page_configs USING btree (page);


--
-- Name: permissions_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permissions_branch_idx ON public.permissions USING btree (branch_id);


--
-- Name: permissions_department_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permissions_department_idx ON public.permissions USING btree (department_id);


--
-- Name: permissions_district_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permissions_district_idx ON public.permissions USING btree (district_id);


--
-- Name: permissions_resource_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permissions_resource_idx ON public.permissions USING btree (resource_id);


--
-- Name: permissions_resource_type_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permissions_resource_type_idx ON public.permissions USING btree (resource_type_id);


--
-- Name: permissions_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permissions_tenant_idx ON public.permissions USING btree (tenant_id);


--
-- Name: permit_documents_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permit_documents_branch_idx ON public.permit_documents USING btree (branch_id);


--
-- Name: permit_documents_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permit_documents_tenant_idx ON public.permit_documents USING btree (tenant_id);


--
-- Name: permit_inspections_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permit_inspections_branch_idx ON public.permit_inspections USING btree (branch_id);


--
-- Name: permit_inspections_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permit_inspections_tenant_idx ON public.permit_inspections USING btree (tenant_id);


--
-- Name: permit_signatures_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permit_signatures_branch_idx ON public.permit_signatures USING btree (branch_id);


--
-- Name: permit_signatures_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX permit_signatures_tenant_idx ON public.permit_signatures USING btree (tenant_id);


--
-- Name: projects_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX projects_branch_idx ON public.projects USING btree (branch_id);


--
-- Name: projects_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX projects_tenant_idx ON public.projects USING btree (tenant_id);


--
-- Name: resources_type_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX resources_type_idx ON public.resources USING btree (resource_type_id);


--
-- Name: rfq_approval_instances_rfq_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX rfq_approval_instances_rfq_idx ON public.rfq_approval_instances USING btree (rfq_id);


--
-- Name: risk_assessment_files_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_files_branch_idx ON public.risk_assessment_files USING btree (branch_id);


--
-- Name: risk_assessment_files_ra_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_files_ra_idx ON public.risk_assessment_files USING btree (risk_assessment_id);


--
-- Name: risk_assessment_files_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_files_tenant_idx ON public.risk_assessment_files USING btree (tenant_id);


--
-- Name: risk_assessment_hazards_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_hazards_branch_idx ON public.risk_assessment_hazards USING btree (branch_id);


--
-- Name: risk_assessment_hazards_ra_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_hazards_ra_idx ON public.risk_assessment_hazards USING btree (risk_assessment_id);


--
-- Name: risk_assessment_hazards_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_hazards_tenant_idx ON public.risk_assessment_hazards USING btree (tenant_id);


--
-- Name: risk_assessment_ppe_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_ppe_branch_idx ON public.risk_assessment_ppe USING btree (branch_id);


--
-- Name: risk_assessment_ppe_ra_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_ppe_ra_idx ON public.risk_assessment_ppe USING btree (risk_assessment_id);


--
-- Name: risk_assessment_ppe_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_ppe_tenant_idx ON public.risk_assessment_ppe USING btree (tenant_id);


--
-- Name: risk_assessment_signoffs_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_signoffs_branch_idx ON public.risk_assessment_signoffs USING btree (branch_id);


--
-- Name: risk_assessment_signoffs_ra_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_signoffs_ra_idx ON public.risk_assessment_signoffs USING btree (risk_assessment_id);


--
-- Name: risk_assessment_signoffs_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_signoffs_tenant_idx ON public.risk_assessment_signoffs USING btree (tenant_id);


--
-- Name: risk_assessment_types_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_types_branch_idx ON public.risk_assessment_types USING btree (branch_id);


--
-- Name: risk_assessment_types_form_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_types_form_idx ON public.risk_assessment_types USING btree (form_id);


--
-- Name: risk_assessment_types_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessment_types_tenant_idx ON public.risk_assessment_types USING btree (tenant_id);


--
-- Name: risk_assessments_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessments_branch_idx ON public.risk_assessments USING btree (branch_id);


--
-- Name: risk_assessments_incident_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessments_incident_idx ON public.risk_assessments USING btree (incident_id);


--
-- Name: risk_assessments_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessments_tenant_idx ON public.risk_assessments USING btree (tenant_id);


--
-- Name: risk_assessments_type_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_assessments_type_idx ON public.risk_assessments USING btree (risk_assessment_type_id);


--
-- Name: risk_categories_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_categories_branch_idx ON public.risk_categories USING btree (branch_id);


--
-- Name: risk_categories_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_categories_tenant_idx ON public.risk_categories USING btree (tenant_id);


--
-- Name: risk_identifications_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_identifications_branch_idx ON public.risk_identifications USING btree (branch_id);


--
-- Name: risk_identifications_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX risk_identifications_tenant_idx ON public.risk_identifications USING btree (tenant_id);


--
-- Name: safety_alert_logs_alert_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX safety_alert_logs_alert_idx ON public.safety_alert_logs USING btree (alert_id);


--
-- Name: service_connections_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX service_connections_branch_idx ON public.service_connections USING btree (branch_id);


--
-- Name: service_connections_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX service_connections_tenant_idx ON public.service_connections USING btree (tenant_id);


--
-- Name: service_connections_user_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX service_connections_user_idx ON public.service_connections USING btree (user_id);


--
-- Name: service_types_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX service_types_branch_idx ON public.service_types USING btree (branch_id);


--
-- Name: service_types_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX service_types_tenant_idx ON public.service_types USING btree (tenant_id);


--
-- Name: tcs_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX tcs_branch_idx ON public.table_column_settings USING btree (branch_id);


--
-- Name: tcs_table_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX tcs_table_idx ON public.table_column_settings USING btree (table_name);


--
-- Name: tcs_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX tcs_tenant_idx ON public.table_column_settings USING btree (tenant_id);


--
-- Name: tcs_user_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX tcs_user_idx ON public.table_column_settings USING btree (user_id);


--
-- Name: tenant_tables_name_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX tenant_tables_name_idx ON public.tenant_tables USING btree (table_name);


--
-- Name: tenant_tables_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX tenant_tables_tenant_idx ON public.tenant_tables USING btree (tenant_id);


--
-- Name: tenant_tables_user_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX tenant_tables_user_idx ON public.tenant_tables USING btree (user_id);


--
-- Name: training_paths_country_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX training_paths_country_idx ON public.training_paths USING btree (country_id);


--
-- Name: training_paths_department_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX training_paths_department_idx ON public.training_paths USING btree (department_id);


--
-- Name: training_paths_role_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX training_paths_role_idx ON public.training_paths USING btree (role_id);


--
-- Name: training_paths_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX training_paths_tenant_idx ON public.training_paths USING btree (tenant_id);


--
-- Name: uq_pos_settings_org_branch; Type: INDEX; Schema: public; Owner: taf
--

CREATE UNIQUE INDEX uq_pos_settings_org_branch ON public.pos_settings USING btree (org_id, branch_id) WHERE (isdeleted = false);


--
-- Name: uq_rfq_invite_unique; Type: INDEX; Schema: public; Owner: taf
--

CREATE UNIQUE INDEX uq_rfq_invite_unique ON public.rfq_invites USING btree (rfq_id, vendor_id);


--
-- Name: uq_rfq_org_number; Type: INDEX; Schema: public; Owner: taf
--

CREATE UNIQUE INDEX uq_rfq_org_number ON public.rfq_headers USING btree (org_id, rfq_number) WHERE (rfq_number IS NOT NULL);


--
-- Name: user_board_settings_board_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX user_board_settings_board_idx ON public.user_board_settings USING btree (board_id);


--
-- Name: user_board_settings_user_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX user_board_settings_user_idx ON public.user_board_settings USING btree (user_id);


--
-- Name: user_emails_one_primary; Type: INDEX; Schema: public; Owner: taf
--

CREATE UNIQUE INDEX user_emails_one_primary ON public.user_emails USING btree (user_id) WHERE is_primary;


--
-- Name: user_emails_verified_unique; Type: INDEX; Schema: public; Owner: taf
--

CREATE UNIQUE INDEX user_emails_verified_unique ON public.user_emails USING btree (email) WHERE (verified_at IS NOT NULL);


--
-- Name: user_phones_one_primary; Type: INDEX; Schema: public; Owner: taf
--

CREATE UNIQUE INDEX user_phones_one_primary ON public.user_phones USING btree (user_id) WHERE is_primary;


--
-- Name: user_phones_verified_unique; Type: INDEX; Schema: public; Owner: taf
--

CREATE UNIQUE INDEX user_phones_verified_unique ON public.user_phones USING btree (phone_number) WHERE (verified_at IS NOT NULL);


--
-- Name: vehicle_makes_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_makes_branch_idx ON public.vehicle_makes USING btree (branch_id);


--
-- Name: vehicle_makes_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_makes_tenant_idx ON public.vehicle_makes USING btree (tenant_id);


--
-- Name: vehicle_models_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_models_branch_idx ON public.vehicle_models USING btree (branch_id);


--
-- Name: vehicle_models_make_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_models_make_idx ON public.vehicle_models USING btree (make_id);


--
-- Name: vehicle_models_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_models_tenant_idx ON public.vehicle_models USING btree (tenant_id);


--
-- Name: vehicle_report_comments_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_report_comments_branch_idx ON public.vehicle_report_comments USING btree (branch_id);


--
-- Name: vehicle_report_comments_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_report_comments_tenant_idx ON public.vehicle_report_comments USING btree (tenant_id);


--
-- Name: vehicle_report_parts_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_report_parts_branch_idx ON public.vehicle_report_parts USING btree (branch_id);


--
-- Name: vehicle_report_parts_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_report_parts_tenant_idx ON public.vehicle_report_parts USING btree (tenant_id);


--
-- Name: vehicle_reports_assigned_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_reports_assigned_idx ON public.vehicle_reports USING btree (assigned_to);


--
-- Name: vehicle_reports_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_reports_tenant_idx ON public.vehicle_reports USING btree (tenant_id);


--
-- Name: vehicle_reports_updated_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_reports_updated_idx ON public.vehicle_reports USING btree (updatedat);


--
-- Name: vehicle_reports_vehicle_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_reports_vehicle_idx ON public.vehicle_reports USING btree (vehicle_id);


--
-- Name: vehicle_services_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_services_branch_idx ON public.vehicle_services USING btree (branch_id);


--
-- Name: vehicle_services_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_services_tenant_idx ON public.vehicle_services USING btree (tenant_id);


--
-- Name: vehicle_trip_points_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_trip_points_branch_idx ON public.vehicle_trip_points USING btree (branch_id);


--
-- Name: vehicle_trip_points_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_trip_points_tenant_idx ON public.vehicle_trip_points USING btree (tenant_id);


--
-- Name: vehicle_trip_points_trip_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_trip_points_trip_idx ON public.vehicle_trip_points USING btree (trip_id);


--
-- Name: vehicle_trips_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_trips_branch_idx ON public.vehicle_trips USING btree (branch_id);


--
-- Name: vehicle_trips_driver_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_trips_driver_idx ON public.vehicle_trips USING btree (driver_id);


--
-- Name: vehicle_trips_status_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_trips_status_idx ON public.vehicle_trips USING btree (status);


--
-- Name: vehicle_trips_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_trips_tenant_idx ON public.vehicle_trips USING btree (tenant_id);


--
-- Name: vehicle_types_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_types_branch_idx ON public.vehicle_types USING btree (branch_id);


--
-- Name: vehicle_types_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicle_types_tenant_idx ON public.vehicle_types USING btree (tenant_id);


--
-- Name: vehicles_branch_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicles_branch_idx ON public.vehicles USING btree (branch_id);


--
-- Name: vehicles_tenant_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX vehicles_tenant_idx ON public.vehicles USING btree (tenant_id);


--
-- Name: workcom_inspections_request_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX workcom_inspections_request_idx ON public.workcom_inspections USING btree (inspection_request_id);


--
-- Name: workcom_inspections_workplace_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX workcom_inspections_workplace_idx ON public.workcom_inspections USING btree (workplace_id);


--
-- Name: workflow_event_triggers_event_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX workflow_event_triggers_event_idx ON public.workflow_event_triggers USING btree (event_name);


--
-- Name: workflow_event_triggers_form_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX workflow_event_triggers_form_idx ON public.workflow_event_triggers USING btree (form_id);


--
-- Name: workflow_event_triggers_table_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX workflow_event_triggers_table_idx ON public.workflow_event_triggers USING btree (table_name);


--
-- Name: workflow_triggers_event_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX workflow_triggers_event_idx ON public.workflow_triggers USING btree (event_name);


--
-- Name: workflow_triggers_wf_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX workflow_triggers_wf_idx ON public.workflow_triggers USING btree (workflow_id);


--
-- Name: workplace_registrations_email_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX workplace_registrations_email_idx ON public.workplace_registrations USING btree (contact_email);


--
-- Name: workplace_registrations_invoice_id_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX workplace_registrations_invoice_id_idx ON public.workplace_registrations USING btree (invoice_id);


--
-- Name: workplace_registrations_reviewer_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX workplace_registrations_reviewer_idx ON public.workplace_registrations USING btree (assigned_reviewer_id);


--
-- Name: workplace_registrations_status_idx; Type: INDEX; Schema: public; Owner: taf
--

CREATE INDEX workplace_registrations_status_idx ON public.workplace_registrations USING btree (status);


--
-- Name: notification_queue notification_notify; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER notification_notify AFTER INSERT ON public.notification_queue FOR EACH ROW EXECUTE FUNCTION public.notify_notification_queue();


--
-- Name: orgs trg_orgs_root_path; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_orgs_root_path BEFORE INSERT OR UPDATE OF parent_org_id ON public.orgs FOR EACH ROW EXECUTE FUNCTION public.orgs_set_root_path();


--
-- Name: quotations trg_set_quotation_expiry; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_quotation_expiry BEFORE INSERT OR UPDATE ON public.quotations FOR EACH ROW EXECUTE FUNCTION public.set_quotation_expiry();


--
-- Name: time_entries trg_set_time_entry_rate; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_time_entry_rate BEFORE INSERT ON public.time_entries FOR EACH ROW EXECUTE FUNCTION public.set_time_entry_rate();


--
-- Name: account_ai_feedback trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.account_ai_feedback FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: appeals trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.appeals FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: applications trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.applications FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: appraisal_templates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.appraisal_templates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: attendance trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.attendance FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: audit_logs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.audit_logs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: auto_orders trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.auto_orders FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: bank_detail_changes trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.bank_detail_changes FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: branches trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.branches FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: budgets trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.budgets FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: calendar_accounts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.calendar_accounts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: calendar_availability trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.calendar_availability FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: calendar_categories trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.calendar_categories FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: calendar_event_documents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.calendar_event_documents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: calendar_event_permissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.calendar_event_permissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: calendar_events trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.calendar_events FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: career_paths trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.career_paths FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: career_steps trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.career_steps FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: case_evidence trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.case_evidence FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: case_instructions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.case_instructions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: case_notes trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.case_notes FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: case_participants trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.case_participants FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: case_tasks trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.case_tasks FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: cases trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.cases FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: cash_sessions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.cash_sessions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: certificate_templates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.certificate_templates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: check_ins trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.check_ins FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: clients trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.clients FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: companies trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.companies FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: competencies trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.competencies FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: competency_assessments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.competency_assessments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: contract_approvals trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.contract_approvals FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: contract_versions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.contract_versions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: contracts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.contracts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: corrective_actions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.corrective_actions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: countries trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.countries FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: country_holidays trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.country_holidays FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: custom_field_values trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.custom_field_values FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: custom_fields trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.custom_fields FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: customer_history trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.customer_history FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: customer_reminder_preferences trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.customer_reminder_preferences FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: customer_settings trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.customer_settings FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: customers trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.customers FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: dashboard_card_permissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.dashboard_card_permissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: deduction_rates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.deduction_rates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: deduction_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.deduction_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: demo_graph_data trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.demo_graph_data FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: departments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.departments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: detail_view_elements trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.detail_view_elements FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: detail_views trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.detail_views FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: disciplinary_actions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.disciplinary_actions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: disciplinary_cases trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.disciplinary_cases FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: discount_rules trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.discount_rules FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: dispatch_lines trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.dispatch_lines FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: dispatch_notes trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.dispatch_notes FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: districts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.districts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: document_categories trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.document_categories FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: document_comments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.document_comments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: document_folders trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.document_folders FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: document_metadata trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.document_metadata FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: document_permissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.document_permissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: document_tags trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.document_tags FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: document_versions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.document_versions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: documents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.documents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: element_options trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.element_options FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: element_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.element_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employee_authorized_locations trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employee_authorized_locations FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employee_certificates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employee_certificates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employee_competencies trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employee_competencies FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employee_custom_fields trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employee_custom_fields FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employee_custom_values trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employee_custom_values FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employee_documents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employee_documents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employee_exits trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employee_exits FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employee_items trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employee_items FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employee_shifts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employee_shifts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employee_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employee_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employees2locations trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employees2locations FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: employees2users trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.employees2users FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: event_categories trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.event_categories FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: exit_approvals trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.exit_approvals FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: exit_clearances trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.exit_clearances FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: exit_feedback trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.exit_feedback FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: exit_interviews trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.exit_interviews FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: expense_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.expense_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: expenses trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.expenses FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: feedback_notes trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.feedback_notes FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: feedback_requests trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.feedback_requests FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: field_definitions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.field_definitions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: final_settlements trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.final_settlements FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: fishbone_diagrams trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.fishbone_diagrams FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: form_buttons trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.form_buttons FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: form_categories trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.form_categories FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: form_certificates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.form_certificates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: form_definitions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.form_definitions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: form_submission_reviews trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.form_submission_reviews FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: form_submission_values trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.form_submission_values FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: form_submissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.form_submissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: form_wizard_steps trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.form_wizard_steps FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: form_wizards trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.form_wizards FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: forms trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.forms FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: goal_alignment trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.goal_alignment FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: goal_documents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.goal_documents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: goal_milestones trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.goal_milestones FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: goal_score_labels trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.goal_score_labels FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: goal_templates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.goal_templates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: goods_receipt_lines trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.goods_receipt_lines FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: goods_receipts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.goods_receipts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: graphs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.graphs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: group_column_permissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.group_column_permissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: group_module_permissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.group_module_permissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: group_table_permissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.group_table_permissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: groups trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.groups FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: import_export_configs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.import_export_configs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: incident_alert_rules trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.incident_alert_rules FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ingredients trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ingredients FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ingredients_to_products trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ingredients_to_products FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: inspection_assignment_rules trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.inspection_assignment_rules FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: inspection_requests trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.inspection_requests FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: interview_logs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.interview_logs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: interviewers trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.interviewers FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: interviews trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.interviews FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: inventory trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.inventory FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: inventory_breaks trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.inventory_breaks FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: inventory_receive trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.inventory_receive FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: inventory_txn trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.inventory_txn FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: invoice_payments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.invoice_payments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: invoice_settings trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.invoice_settings FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: invoice_templates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.invoice_templates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: invoice_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.invoice_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: invoices trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.invoices FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: items trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.items FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: job_opening_templates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.job_opening_templates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: kanban_boards trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.kanban_boards FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: kanban_columns trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.kanban_columns FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: kanban_comments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.kanban_comments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: kanban_tasks trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.kanban_tasks FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: leave_requests trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.leave_requests FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: leave_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.leave_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: legacy_resources trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.legacy_resources FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: line_items trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.line_items FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: lineitems_payments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.lineitems_payments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: locations trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.locations FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: meeting_links trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.meeting_links FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: models trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.models FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: modules trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.modules FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: notification_log trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.notification_log FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: notification_queue trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.notification_queue FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_action_signoffs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_action_signoffs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_actions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_actions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_assignment_rules trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_assignment_rules FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_compliance_logs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_compliance_logs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_compliance_tasks trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_compliance_tasks FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_emergency_contacts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_emergency_contacts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_emergency_drills trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_emergency_drills FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_fault_trees trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_fault_trees FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_field_incidents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_field_incidents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_five_whys trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_five_whys FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_hazard_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_hazard_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_hazards trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_hazards FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_health_checks trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_health_checks FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_incident_custom_fields trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_incident_custom_fields FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_incident_files trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_incident_files FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_incident_logs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_incident_logs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_incident_signoffs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_incident_signoffs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_incident_statuses trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_incident_statuses FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_incident_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_incident_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_incidents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_incidents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_inspection_audits trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_inspection_audits FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_inspection_items trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_inspection_items FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_inspection_templates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_inspection_templates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_inspection_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_inspection_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_inspections trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_inspections FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_issues trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_issues FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_jsa_reviewers trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_jsa_reviewers FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_jsa_signoffs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_jsa_signoffs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_jsa_step_files trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_jsa_step_files FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_jsa_steps trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_jsa_steps FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_jsa_training trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_jsa_training FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_jsa_versions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_jsa_versions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_jsas trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_jsas FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_medicals trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_medicals FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_needs_expectations trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_needs_expectations FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_regulations trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_regulations FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_risk_matrices trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_risk_matrices FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_risk_reviews trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_risk_reviews FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_root_causes trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_root_causes FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_severities trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_severities FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_stakeholders trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_stakeholders FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ohs_training_requirements trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ohs_training_requirements FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: one_time_service_costs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.one_time_service_costs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: open_positions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.open_positions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: orgs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.orgs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: overtime_rules trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.overtime_rules FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: page_configs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.page_configs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: payment_items trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.payment_items FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: payment_reminder_config trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.payment_reminder_config FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: payment_reminders trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.payment_reminders FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: payment_request trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.payment_request FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: payment_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.payment_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: payments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.payments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: payroll_anomalies trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.payroll_anomalies FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: payslip_deductions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.payslip_deductions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: payslips trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.payslips FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: performance_goals trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.performance_goals FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: performance_reviews trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.performance_reviews FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: permissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.permissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: permit_applications trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.permit_applications FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: permit_documents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.permit_documents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: permit_inspections trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.permit_inspections FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: permit_signatures trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.permit_signatures FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: permit_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.permit_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: policies trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.policies FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: policy_acknowledgments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.policy_acknowledgments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: policy_approvals trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.policy_approvals FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: policy_targets trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.policy_targets FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: policy_templates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.policy_templates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: pos_settings trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.pos_settings FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: procurement_requests trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.procurement_requests FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: procurements trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.procurements FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: product_batch_number trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.product_batch_number FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: product_categories trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.product_categories FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: product_daily_rec trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.product_daily_rec FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: product_discounts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.product_discounts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: products trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.products FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: products_2_categories trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.products_2_categories FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: products_2_taxcodes trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.products_2_taxcodes FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: products_to_vendors trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.products_to_vendors FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: program_default_group_permissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.program_default_group_permissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: program_default_groups trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.program_default_groups FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: program_enrollments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.program_enrollments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: program_modules trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.program_modules FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: programs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.programs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: projects trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.projects FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: properties trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.properties FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: property_rates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.property_rates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: purchase_order_lines trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.purchase_order_lines FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: purchase_orders trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.purchase_orders FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: push_subscriptions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.push_subscriptions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: quotations trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.quotations FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rate_invoices trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rate_invoices FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rate_payments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rate_payments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: ratepayers trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.ratepayers FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: receipts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.receipts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: reimbursement_claims trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.reimbursement_claims FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: resource_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.resource_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: resources trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.resources FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: review_calibrations trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.review_calibrations FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: review_cycles trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.review_cycles FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: review_documents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.review_documents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: review_schedules trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.review_schedules FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_approval_levels trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_approval_levels FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_attachments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_attachments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_contracts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_contracts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_conversations trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_conversations FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_headers trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_headers FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_invites trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_invites FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_items trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_items FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_message_attachments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_message_attachments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_messages trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_messages FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_scoring_notes trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_scoring_notes FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_sections trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_sections FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_shortlists trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_shortlists FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_template_attachments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_template_attachments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_template_sections trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_template_sections FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: rfq_templates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.rfq_templates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: risk_assessment_files trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.risk_assessment_files FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: risk_assessment_hazards trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.risk_assessment_hazards FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: risk_assessment_ppe trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.risk_assessment_ppe FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: risk_assessment_signoffs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.risk_assessment_signoffs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: risk_assessment_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.risk_assessment_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: risk_assessments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.risk_assessments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: risk_categories trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.risk_categories FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: risk_identifications trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.risk_identifications FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: role_competencies trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.role_competencies FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: safety_alert_files trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.safety_alert_files FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: safety_alert_logs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.safety_alert_logs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: safety_alerts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.safety_alerts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: safety_document_versions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.safety_document_versions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: safety_documents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.safety_documents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: safety_field_incidents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.safety_field_incidents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: safety_incident_files trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.safety_incident_files FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: safety_incident_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.safety_incident_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: safety_incidents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.safety_incidents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: salaries trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.salaries FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: sales_receipts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.sales_receipts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: sales_tax_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.sales_tax_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: scheduled_reports trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.scheduled_reports FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: service_connections trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.service_connections FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: service_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.service_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: settings trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.settings FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: shift_swaps trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.shift_swaps FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: shifts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.shifts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: software_info trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.software_info FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: storage_connectors trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.storage_connectors FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: supervisor_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.supervisor_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: table_column_settings trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.table_column_settings FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: table_views trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.table_views FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: tasks trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.tasks FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: tax_core_request trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.tax_core_request FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: tax_core_response trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.tax_core_response FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: tax_ledger trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.tax_ledger FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: taxcore_submissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.taxcore_submissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: tenant_admins trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.tenant_admins FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: tenant_module_settings trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.tenant_module_settings FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: tenant_modules trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.tenant_modules FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: tenant_tables trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.tenant_tables FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: tenants trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.tenants FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: time_clock_aggregates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.time_clock_aggregates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: time_clocks trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.time_clocks FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: time_entries trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.time_entries FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: timesheets trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.timesheets FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_answers trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_answers FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_badges trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_badges FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_bookmarks trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_bookmarks FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_categories trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_categories FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_certificates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_certificates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_contents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_contents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_courses trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_courses FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_enrollments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_enrollments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_feedback trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_feedback FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_path_courses trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_path_courses FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_paths trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_paths FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_questions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_questions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_quizzes trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_quizzes FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_results trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_results FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: training_sessions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.training_sessions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_2fa trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_2fa FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_board_settings trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_board_settings FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_branch_memberships trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_branch_memberships FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_column_permissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_column_permissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_emails trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_emails FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_faces trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_faces FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_group_memberships trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_group_memberships FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_mfa_factors trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_mfa_factors FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_module_permissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_module_permissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_org_memberships trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_org_memberships FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_passkeys trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_passkeys FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_passwords trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_passwords FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_phones trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_phones FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_settings trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_settings FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_table_permissions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_table_permissions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: user_tokens trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.user_tokens FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: users trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.users FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: users_profiles trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.users_profiles FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vehicle_makes trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vehicle_makes FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vehicle_models trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vehicle_models FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vehicle_report_comments trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vehicle_report_comments FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vehicle_report_parts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vehicle_report_parts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vehicle_reports trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vehicle_reports FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vehicle_services trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vehicle_services FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vehicle_trip_points trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vehicle_trip_points FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vehicle_trips trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vehicle_trips FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vehicle_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vehicle_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vehicles trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vehicles FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_addresses trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_addresses FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_bank_accounts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_bank_accounts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_capabilities trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_capabilities FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_certificates trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_certificates FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_contacts trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_contacts FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_documents trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_documents FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_emails trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_emails FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_invoices trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_invoices FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_performance_metrics trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_performance_metrics FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_phone_numbers trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_phone_numbers FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_quotes trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_quotes FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendor_supporting_docs trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendor_supporting_docs FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: vendors trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.vendors FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: view_filters trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.view_filters FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: violation_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.violation_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: work_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.work_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workcom_inspection_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workcom_inspection_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workcom_inspections trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workcom_inspections FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workflow_approvals trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workflow_approvals FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workflow_event_triggers trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workflow_event_triggers FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workflow_instances trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workflow_instances FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workflow_states trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workflow_states FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workflow_step_types trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workflow_step_types FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workflow_steps trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workflow_steps FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workflow_tasks trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workflow_tasks FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workflow_transitions trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workflow_transitions FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workflow_triggers trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workflow_triggers FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workflows trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workflows FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: workplace_registrations trg_set_updatedat; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_set_updatedat BEFORE UPDATE ON public.workplace_registrations FOR EACH ROW EXECUTE FUNCTION public.set_updatedat();


--
-- Name: invoices trg_update_credit_on_invoice_change; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_update_credit_on_invoice_change AFTER INSERT OR DELETE OR UPDATE ON public.invoices FOR EACH ROW EXECUTE FUNCTION public.trigger_update_credit_on_invoice_change();


--
-- Name: quotations trg_update_credit_on_quotation_change; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_update_credit_on_quotation_change AFTER INSERT OR DELETE OR UPDATE ON public.quotations FOR EACH ROW EXECUTE FUNCTION public.trigger_update_credit_on_quotation_change();


--
-- Name: payments trg_update_customer_balance; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_update_customer_balance AFTER INSERT OR DELETE OR UPDATE ON public.payments FOR EACH ROW EXECUTE FUNCTION public.update_customer_balance();


--
-- Name: customer_credit_limits trg_update_customer_credit_limits_timestamp; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_update_customer_credit_limits_timestamp BEFORE UPDATE ON public.customer_credit_limits FOR EACH ROW EXECUTE FUNCTION public.trigger_update_customer_credit_limits_timestamp();


--
-- Name: payments trg_update_invoice_amount_paid; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_update_invoice_amount_paid AFTER INSERT OR DELETE OR UPDATE ON public.payments FOR EACH ROW EXECUTE FUNCTION public.update_invoice_amount_paid();


--
-- Name: goods_receipt_lines trg_update_po_line_qty; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_update_po_line_qty AFTER INSERT ON public.goods_receipt_lines FOR EACH ROW EXECUTE FUNCTION public.update_po_line_received_qty();


--
-- Name: goods_receipt_lines trg_update_po_status; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trg_update_po_status AFTER INSERT OR UPDATE ON public.goods_receipt_lines FOR EACH ROW EXECUTE FUNCTION public.update_po_status_on_receipt();


--
-- Name: program_enrollments trigger_create_default_program_groups; Type: TRIGGER; Schema: public; Owner: taf
--

CREATE TRIGGER trigger_create_default_program_groups AFTER INSERT OR UPDATE ON public.program_enrollments FOR EACH ROW EXECUTE FUNCTION public.create_default_program_groups();


--
-- Name: auto_orders auto_orders_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.auto_orders
    ADD CONSTRAINT auto_orders_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE CASCADE;


--
-- Name: branches branches_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.branches
    ADD CONSTRAINT branches_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: budgets budgets_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.budgets
    ADD CONSTRAINT budgets_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: case_instructions case_instructions_case_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.case_instructions
    ADD CONSTRAINT case_instructions_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.cases(case_id) ON DELETE CASCADE;


--
-- Name: case_instructions case_instructions_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.case_instructions
    ADD CONSTRAINT case_instructions_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(user_id);


--
-- Name: cases cases_client_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.cases
    ADD CONSTRAINT cases_client_id_fkey FOREIGN KEY (client_id) REFERENCES public.clients(client_id) ON DELETE CASCADE;


--
-- Name: cases cases_lead_rep_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.cases
    ADD CONSTRAINT cases_lead_rep_id_fkey FOREIGN KEY (lead_rep_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: cases cases_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.cases
    ADD CONSTRAINT cases_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: cases cases_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.cases
    ADD CONSTRAINT cases_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: clarification_requests clarification_requests_client_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.clarification_requests
    ADD CONSTRAINT clarification_requests_client_user_id_fkey FOREIGN KEY (client_user_id) REFERENCES public.users(user_id);


--
-- Name: clarification_requests clarification_requests_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.clarification_requests
    ADD CONSTRAINT clarification_requests_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: clarification_responses clarification_responses_clarification_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.clarification_responses
    ADD CONSTRAINT clarification_responses_clarification_id_fkey FOREIGN KEY (clarification_id) REFERENCES public.clarification_requests(clarification_id) ON DELETE CASCADE;


--
-- Name: clarification_responses clarification_responses_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.clarification_responses
    ADD CONSTRAINT clarification_responses_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id);


--
-- Name: client_payment_restrictions client_payment_restrictions_client_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.client_payment_restrictions
    ADD CONSTRAINT client_payment_restrictions_client_user_id_fkey FOREIGN KEY (client_user_id) REFERENCES public.users(user_id);


--
-- Name: client_payment_restrictions client_payment_restrictions_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.client_payment_restrictions
    ADD CONSTRAINT client_payment_restrictions_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: client_portal_tokens client_portal_tokens_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.client_portal_tokens
    ADD CONSTRAINT client_portal_tokens_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: client_portal_tokens client_portal_tokens_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.client_portal_tokens
    ADD CONSTRAINT client_portal_tokens_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id);


--
-- Name: clients clients_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.clients
    ADD CONSTRAINT clients_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: clients clients_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.clients
    ADD CONSTRAINT clients_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id);


--
-- Name: customer_reminder_preferences customer_reminder_preferences_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customer_reminder_preferences
    ADD CONSTRAINT customer_reminder_preferences_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: customers customers_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customers
    ADD CONSTRAINT customers_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: customers customers_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customers
    ADD CONSTRAINT customers_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id);


--
-- Name: deduction_rates deduction_rates_deduction_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.deduction_rates
    ADD CONSTRAINT deduction_rates_deduction_type_id_fkey FOREIGN KEY (deduction_type_id) REFERENCES public.deduction_types(deduction_type_id);


--
-- Name: deduction_types deduction_types_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.deduction_types
    ADD CONSTRAINT deduction_types_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: departments departments_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.departments
    ADD CONSTRAINT departments_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.orgs(org_id);


--
-- Name: discount_rules discount_rules_category_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.discount_rules
    ADD CONSTRAINT discount_rules_category_id_fkey FOREIGN KEY (category_id) REFERENCES public.product_categories(category_id) ON DELETE SET NULL;


--
-- Name: discount_rules discount_rules_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.discount_rules
    ADD CONSTRAINT discount_rules_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: discount_rules discount_rules_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.discount_rules
    ADD CONSTRAINT discount_rules_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE SET NULL;


--
-- Name: dispatch_lines dispatch_lines_dispatch_note_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.dispatch_lines
    ADD CONSTRAINT dispatch_lines_dispatch_note_id_fkey FOREIGN KEY (dispatch_note_id) REFERENCES public.dispatch_notes(dispatch_note_id) ON DELETE CASCADE;


--
-- Name: dispatch_lines dispatch_lines_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.dispatch_lines
    ADD CONSTRAINT dispatch_lines_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: dispatch_lines dispatch_lines_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.dispatch_lines
    ADD CONSTRAINT dispatch_lines_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE RESTRICT;


--
-- Name: dispatch_notes dispatch_notes_dispatched_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.dispatch_notes
    ADD CONSTRAINT dispatch_notes_dispatched_by_fkey FOREIGN KEY (dispatched_by) REFERENCES public.users(user_id);


--
-- Name: dispatch_notes dispatch_notes_from_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.dispatch_notes
    ADD CONSTRAINT dispatch_notes_from_branch_id_fkey FOREIGN KEY (from_branch_id) REFERENCES public.branches(branch_id) ON DELETE RESTRICT;


--
-- Name: dispatch_notes dispatch_notes_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.dispatch_notes
    ADD CONSTRAINT dispatch_notes_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: dispatch_notes dispatch_notes_received_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.dispatch_notes
    ADD CONSTRAINT dispatch_notes_received_by_fkey FOREIGN KEY (received_by) REFERENCES public.users(user_id);


--
-- Name: dispatch_notes dispatch_notes_to_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.dispatch_notes
    ADD CONSTRAINT dispatch_notes_to_branch_id_fkey FOREIGN KEY (to_branch_id) REFERENCES public.branches(branch_id) ON DELETE RESTRICT;


--
-- Name: document_metadata document_metadata_document_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.document_metadata
    ADD CONSTRAINT document_metadata_document_id_fkey FOREIGN KEY (document_id) REFERENCES public.documents(document_id) ON DELETE CASCADE;


--
-- Name: document_tags document_tags_parent_tag_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.document_tags
    ADD CONSTRAINT document_tags_parent_tag_id_fkey FOREIGN KEY (parent_tag_id) REFERENCES public.document_tags(document_tag_id) ON DELETE CASCADE;


--
-- Name: documents documents_parent_document_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.documents
    ADD CONSTRAINT documents_parent_document_id_fkey FOREIGN KEY (parent_document_id) REFERENCES public.documents(document_id) ON DELETE SET NULL;


--
-- Name: email_templates email_templates_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.email_templates
    ADD CONSTRAINT email_templates_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(user_id);


--
-- Name: email_templates email_templates_deleted_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.email_templates
    ADD CONSTRAINT email_templates_deleted_by_fkey FOREIGN KEY (deleted_by) REFERENCES public.users(user_id);


--
-- Name: email_templates email_templates_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.email_templates
    ADD CONSTRAINT email_templates_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: email_templates email_templates_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.email_templates
    ADD CONSTRAINT email_templates_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES public.users(user_id);


--
-- Name: expenses expenses_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.expenses
    ADD CONSTRAINT expenses_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id);


--
-- Name: credit_alerts fk_credit_alerts_credit_limit; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.credit_alerts
    ADD CONSTRAINT fk_credit_alerts_credit_limit FOREIGN KEY (credit_limit_id) REFERENCES public.customer_credit_limits(credit_limit_id);


--
-- Name: credit_alerts fk_credit_alerts_customer; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.credit_alerts
    ADD CONSTRAINT fk_credit_alerts_customer FOREIGN KEY (customer_id) REFERENCES public.customers(customer_id);


--
-- Name: credit_alerts fk_credit_alerts_org; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.credit_alerts
    ADD CONSTRAINT fk_credit_alerts_org FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: credit_approval_requests fk_credit_approval_requests_customer; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.credit_approval_requests
    ADD CONSTRAINT fk_credit_approval_requests_customer FOREIGN KEY (customer_id) REFERENCES public.customers(customer_id);


--
-- Name: credit_approval_requests fk_credit_approval_requests_org; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.credit_approval_requests
    ADD CONSTRAINT fk_credit_approval_requests_org FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: credit_limit_history fk_credit_limit_history_credit_limit; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.credit_limit_history
    ADD CONSTRAINT fk_credit_limit_history_credit_limit FOREIGN KEY (credit_limit_id) REFERENCES public.customer_credit_limits(credit_limit_id);


--
-- Name: credit_limit_history fk_credit_limit_history_customer; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.credit_limit_history
    ADD CONSTRAINT fk_credit_limit_history_customer FOREIGN KEY (customer_id) REFERENCES public.customers(customer_id);


--
-- Name: credit_limit_history fk_credit_limit_history_org; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.credit_limit_history
    ADD CONSTRAINT fk_credit_limit_history_org FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: customer_credit_limits fk_customer_credit_limits_customer; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customer_credit_limits
    ADD CONSTRAINT fk_customer_credit_limits_customer FOREIGN KEY (customer_id) REFERENCES public.customers(customer_id);


--
-- Name: customer_credit_limits fk_customer_credit_limits_org; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.customer_credit_limits
    ADD CONSTRAINT fk_customer_credit_limits_org FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: goods_receipt_lines goods_receipt_lines_goods_receipt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goods_receipt_lines
    ADD CONSTRAINT goods_receipt_lines_goods_receipt_id_fkey FOREIGN KEY (goods_receipt_id) REFERENCES public.goods_receipts(goods_receipt_id) ON DELETE CASCADE;


--
-- Name: goods_receipt_lines goods_receipt_lines_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goods_receipt_lines
    ADD CONSTRAINT goods_receipt_lines_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: goods_receipt_lines goods_receipt_lines_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goods_receipt_lines
    ADD CONSTRAINT goods_receipt_lines_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE RESTRICT;


--
-- Name: goods_receipt_lines goods_receipt_lines_purchase_order_line_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goods_receipt_lines
    ADD CONSTRAINT goods_receipt_lines_purchase_order_line_id_fkey FOREIGN KEY (purchase_order_line_id) REFERENCES public.purchase_order_lines(purchase_order_line_id) ON DELETE RESTRICT;


--
-- Name: goods_receipts goods_receipts_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goods_receipts
    ADD CONSTRAINT goods_receipts_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.branches(branch_id);


--
-- Name: goods_receipts goods_receipts_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goods_receipts
    ADD CONSTRAINT goods_receipts_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: goods_receipts goods_receipts_purchase_order_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goods_receipts
    ADD CONSTRAINT goods_receipts_purchase_order_id_fkey FOREIGN KEY (purchase_order_id) REFERENCES public.purchase_orders(purchase_order_id) ON DELETE CASCADE;


--
-- Name: goods_receipts goods_receipts_received_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.goods_receipts
    ADD CONSTRAINT goods_receipts_received_by_fkey FOREIGN KEY (received_by) REFERENCES public.users(user_id);


--
-- Name: group_column_permissions group_column_permissions_group_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.group_column_permissions
    ADD CONSTRAINT group_column_permissions_group_id_fkey FOREIGN KEY (group_id) REFERENCES public.groups(group_id) ON DELETE CASCADE;


--
-- Name: group_module_permissions group_module_permissions_group_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.group_module_permissions
    ADD CONSTRAINT group_module_permissions_group_id_fkey FOREIGN KEY (group_id) REFERENCES public.groups(group_id) ON DELETE CASCADE;


--
-- Name: group_module_permissions group_module_permissions_module_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.group_module_permissions
    ADD CONSTRAINT group_module_permissions_module_id_fkey FOREIGN KEY (module_id) REFERENCES public.modules(module_id) ON DELETE CASCADE;


--
-- Name: group_table_permissions group_table_permissions_group_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.group_table_permissions
    ADD CONSTRAINT group_table_permissions_group_id_fkey FOREIGN KEY (group_id) REFERENCES public.groups(group_id) ON DELETE CASCADE;


--
-- Name: groups groups_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.groups
    ADD CONSTRAINT groups_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: groups groups_parent_group_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.groups
    ADD CONSTRAINT groups_parent_group_id_fkey FOREIGN KEY (parent_group_id) REFERENCES public.groups(group_id);


--
-- Name: import_export_configs import_export_configs_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.import_export_configs
    ADD CONSTRAINT import_export_configs_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(user_id) ON DELETE SET NULL;


--
-- Name: import_export_configs import_export_configs_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.import_export_configs
    ADD CONSTRAINT import_export_configs_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: ingredients ingredients_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ingredients
    ADD CONSTRAINT ingredients_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: ingredients_to_products ingredients_to_products_ingredients_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ingredients_to_products
    ADD CONSTRAINT ingredients_to_products_ingredients_id_fkey FOREIGN KEY (ingredients_id) REFERENCES public.ingredients(ingredients_id) ON DELETE CASCADE;


--
-- Name: ingredients_to_products ingredients_to_products_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ingredients_to_products
    ADD CONSTRAINT ingredients_to_products_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: ingredients_to_products ingredients_to_products_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.ingredients_to_products
    ADD CONSTRAINT ingredients_to_products_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE CASCADE;


--
-- Name: interviewers interviewers_interview_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.interviewers
    ADD CONSTRAINT interviewers_interview_id_fkey FOREIGN KEY (interview_id) REFERENCES public.interviews(interview_id) ON DELETE CASCADE;


--
-- Name: interviewers interviewers_interviewer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.interviewers
    ADD CONSTRAINT interviewers_interviewer_id_fkey FOREIGN KEY (interviewer_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: interviews interviews_application_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.interviews
    ADD CONSTRAINT interviews_application_id_fkey FOREIGN KEY (application_id) REFERENCES public.applications(application_id) ON DELETE CASCADE;


--
-- Name: inventory_breaks inventory_breaks_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_breaks
    ADD CONSTRAINT inventory_breaks_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.branches(branch_id);


--
-- Name: inventory_breaks inventory_breaks_broken_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_breaks
    ADD CONSTRAINT inventory_breaks_broken_by_fkey FOREIGN KEY (broken_by) REFERENCES public.users(user_id);


--
-- Name: inventory_breaks inventory_breaks_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_breaks
    ADD CONSTRAINT inventory_breaks_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: inventory_breaks inventory_breaks_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_breaks
    ADD CONSTRAINT inventory_breaks_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE RESTRICT;


--
-- Name: inventory inventory_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory
    ADD CONSTRAINT inventory_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: inventory inventory_product_batch_number_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory
    ADD CONSTRAINT inventory_product_batch_number_id_fkey FOREIGN KEY (product_batch_number_id) REFERENCES public.product_batch_number(product_batch_number_id) ON DELETE CASCADE;


--
-- Name: inventory_receive inventory_receive_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_receive
    ADD CONSTRAINT inventory_receive_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.branches(branch_id) ON DELETE CASCADE;


--
-- Name: inventory_receive inventory_receive_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_receive
    ADD CONSTRAINT inventory_receive_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: inventory_receive inventory_receive_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_receive
    ADD CONSTRAINT inventory_receive_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: inventory_receive inventory_receive_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_receive
    ADD CONSTRAINT inventory_receive_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: inventory_txn inventory_txn_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_txn
    ADD CONSTRAINT inventory_txn_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: inventory_txn inventory_txn_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.inventory_txn
    ADD CONSTRAINT inventory_txn_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id);


--
-- Name: invitations invitations_inviter_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invitations
    ADD CONSTRAINT invitations_inviter_user_id_fkey FOREIGN KEY (inviter_user_id) REFERENCES public.users(user_id);


--
-- Name: invoice_types invoice_types_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoice_types
    ADD CONSTRAINT invoice_types_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: invoices invoices_advance_payment_for_invoice_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_advance_payment_for_invoice_id_fkey FOREIGN KEY (advance_payment_for_invoice_id) REFERENCES public.invoices(invoice_id);


--
-- Name: invoices invoices_customer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_customer_id_fkey FOREIGN KEY (customer_id) REFERENCES public.customers(customer_id);


--
-- Name: invoices invoices_invoice_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_invoice_template_id_fkey FOREIGN KEY (invoice_template_id) REFERENCES public.invoice_templates(invoice_template_id);


--
-- Name: invoices invoices_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: invoices invoices_refund_for_invoice_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_refund_for_invoice_id_fkey FOREIGN KEY (refund_for_invoice_id) REFERENCES public.invoices(invoice_id);


--
-- Name: invoices invoices_taxcore_submission_id_fk_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_taxcore_submission_id_fk_fkey FOREIGN KEY (taxcore_submission_id_fk) REFERENCES public.taxcore_submissions(submission_id);


--
-- Name: invoices invoices_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_type_id_fkey FOREIGN KEY (type_id) REFERENCES public.invoice_types(invoice_type_id);


--
-- Name: invoices invoices_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES public.users(user_id);


--
-- Name: items items_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.items
    ADD CONSTRAINT items_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: leave_balances leave_balances_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.leave_balances
    ADD CONSTRAINT leave_balances_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: leave_balances leave_balances_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.leave_balances
    ADD CONSTRAINT leave_balances_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: leave_requests leave_requests_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.leave_requests
    ADD CONSTRAINT leave_requests_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE SET NULL;


--
-- Name: leave_requests leave_requests_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.leave_requests
    ADD CONSTRAINT leave_requests_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE SET NULL;


--
-- Name: leave_types leave_types_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.leave_types
    ADD CONSTRAINT leave_types_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE SET NULL;


--
-- Name: lineitems_payments lineitems_payments_case_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.lineitems_payments
    ADD CONSTRAINT lineitems_payments_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.cases(case_id);


--
-- Name: modules modules_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.modules
    ADD CONSTRAINT modules_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: modules modules_parent_module_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.modules
    ADD CONSTRAINT modules_parent_module_id_fkey FOREIGN KEY (parent_module_id) REFERENCES public.modules(module_id);


--
-- Name: notification_queue notification_queue_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.notification_queue
    ADD CONSTRAINT notification_queue_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.orgs(org_id);


--
-- Name: notification_queue notification_queue_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.notification_queue
    ADD CONSTRAINT notification_queue_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.orgs(org_id);


--
-- Name: notification_queue notification_queue_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.notification_queue
    ADD CONSTRAINT notification_queue_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id);


--
-- Name: one_time_service_costs one_time_service_costs_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.one_time_service_costs
    ADD CONSTRAINT one_time_service_costs_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id);


--
-- Name: one_time_tokens one_time_tokens_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.one_time_tokens
    ADD CONSTRAINT one_time_tokens_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: orgs orgs_parent_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.orgs
    ADD CONSTRAINT orgs_parent_org_id_fkey FOREIGN KEY (parent_org_id) REFERENCES public.orgs(org_id);


--
-- Name: orgs orgs_root_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.orgs
    ADD CONSTRAINT orgs_root_org_id_fkey FOREIGN KEY (root_org_id) REFERENCES public.orgs(org_id);


--
-- Name: page_configs page_configs_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.page_configs
    ADD CONSTRAINT page_configs_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.orgs(org_id);


--
-- Name: page_configs page_configs_tenant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.page_configs
    ADD CONSTRAINT page_configs_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.orgs(org_id);


--
-- Name: payment_items payment_items_payment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_items
    ADD CONSTRAINT payment_items_payment_id_fkey FOREIGN KEY (payment_id) REFERENCES public.payments(payment_id) ON DELETE CASCADE;


--
-- Name: payment_providers payment_providers_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_providers
    ADD CONSTRAINT payment_providers_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: payment_reminder_config payment_reminder_config_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_reminder_config
    ADD CONSTRAINT payment_reminder_config_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: payment_reminders payment_reminders_invoice_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_reminders
    ADD CONSTRAINT payment_reminders_invoice_id_fkey FOREIGN KEY (invoice_id) REFERENCES public.invoices(invoice_id) ON DELETE CASCADE;


--
-- Name: payment_reminders payment_reminders_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_reminders
    ADD CONSTRAINT payment_reminders_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: payment_transactions payment_transactions_client_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_transactions
    ADD CONSTRAINT payment_transactions_client_user_id_fkey FOREIGN KEY (client_user_id) REFERENCES public.users(user_id);


--
-- Name: payment_transactions payment_transactions_invoice_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_transactions
    ADD CONSTRAINT payment_transactions_invoice_id_fkey FOREIGN KEY (invoice_id) REFERENCES public.invoices(invoice_id);


--
-- Name: payment_transactions payment_transactions_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_transactions
    ADD CONSTRAINT payment_transactions_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: payment_transactions payment_transactions_payment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_transactions
    ADD CONSTRAINT payment_transactions_payment_id_fkey FOREIGN KEY (payment_id) REFERENCES public.payments(payment_id);


--
-- Name: payment_transactions payment_transactions_provider_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_transactions
    ADD CONSTRAINT payment_transactions_provider_id_fkey FOREIGN KEY (provider_id) REFERENCES public.payment_providers(provider_id);


--
-- Name: payment_transactions payment_transactions_quotation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_transactions
    ADD CONSTRAINT payment_transactions_quotation_id_fkey FOREIGN KEY (quotation_id) REFERENCES public.quotations(quotation_id);


--
-- Name: payment_webhooks payment_webhooks_transaction_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payment_webhooks
    ADD CONSTRAINT payment_webhooks_transaction_id_fkey FOREIGN KEY (transaction_id) REFERENCES public.payment_transactions(transaction_id);


--
-- Name: payments payments_client_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payments
    ADD CONSTRAINT payments_client_id_fkey FOREIGN KEY (client_id) REFERENCES public.clients(client_id);


--
-- Name: payments payments_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payments
    ADD CONSTRAINT payments_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: payslip_deductions payslip_deductions_deduction_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payslip_deductions
    ADD CONSTRAINT payslip_deductions_deduction_type_id_fkey FOREIGN KEY (deduction_type_id) REFERENCES public.deduction_types(deduction_type_id);


--
-- Name: payslip_deductions payslip_deductions_payslip_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payslip_deductions
    ADD CONSTRAINT payslip_deductions_payslip_id_fkey FOREIGN KEY (payslip_id) REFERENCES public.payslips(payslip_id);


--
-- Name: payslips payslips_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payslips
    ADD CONSTRAINT payslips_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: payslips payslips_time_clock_aggregate_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payslips
    ADD CONSTRAINT payslips_time_clock_aggregate_id_fkey FOREIGN KEY (time_clock_aggregate_id) REFERENCES public.time_clock_aggregates(time_clock_aggregate_id);


--
-- Name: payslips payslips_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.payslips
    ADD CONSTRAINT payslips_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: procurement_requests procurement_requests_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.procurement_requests
    ADD CONSTRAINT procurement_requests_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: procurements procurements_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.procurements
    ADD CONSTRAINT procurements_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: product_batch_number product_batch_number_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.product_batch_number
    ADD CONSTRAINT product_batch_number_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE CASCADE;


--
-- Name: product_discounts product_discounts_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.product_discounts
    ADD CONSTRAINT product_discounts_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: product_discounts product_discounts_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.product_discounts
    ADD CONSTRAINT product_discounts_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE CASCADE;


--
-- Name: products_2_categories products_2_categories_category_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.products_2_categories
    ADD CONSTRAINT products_2_categories_category_id_fkey FOREIGN KEY (category_id) REFERENCES public.product_categories(category_id) ON DELETE CASCADE;


--
-- Name: products_2_categories products_2_categories_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.products_2_categories
    ADD CONSTRAINT products_2_categories_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE CASCADE;


--
-- Name: products_2_taxcodes products_2_taxcodes_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.products_2_taxcodes
    ADD CONSTRAINT products_2_taxcodes_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE CASCADE;


--
-- Name: products_2_taxcodes products_2_taxcodes_taxcode_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.products_2_taxcodes
    ADD CONSTRAINT products_2_taxcodes_taxcode_id_fkey FOREIGN KEY (taxcode_id) REFERENCES public.sales_tax_types(salestax_id) ON DELETE CASCADE;


--
-- Name: products products_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.products
    ADD CONSTRAINT products_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: products_to_vendors products_to_vendors_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.products_to_vendors
    ADD CONSTRAINT products_to_vendors_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE CASCADE;


--
-- Name: products_to_vendors products_to_vendors_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.products_to_vendors
    ADD CONSTRAINT products_to_vendors_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: program_default_group_permissions program_default_group_permissions_module_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_default_group_permissions
    ADD CONSTRAINT program_default_group_permissions_module_id_fkey FOREIGN KEY (module_id) REFERENCES public.modules(module_id);


--
-- Name: program_default_group_permissions program_default_group_permissions_program_default_group_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_default_group_permissions
    ADD CONSTRAINT program_default_group_permissions_program_default_group_id_fkey FOREIGN KEY (program_default_group_id) REFERENCES public.program_default_groups(program_default_group_id) ON DELETE CASCADE;


--
-- Name: program_default_groups program_default_groups_program_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_default_groups
    ADD CONSTRAINT program_default_groups_program_id_fkey FOREIGN KEY (program_id) REFERENCES public.programs(program_id) ON DELETE CASCADE;


--
-- Name: program_enrollments program_enrollments_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_enrollments
    ADD CONSTRAINT program_enrollments_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: program_enrollments program_enrollments_program_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_enrollments
    ADD CONSTRAINT program_enrollments_program_id_fkey FOREIGN KEY (program_id) REFERENCES public.programs(program_id) ON DELETE CASCADE;


--
-- Name: program_modules program_modules_module_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_modules
    ADD CONSTRAINT program_modules_module_id_fkey FOREIGN KEY (module_id) REFERENCES public.modules(module_id);


--
-- Name: program_modules program_modules_program_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.program_modules
    ADD CONSTRAINT program_modules_program_id_fkey FOREIGN KEY (program_id) REFERENCES public.programs(program_id) ON DELETE CASCADE;


--
-- Name: programs programs_owner_root_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.programs
    ADD CONSTRAINT programs_owner_root_org_id_fkey FOREIGN KEY (owner_root_org_id) REFERENCES public.orgs(org_id);


--
-- Name: purchase_order_lines purchase_order_lines_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_order_lines
    ADD CONSTRAINT purchase_order_lines_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: purchase_order_lines purchase_order_lines_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_order_lines
    ADD CONSTRAINT purchase_order_lines_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(product_id) ON DELETE RESTRICT;


--
-- Name: purchase_order_lines purchase_order_lines_purchase_order_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_order_lines
    ADD CONSTRAINT purchase_order_lines_purchase_order_id_fkey FOREIGN KEY (purchase_order_id) REFERENCES public.purchase_orders(purchase_order_id) ON DELETE CASCADE;


--
-- Name: purchase_orders purchase_orders_approved_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_orders
    ADD CONSTRAINT purchase_orders_approved_by_fkey FOREIGN KEY (approved_by) REFERENCES public.users(user_id);


--
-- Name: purchase_orders purchase_orders_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_orders
    ADD CONSTRAINT purchase_orders_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.branches(branch_id) ON DELETE SET NULL;


--
-- Name: purchase_orders purchase_orders_closed_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_orders
    ADD CONSTRAINT purchase_orders_closed_by_fkey FOREIGN KEY (closed_by) REFERENCES public.users(user_id);


--
-- Name: purchase_orders purchase_orders_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_orders
    ADD CONSTRAINT purchase_orders_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(user_id);


--
-- Name: purchase_orders purchase_orders_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_orders
    ADD CONSTRAINT purchase_orders_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: purchase_orders purchase_orders_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_orders
    ADD CONSTRAINT purchase_orders_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE SET NULL;


--
-- Name: purchase_orders purchase_orders_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.purchase_orders
    ADD CONSTRAINT purchase_orders_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: quotation_actions quotation_actions_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotation_actions
    ADD CONSTRAINT quotation_actions_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: quotation_actions quotation_actions_quotation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotation_actions
    ADD CONSTRAINT quotation_actions_quotation_id_fkey FOREIGN KEY (quotation_id) REFERENCES public.quotations(quotation_id) ON DELETE CASCADE;


--
-- Name: quotation_actions quotation_actions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotation_actions
    ADD CONSTRAINT quotation_actions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id);


--
-- Name: quotation_settings quotation_settings_logo_document_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotation_settings
    ADD CONSTRAINT quotation_settings_logo_document_id_fkey FOREIGN KEY (logo_document_id) REFERENCES public.documents(document_id);


--
-- Name: quotation_settings quotation_settings_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotation_settings
    ADD CONSTRAINT quotation_settings_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: quotation_settings quotation_settings_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotation_settings
    ADD CONSTRAINT quotation_settings_template_id_fkey FOREIGN KEY (template_id) REFERENCES public.invoice_templates(invoice_template_id);


--
-- Name: quotations quotations_client_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotations
    ADD CONSTRAINT quotations_client_id_fkey FOREIGN KEY (client_id) REFERENCES public.clients(client_id);


--
-- Name: quotations quotations_converted_invoice_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotations
    ADD CONSTRAINT quotations_converted_invoice_id_fkey FOREIGN KEY (converted_invoice_id) REFERENCES public.invoices(invoice_id);


--
-- Name: quotations quotations_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotations
    ADD CONSTRAINT quotations_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(user_id);


--
-- Name: quotations quotations_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotations
    ADD CONSTRAINT quotations_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: quotations quotations_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.quotations
    ADD CONSTRAINT quotations_template_id_fkey FOREIGN KEY (template_id) REFERENCES public.invoice_templates(invoice_template_id);


--
-- Name: refresh_tokens refresh_tokens_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.refresh_tokens
    ADD CONSTRAINT refresh_tokens_session_id_fkey FOREIGN KEY (session_id) REFERENCES public.sessions(session_id) ON DELETE CASCADE;


--
-- Name: resources resources_resource_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.resources
    ADD CONSTRAINT resources_resource_type_id_fkey FOREIGN KEY (resource_type_id) REFERENCES public.resource_types(id) ON DELETE CASCADE;


--
-- Name: rfq_approval_instances rfq_approval_instances_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_approval_instances
    ADD CONSTRAINT rfq_approval_instances_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_approval_levels rfq_approval_levels_approver_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_approval_levels
    ADD CONSTRAINT rfq_approval_levels_approver_user_id_fkey FOREIGN KEY (approver_user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: rfq_attachments rfq_attachments_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_attachments
    ADD CONSTRAINT rfq_attachments_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_awards rfq_awards_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_awards
    ADD CONSTRAINT rfq_awards_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_awards rfq_awards_rfq_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_awards
    ADD CONSTRAINT rfq_awards_rfq_item_id_fkey FOREIGN KEY (rfq_item_id) REFERENCES public.rfq_items(id) ON DELETE SET NULL;


--
-- Name: rfq_awards rfq_awards_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_awards
    ADD CONSTRAINT rfq_awards_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE RESTRICT;


--
-- Name: rfq_contracts rfq_contracts_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_contracts
    ADD CONSTRAINT rfq_contracts_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_contracts rfq_contracts_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_contracts
    ADD CONSTRAINT rfq_contracts_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE RESTRICT;


--
-- Name: rfq_conversations rfq_conversations_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_conversations
    ADD CONSTRAINT rfq_conversations_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_conversations rfq_conversations_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_conversations
    ADD CONSTRAINT rfq_conversations_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: rfq_events rfq_events_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_events
    ADD CONSTRAINT rfq_events_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_headers rfq_headers_tender_box_opened_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_headers
    ADD CONSTRAINT rfq_headers_tender_box_opened_by_fkey FOREIGN KEY (tender_box_opened_by) REFERENCES public.users(user_id);


--
-- Name: rfq_invites rfq_invites_contact_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_invites
    ADD CONSTRAINT rfq_invites_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES public.vendor_contacts(vendor_contact_id) ON DELETE SET NULL;


--
-- Name: rfq_invites rfq_invites_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_invites
    ADD CONSTRAINT rfq_invites_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_invites rfq_invites_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_invites
    ADD CONSTRAINT rfq_invites_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: rfq_invites rfq_invites_vendor_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_invites
    ADD CONSTRAINT rfq_invites_vendor_user_id_fkey FOREIGN KEY (vendor_user_id) REFERENCES public.users(user_id) ON DELETE SET NULL;


--
-- Name: rfq_items rfq_items_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_items
    ADD CONSTRAINT rfq_items_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_message_attachments rfq_message_attachments_message_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_message_attachments
    ADD CONSTRAINT rfq_message_attachments_message_id_fkey FOREIGN KEY (message_id) REFERENCES public.rfq_messages(message_id) ON DELETE CASCADE;


--
-- Name: rfq_messages rfq_messages_conversation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_messages
    ADD CONSTRAINT rfq_messages_conversation_id_fkey FOREIGN KEY (conversation_id) REFERENCES public.rfq_conversations(conversation_id) ON DELETE CASCADE;


--
-- Name: rfq_messages rfq_messages_origin_message_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_messages
    ADD CONSTRAINT rfq_messages_origin_message_id_fkey FOREIGN KEY (origin_message_id) REFERENCES public.rfq_messages(message_id) ON DELETE SET NULL;


--
-- Name: rfq_messages rfq_messages_parent_message_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_messages
    ADD CONSTRAINT rfq_messages_parent_message_id_fkey FOREIGN KEY (parent_message_id) REFERENCES public.rfq_messages(message_id) ON DELETE SET NULL;


--
-- Name: rfq_messages rfq_messages_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_messages
    ADD CONSTRAINT rfq_messages_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_messages rfq_messages_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_messages
    ADD CONSTRAINT rfq_messages_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE SET NULL;


--
-- Name: rfq_scoring_notes rfq_scoring_notes_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_scoring_notes
    ADD CONSTRAINT rfq_scoring_notes_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(user_id) ON DELETE SET NULL;


--
-- Name: rfq_scoring_notes rfq_scoring_notes_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_scoring_notes
    ADD CONSTRAINT rfq_scoring_notes_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_scoring_notes rfq_scoring_notes_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_scoring_notes
    ADD CONSTRAINT rfq_scoring_notes_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES public.users(user_id) ON DELETE SET NULL;


--
-- Name: rfq_scoring_notes rfq_scoring_notes_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_scoring_notes
    ADD CONSTRAINT rfq_scoring_notes_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: rfq_sections rfq_sections_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_sections
    ADD CONSTRAINT rfq_sections_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_shortlists rfq_shortlists_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_shortlists
    ADD CONSTRAINT rfq_shortlists_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(user_id) ON DELETE SET NULL;


--
-- Name: rfq_shortlists rfq_shortlists_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_shortlists
    ADD CONSTRAINT rfq_shortlists_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE SET NULL;


--
-- Name: rfq_shortlists rfq_shortlists_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_shortlists
    ADD CONSTRAINT rfq_shortlists_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: rfq_shortlists rfq_shortlists_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_shortlists
    ADD CONSTRAINT rfq_shortlists_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES public.users(user_id) ON DELETE SET NULL;


--
-- Name: rfq_shortlists rfq_shortlists_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_shortlists
    ADD CONSTRAINT rfq_shortlists_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: rfq_template_attachments rfq_template_attachments_rfq_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_template_attachments
    ADD CONSTRAINT rfq_template_attachments_rfq_template_id_fkey FOREIGN KEY (rfq_template_id) REFERENCES public.rfq_templates(rfq_template_id) ON DELETE CASCADE;


--
-- Name: rfq_template_sections rfq_template_sections_rfq_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_template_sections
    ADD CONSTRAINT rfq_template_sections_rfq_template_id_fkey FOREIGN KEY (rfq_template_id) REFERENCES public.rfq_templates(rfq_template_id) ON DELETE CASCADE;


--
-- Name: rfq_templates rfq_templates_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_templates
    ADD CONSTRAINT rfq_templates_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(user_id);


--
-- Name: rfq_templates rfq_templates_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfq_templates
    ADD CONSTRAINT rfq_templates_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: rfqs rfqs_procurement_request_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfqs
    ADD CONSTRAINT rfqs_procurement_request_id_fkey FOREIGN KEY (procurement_request_id) REFERENCES public.procurement_requests(procurement_request_id) ON DELETE CASCADE;


--
-- Name: rfqs rfqs_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.rfqs
    ADD CONSTRAINT rfqs_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: salaries salaries_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.salaries
    ADD CONSTRAINT salaries_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: salaries salaries_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.salaries
    ADD CONSTRAINT salaries_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: sales_receipts sales_receipts_case_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.sales_receipts
    ADD CONSTRAINT sales_receipts_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.cases(case_id);


--
-- Name: sales_receipts sales_receipts_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.sales_receipts
    ADD CONSTRAINT sales_receipts_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: sales_receipts sales_receipts_taxcore_submission_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.sales_receipts
    ADD CONSTRAINT sales_receipts_taxcore_submission_id_fkey FOREIGN KEY (taxcore_submission_id) REFERENCES public.taxcore_submissions(submission_id);


--
-- Name: sessions sessions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.sessions
    ADD CONSTRAINT sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: taxcore_configurations taxcore_configurations_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.taxcore_configurations
    ADD CONSTRAINT taxcore_configurations_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(user_id);


--
-- Name: taxcore_configurations taxcore_configurations_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.taxcore_configurations
    ADD CONSTRAINT taxcore_configurations_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: taxcore_queue taxcore_queue_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.taxcore_queue
    ADD CONSTRAINT taxcore_queue_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: taxcore_queue taxcore_queue_submission_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.taxcore_queue
    ADD CONSTRAINT taxcore_queue_submission_id_fkey FOREIGN KEY (submission_id) REFERENCES public.taxcore_submissions(submission_id) ON DELETE CASCADE;


--
-- Name: taxcore_submissions taxcore_submissions_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.taxcore_submissions
    ADD CONSTRAINT taxcore_submissions_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: taxcore_submissions taxcore_submissions_submitted_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.taxcore_submissions
    ADD CONSTRAINT taxcore_submissions_submitted_by_fkey FOREIGN KEY (submitted_by) REFERENCES public.users(user_id);


--
-- Name: tenant_idp_configs tenant_idp_configs_provider_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.tenant_idp_configs
    ADD CONSTRAINT tenant_idp_configs_provider_code_fkey FOREIGN KEY (provider_code) REFERENCES public.idp_providers(provider_code);


--
-- Name: time_clock_aggregates time_clock_aggregates_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.time_clock_aggregates
    ADD CONSTRAINT time_clock_aggregates_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: time_clock_aggregates time_clock_aggregates_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.time_clock_aggregates
    ADD CONSTRAINT time_clock_aggregates_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id);


--
-- Name: time_clocks time_clocks_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.time_clocks
    ADD CONSTRAINT time_clocks_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id);


--
-- Name: time_clocks time_clocks_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.time_clocks
    ADD CONSTRAINT time_clocks_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id);


--
-- Name: time_entries time_entries_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.time_entries
    ADD CONSTRAINT time_entries_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: time_entries time_entries_work_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.time_entries
    ADD CONSTRAINT time_entries_work_type_id_fkey FOREIGN KEY (work_type_id) REFERENCES public.work_types(work_type_id);


--
-- Name: user_branch_memberships user_branch_memberships_branch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_branch_memberships
    ADD CONSTRAINT user_branch_memberships_branch_id_fkey FOREIGN KEY (branch_id) REFERENCES public.branches(branch_id) ON DELETE CASCADE;


--
-- Name: user_branch_memberships user_branch_memberships_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_branch_memberships
    ADD CONSTRAINT user_branch_memberships_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_column_permissions user_column_permissions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_column_permissions
    ADD CONSTRAINT user_column_permissions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_emails user_emails_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_emails
    ADD CONSTRAINT user_emails_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_faces user_faces_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_faces
    ADD CONSTRAINT user_faces_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_group_memberships user_group_memberships_group_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_group_memberships
    ADD CONSTRAINT user_group_memberships_group_id_fkey FOREIGN KEY (group_id) REFERENCES public.groups(group_id) ON DELETE CASCADE;


--
-- Name: user_group_memberships user_group_memberships_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_group_memberships
    ADD CONSTRAINT user_group_memberships_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_identities user_identities_provider_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_identities
    ADD CONSTRAINT user_identities_provider_code_fkey FOREIGN KEY (provider_code) REFERENCES public.idp_providers(provider_code);


--
-- Name: user_identities user_identities_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_identities
    ADD CONSTRAINT user_identities_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_mfa_factors user_mfa_factors_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_mfa_factors
    ADD CONSTRAINT user_mfa_factors_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_mfa_totp user_mfa_totp_factor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_mfa_totp
    ADD CONSTRAINT user_mfa_totp_factor_id_fkey FOREIGN KEY (factor_id) REFERENCES public.user_mfa_factors(factor_id) ON DELETE CASCADE;


--
-- Name: user_mfa_webauthn user_mfa_webauthn_factor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_mfa_webauthn
    ADD CONSTRAINT user_mfa_webauthn_factor_id_fkey FOREIGN KEY (factor_id) REFERENCES public.user_mfa_factors(factor_id) ON DELETE CASCADE;


--
-- Name: user_module_permissions user_module_permissions_module_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_module_permissions
    ADD CONSTRAINT user_module_permissions_module_id_fkey FOREIGN KEY (module_id) REFERENCES public.modules(module_id) ON DELETE CASCADE;


--
-- Name: user_module_permissions user_module_permissions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_module_permissions
    ADD CONSTRAINT user_module_permissions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_org_memberships user_org_memberships_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_org_memberships
    ADD CONSTRAINT user_org_memberships_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: user_org_memberships user_org_memberships_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_org_memberships
    ADD CONSTRAINT user_org_memberships_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_passwords user_passwords_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_passwords
    ADD CONSTRAINT user_passwords_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_phones user_phones_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_phones
    ADD CONSTRAINT user_phones_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_recovery_codes user_recovery_codes_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_recovery_codes
    ADD CONSTRAINT user_recovery_codes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: user_table_permissions user_table_permissions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.user_table_permissions
    ADD CONSTRAINT user_table_permissions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: users_profiles users_profiles_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.users_profiles
    ADD CONSTRAINT users_profiles_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;


--
-- Name: vendor_addresses vendor_addresses_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_addresses
    ADD CONSTRAINT vendor_addresses_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: vendor_bank_accounts vendor_bank_accounts_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_bank_accounts
    ADD CONSTRAINT vendor_bank_accounts_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: vendor_capabilities vendor_capabilities_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_capabilities
    ADD CONSTRAINT vendor_capabilities_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: vendor_certificates vendor_certificates_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_certificates
    ADD CONSTRAINT vendor_certificates_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: vendor_contacts vendor_contacts_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_contacts
    ADD CONSTRAINT vendor_contacts_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: vendor_documents vendor_documents_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_documents
    ADD CONSTRAINT vendor_documents_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: vendor_emails vendor_emails_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_emails
    ADD CONSTRAINT vendor_emails_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: vendor_invoices vendor_invoices_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_invoices
    ADD CONSTRAINT vendor_invoices_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: vendor_invoices vendor_invoices_purchase_order_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_invoices
    ADD CONSTRAINT vendor_invoices_purchase_order_id_fkey FOREIGN KEY (purchase_order_id) REFERENCES public.purchase_orders(purchase_order_id) ON DELETE CASCADE;


--
-- Name: vendor_performance_metrics vendor_performance_metrics_reviewer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_performance_metrics
    ADD CONSTRAINT vendor_performance_metrics_reviewer_id_fkey FOREIGN KEY (reviewer_id) REFERENCES public.users(user_id);


--
-- Name: vendor_performance_metrics vendor_performance_metrics_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_performance_metrics
    ADD CONSTRAINT vendor_performance_metrics_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: vendor_phone_numbers vendor_phone_numbers_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_phone_numbers
    ADD CONSTRAINT vendor_phone_numbers_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: vendor_quote_items vendor_quote_items_quote_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_quote_items
    ADD CONSTRAINT vendor_quote_items_quote_id_fkey FOREIGN KEY (quote_id) REFERENCES public.vendor_quotes(quote_id) ON DELETE CASCADE;


--
-- Name: vendor_quote_items vendor_quote_items_rfq_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_quote_items
    ADD CONSTRAINT vendor_quote_items_rfq_item_id_fkey FOREIGN KEY (rfq_item_id) REFERENCES public.rfq_items(id) ON DELETE SET NULL;


--
-- Name: vendor_quotes vendor_quotes_invite_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_quotes
    ADD CONSTRAINT vendor_quotes_invite_id_fkey FOREIGN KEY (invite_id) REFERENCES public.rfq_invites(invite_id) ON DELETE SET NULL;


--
-- Name: vendor_quotes vendor_quotes_rfq_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_quotes
    ADD CONSTRAINT vendor_quotes_rfq_id_fkey FOREIGN KEY (rfq_id) REFERENCES public.rfq_headers(rfq_id) ON DELETE CASCADE;


--
-- Name: vendor_quotes vendor_quotes_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_quotes
    ADD CONSTRAINT vendor_quotes_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: vendor_supporting_docs vendor_supporting_docs_vendor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendor_supporting_docs
    ADD CONSTRAINT vendor_supporting_docs_vendor_id_fkey FOREIGN KEY (vendor_id) REFERENCES public.vendors(vendor_id) ON DELETE CASCADE;


--
-- Name: vendors vendors_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.vendors
    ADD CONSTRAINT vendors_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: work_types work_types_org_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: taf
--

ALTER TABLE ONLY public.work_types
    ADD CONSTRAINT work_types_org_id_fkey FOREIGN KEY (org_id) REFERENCES public.orgs(org_id) ON DELETE CASCADE;


--
-- Name: auto_attach_updatedat_trigger; Type: EVENT TRIGGER; Schema: -; Owner: taf
--

CREATE EVENT TRIGGER auto_attach_updatedat_trigger ON ddl_command_end
         WHEN TAG IN ('CREATE TABLE', 'CREATE TABLE AS', 'ALTER TABLE')
   EXECUTE FUNCTION public.attach_updatedat_trigger();


ALTER EVENT TRIGGER auto_attach_updatedat_trigger OWNER TO taf;

--
-- Name: inventory_movement_history; Type: MATERIALIZED VIEW DATA; Schema: public; Owner: taf
--

REFRESH MATERIALIZED VIEW public.inventory_movement_history;


--
--

\unrestrict 8xkg0dABR2Co3HEmNkoYlhOI4HwVigFsD6g6laTxU5hJZLh1SyljM62BxNFMcVQ

