--
-- PostgreSQL database dump
--

-- Dumped from database version 16.6 (Homebrew)
-- Dumped by pg_dump version 16.6 (Homebrew)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: cube; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS cube WITH SCHEMA public;


--
-- Name: EXTENSION cube; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION cube IS 'data type for multidimensional cubes';


--
-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;


--
-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';


--
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;


--
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';


SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: activity_log; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.activity_log (
    id bigint NOT NULL,
    log_name character varying(255),
    description text NOT NULL,
    subject_type character varying(255),
    subject_id bigint,
    causer_type character varying(255),
    causer_id bigint,
    properties json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    event character varying(255),
    batch_uuid uuid
);


--
-- Name: activity_log_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.activity_log_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: activity_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.activity_log_id_seq OWNED BY public.activity_log.id;


--
-- Name: approval_flows; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.approval_flows (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    code character varying(50) NOT NULL,
    name json NOT NULL,
    description json,
    model_type character varying(255) NOT NULL,
    run_on character varying(255) NOT NULL,
    run_on_status character varying(50),
    conditions json,
    icon character varying(100),
    color character varying(50),
    is_active boolean DEFAULT true NOT NULL,
    meta json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT approval_flows_run_on_check CHECK (((run_on)::text = ANY ((ARRAY['created'::character varying, 'updated'::character varying, 'status_changed'::character varying])::text[])))
);


--
-- Name: approval_flows_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.approval_flows_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: approval_flows_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.approval_flows_id_seq OWNED BY public.approval_flows.id;


--
-- Name: approval_instance_steps; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.approval_instance_steps (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    approval_instance_id bigint NOT NULL,
    approval_flow_id bigint,
    approval_step_id bigint,
    code character varying(50) NOT NULL,
    name json,
    message json,
    is_active boolean DEFAULT true NOT NULL,
    is_by_role boolean DEFAULT false NOT NULL,
    approver_role character varying(100),
    approver_id bigint,
    step_order integer DEFAULT 0 NOT NULL,
    approver_count integer DEFAULT 0 NOT NULL,
    min_approvals integer DEFAULT 1 NOT NULL,
    status character varying(255) DEFAULT 'pending'::character varying NOT NULL,
    approved_count integer DEFAULT 0 NOT NULL,
    rejected_count integer DEFAULT 0 NOT NULL,
    on_approved json,
    on_rejected json,
    meta json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT approval_instance_steps_status_check CHECK (((status)::text = ANY ((ARRAY['pending'::character varying, 'approved'::character varying, 'rejected'::character varying])::text[])))
);


--
-- Name: approval_instance_steps_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.approval_instance_steps_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: approval_instance_steps_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.approval_instance_steps_id_seq OWNED BY public.approval_instance_steps.id;


--
-- Name: approval_instances; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.approval_instances (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    approval_flow_id bigint NOT NULL,
    code character varying(50),
    name json,
    message json,
    current_step_id integer,
    next_step_id integer,
    approvable_type character varying(255) NOT NULL,
    approvable_id bigint NOT NULL,
    is_completed boolean DEFAULT false NOT NULL,
    meta json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: approval_instances_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.approval_instances_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: approval_instances_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.approval_instances_id_seq OWNED BY public.approval_instances.id;


--
-- Name: approval_steps; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.approval_steps (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    approval_flow_id bigint NOT NULL,
    code character varying(50) NOT NULL,
    step_order integer NOT NULL,
    name json NOT NULL,
    is_by_role boolean DEFAULT false NOT NULL,
    approver_role character varying(100),
    approver_user_id bigint,
    min_approvals integer DEFAULT 1 NOT NULL,
    on_approved json,
    on_rejected json,
    is_active boolean DEFAULT true NOT NULL,
    meta json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone
);


--
-- Name: approval_steps_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.approval_steps_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: approval_steps_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.approval_steps_id_seq OWNED BY public.approval_steps.id;


--
-- Name: approvals; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.approvals (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    approval_step_id bigint NOT NULL,
    approvable_type character varying(255) NOT NULL,
    approvable_id bigint NOT NULL,
    status character varying(255) DEFAULT 'pending'::character varying NOT NULL,
    approver_id bigint,
    comment text,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    approval_instance_id bigint,
    approval_instance_step_id bigint,
    deleted_at timestamp(0) without time zone,
    CONSTRAINT approvals_status_check CHECK (((status)::text = ANY ((ARRAY['pending'::character varying, 'approved'::character varying, 'rejected'::character varying])::text[])))
);


--
-- Name: approvals_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.approvals_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: approvals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.approvals_id_seq OWNED BY public.approvals.id;


--
-- Name: audit_logs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.audit_logs (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    action_type character varying(255) NOT NULL,
    actor_user_id bigint,
    actor_user_uuid uuid,
    actor_device_id bigint,
    actor_device_uuid uuid,
    target_entity_type character varying(255),
    target_entity_id bigint,
    target_entity_uuid uuid,
    description text NOT NULL,
    details_before jsonb,
    details_after jsonb,
    additional_metadata jsonb,
    ip_address inet,
    user_agent text,
    trace_id character varying(255),
    occurred_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT audit_logs_action_type_check CHECK (((action_type)::text = ANY ((ARRAY['user.registered'::character varying, 'user.phone.verified'::character varying, 'user.email.verified'::character varying, 'user.profile.updated'::character varying, 'user.password.changed'::character varying, 'user.status.changed'::character varying, 'user.password_reset.requested'::character varying, 'user.password_reset.completed'::character varying, 'user.account.deactivated'::character varying, 'user.account.reactivated'::character varying, 'auth.login.success'::character varying, 'auth.login.failed'::character varying, 'auth.logout.success'::character varying, 'auth.otp.requested'::character varying, 'auth.otp.verified'::character varying, 'auth.otp.invalid'::character varying, 'auth.token.issued'::character varying, 'auth.token.revoked'::character varying, 'device.registered'::character varying, 'device.status.changed'::character varying, 'device.details.updated'::character varying, 'device.verified'::character varying, 'device_user.linked'::character varying, 'device_user.unlinked'::character varying, 'device_user.link_status.changed'::character varying, 'device_user.primary_status.changed'::character varying, 'admin.user.created'::character varying, 'admin.user.updated'::character varying, 'admin.user.deleted'::character varying, 'admin.device.blocked'::character varying, 'admin.settings.changed'::character varying, 'system.error.occurred'::character varying, 'system.maintenance.engaged'::character varying, 'system.maintenance.disengaged'::character varying, 'resource.created'::character varying, 'resource.updated'::character varying, 'resource.deleted'::character varying, 'resource.viewed'::character varying, 'opportunity.created'::character varying, 'opportunity.updated'::character varying, 'opportunity.deleted'::character varying, 'opportunity.stage.transitioned'::character varying, 'opportunity.screening.accepted'::character varying, 'opportunity.screening.rejected'::character varying, 'opportunity.screening.held'::character varying, 'opportunity.screening.returned'::character varying, 'opportunity.screening.priority_set'::character varying, 'opportunity.feasibility.completed'::character varying, 'opportunity.feasibility.rejected'::character varying, 'opportunity.feasibility.returned'::character varying, 'opportunity.feasibility.updated'::character varying, 'opportunity.financial.completed'::character varying, 'opportunity.financial.rejected'::character varying, 'opportunity.financial.returned'::character varying, 'opportunity.financial.modeled'::character varying, 'opportunity.approval_investment.approved'::character varying, 'opportunity.approval_investment.rejected'::character varying, 'opportunity.approval_investment.returned'::character varying, 'opportunity.approval_financial.approved'::character varying, 'opportunity.approval_financial.rejected'::character varying, 'opportunity.approval_financial.returned'::character varying, 'opportunity.approval_executive.approved'::character varying, 'opportunity.approval_executive.rejected'::character varying, 'opportunity.approval_executive.returned'::character varying, 'opportunity.funding.completed'::character varying, 'opportunity.handover.completed'::character varying, 'opportunity.media.uploaded'::character varying, 'opportunity.media.deleted'::character varying, 'opportunity.resubmitted'::character varying, 'opportunity.comment.added'::character varying])::text[])))
);


--
-- Name: audit_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.audit_logs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: audit_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.audit_logs_id_seq OWNED BY public.audit_logs.id;


--
-- Name: cache; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cache (
    key character varying(255) NOT NULL,
    value text NOT NULL,
    expiration integer NOT NULL
);


--
-- Name: cache_locks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cache_locks (
    key character varying(255) NOT NULL,
    owner character varying(255) NOT NULL,
    expiration integer NOT NULL
);


--
-- Name: configurable_features; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.configurable_features (
    id bigint NOT NULL,
    feature_id bigint NOT NULL,
    configurable_type character varying(255) NOT NULL,
    configurable_id uuid NOT NULL,
    value character varying(255) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: configurable_features_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.configurable_features_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: configurable_features_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.configurable_features_id_seq OWNED BY public.configurable_features.id;


--
-- Name: department_stage_assignments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.department_stage_assignments (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    department_id uuid NOT NULL,
    stage_id uuid NOT NULL,
    can_view boolean DEFAULT true NOT NULL,
    can_edit boolean DEFAULT false NOT NULL,
    can_approve boolean DEFAULT false NOT NULL,
    can_reject boolean DEFAULT false NOT NULL,
    assignment_config jsonb,
    created_at timestamp(0) without time zone NOT NULL
);


--
-- Name: department_stage_assignments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.department_stage_assignments_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: department_stage_assignments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.department_stage_assignments_id_seq OWNED BY public.department_stage_assignments.id;


--
-- Name: departments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.departments (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    code character varying(50) NOT NULL,
    name_ar character varying(255) NOT NULL,
    name_en character varying(255) NOT NULL,
    description_ar text,
    description_en text,
    icon character varying(100),
    color character varying(20),
    settings jsonb,
    is_active boolean DEFAULT true NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    parent_id bigint,
    manager_id bigint,
    CONSTRAINT check_department_sort_order CHECK ((sort_order >= 0))
);


--
-- Name: departments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.departments_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: departments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.departments_id_seq OWNED BY public.departments.id;


--
-- Name: device_users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.device_users (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    user_id bigint NOT NULL,
    device_id bigint NOT NULL,
    link_status character varying(255) DEFAULT 'linked_inactive_session'::character varying NOT NULL,
    linked_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    last_login_at timestamp(0) without time zone,
    last_activity_at timestamp(0) without time zone,
    last_logout_at timestamp(0) without time zone,
    is_primary_device_for_user boolean DEFAULT false NOT NULL,
    link_notes text,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT device_users_link_status_check CHECK (((link_status)::text = ANY ((ARRAY['pending_device_verification'::character varying, 'active_session'::character varying, 'linked_inactive_session'::character varying, 'pending_approval'::character varying, 'link_suspended_by_user'::character varying, 'link_suspended_by_admin'::character varying, 'unlinked_by_user'::character varying, 'unlinked_by_admin'::character varying, 'link_expired'::character varying])::text[])))
);


--
-- Name: COLUMN device_users.uuid; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.device_users.uuid IS 'Public unique ID for this link record.';


--
-- Name: COLUMN device_users.link_notes; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN public.device_users.link_notes IS 'Notes regarding this specific link, e.g., reason for suspension.';


--
-- Name: device_users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.device_users_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: device_users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.device_users_id_seq OWNED BY public.device_users.id;


--
-- Name: devices; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.devices (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    device_hash character varying(255) NOT NULL,
    platform character varying(255) DEFAULT 'other'::character varying NOT NULL,
    os_name character varying(255),
    os_version character varying(255),
    model_name character varying(255),
    manufacturer character varying(255),
    app_version character varying(255),
    status character varying(255) DEFAULT 'active'::character varying NOT NULL,
    status_reason text,
    last_known_ip inet,
    last_user_agent text,
    last_seen_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    CONSTRAINT devices_platform_check CHECK (((platform)::text = ANY ((ARRAY['android'::character varying, 'ios'::character varying, 'web'::character varying, 'macos'::character varying, 'windows'::character varying, 'linux'::character varying, 'other'::character varying])::text[]))),
    CONSTRAINT devices_status_check CHECK (((status)::text = ANY ((ARRAY['active'::character varying, 'inactive'::character varying, 'blocked'::character varying, 'suspended'::character varying, 'reported'::character varying, 'compromised'::character varying, 'unlinked'::character varying, 'pending_verification'::character varying, 'revoked_by_admin'::character varying, 'stale_registration'::character varying])::text[])))
);


--
-- Name: devices_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.devices_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: devices_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.devices_id_seq OWNED BY public.devices.id;


--
-- Name: failed_jobs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.failed_jobs (
    id bigint NOT NULL,
    uuid character varying(255) NOT NULL,
    connection text NOT NULL,
    queue text NOT NULL,
    payload text NOT NULL,
    exception text NOT NULL,
    failed_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


--
-- Name: failed_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.failed_jobs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: failed_jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.failed_jobs_id_seq OWNED BY public.failed_jobs.id;


--
-- Name: features; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.features (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    slug character varying(255) NOT NULL,
    name_ar character varying(255) NOT NULL,
    name_en character varying(255) NOT NULL,
    description_ar text,
    description_en text,
    type character varying(255) DEFAULT 'boolean'::character varying NOT NULL,
    default_value character varying(255),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: features_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.features_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: features_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.features_id_seq OWNED BY public.features.id;


--
-- Name: form_audit_trails; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.form_audit_trails (
    id uuid NOT NULL,
    instance_id uuid NOT NULL,
    operation character varying(255) NOT NULL,
    old_values jsonb,
    new_values jsonb,
    changed_fields jsonb,
    user_id character varying(255),
    ip_address character varying(255),
    user_agent character varying(255),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: form_blueprints; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.form_blueprints (
    id uuid NOT NULL,
    code character varying(255) NOT NULL,
    version integer DEFAULT 1 NOT NULL,
    name jsonb NOT NULL,
    schema_def jsonb NOT NULL,
    entity_mapping jsonb,
    workflow_config jsonb,
    status character varying(255) DEFAULT 'draft'::character varying NOT NULL,
    created_by uuid,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone
);


--
-- Name: form_instances; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.form_instances (
    id uuid NOT NULL,
    blueprint_id uuid NOT NULL,
    entity_type character varying(255) NOT NULL,
    entity_id uuid NOT NULL,
    data jsonb NOT NULL,
    computed_cache jsonb,
    schema_version bigint NOT NULL,
    status character varying(255) DEFAULT 'draft'::character varying NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    schema_override jsonb
);


--
-- Name: hr_application_activities; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_application_activities (
    id bigint NOT NULL,
    application_id bigint NOT NULL,
    actor_user_id bigint,
    actor_name character varying(120),
    actor_role character varying(32),
    activity_type character varying(255) NOT NULL,
    message character varying(1000) NOT NULL,
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    CONSTRAINT hr_application_activities_activity_type_check CHECK (((activity_type)::text = ANY ((ARRAY['submitted'::character varying, 'status'::character varying, 'note'::character varying, 'system'::character varying])::text[])))
);


--
-- Name: hr_application_activities_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_application_activities_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_application_activities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_application_activities_id_seq OWNED BY public.hr_application_activities.id;


--
-- Name: hr_application_attachments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_application_attachments (
    id bigint NOT NULL,
    application_id bigint NOT NULL,
    field_id bigint,
    field_key character varying(120),
    label character varying(190),
    file_name character varying(255) NOT NULL,
    mime_type character varying(190),
    size_bytes bigint,
    storage_disk character varying(64) DEFAULT 'public'::character varying NOT NULL,
    storage_path character varying(500),
    storage_url character varying(1000),
    sha256_hex character(64),
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


--
-- Name: hr_application_attachments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_application_attachments_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_application_attachments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_application_attachments_id_seq OWNED BY public.hr_application_attachments.id;


--
-- Name: hr_application_field_values; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_application_field_values (
    id bigint NOT NULL,
    application_id bigint NOT NULL,
    field_id bigint,
    field_key character varying(120) NOT NULL,
    field_label_snapshot character varying(190),
    field_type_snapshot character varying(32),
    value_json json,
    value_text text,
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


--
-- Name: hr_application_field_values_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_application_field_values_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_application_field_values_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_application_field_values_id_seq OWNED BY public.hr_application_field_values.id;


--
-- Name: hr_application_question_answers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_application_question_answers (
    id bigint NOT NULL,
    application_id bigint NOT NULL,
    question_id bigint NOT NULL,
    answer_text text,
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


--
-- Name: hr_application_question_answers_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_application_question_answers_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_application_question_answers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_application_question_answers_id_seq OWNED BY public.hr_application_question_answers.id;


--
-- Name: hr_application_skill_ratings; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_application_skill_ratings (
    id bigint NOT NULL,
    application_id bigint NOT NULL,
    skill_id bigint NOT NULL,
    value character varying(64),
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


--
-- Name: hr_application_skill_ratings_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_application_skill_ratings_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_application_skill_ratings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_application_skill_ratings_id_seq OWNED BY public.hr_application_skill_ratings.id;


--
-- Name: hr_application_statuses; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_application_statuses (
    id bigint NOT NULL,
    key character varying(255) NOT NULL,
    name_ar character varying(255) NOT NULL,
    name_en character varying(255) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: hr_application_statuses_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_application_statuses_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_application_statuses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_application_statuses_id_seq OWNED BY public.hr_application_statuses.id;


--
-- Name: hr_applications; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_applications (
    id bigint NOT NULL,
    job_id bigint NOT NULL,
    status character varying(255) DEFAULT 'new'::character varying NOT NULL,
    applicant_full_name character varying(190) NOT NULL,
    applicant_phone character varying(64) NOT NULL,
    applicant_email character varying(190) NOT NULL,
    submitted_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at timestamp(0) without time zone,
    CONSTRAINT hr_applications_status_check CHECK (((status)::text = ANY ((ARRAY['new'::character varying, 'review'::character varying, 'shortlist'::character varying, 'hired'::character varying, 'rejected'::character varying])::text[])))
);


--
-- Name: hr_applications_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_applications_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_applications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_applications_id_seq OWNED BY public.hr_applications.id;


--
-- Name: hr_filter_groups; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_filter_groups (
    id bigint NOT NULL,
    scope character varying(50) NOT NULL,
    key character varying(100) NOT NULL,
    name_ar character varying(255) NOT NULL,
    name_en character varying(255),
    icon character varying(50),
    sort_order integer DEFAULT 0 NOT NULL,
    is_multi boolean DEFAULT true NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone
);


--
-- Name: hr_filter_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_filter_groups_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_filter_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_filter_groups_id_seq OWNED BY public.hr_filter_groups.id;


--
-- Name: hr_filter_options; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_filter_options (
    id bigint NOT NULL,
    group_id bigint NOT NULL,
    parent_id bigint,
    key character varying(100) NOT NULL,
    name_ar character varying(255) NOT NULL,
    name_en character varying(255),
    sort_order integer DEFAULT 0 NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    meta json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone
);


--
-- Name: hr_filter_options_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_filter_options_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_filter_options_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_filter_options_id_seq OWNED BY public.hr_filter_options.id;


--
-- Name: hr_job_form_field_options; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_job_form_field_options (
    id bigint NOT NULL,
    field_id bigint NOT NULL,
    value character varying(190) NOT NULL,
    label_ar character varying(190) NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL,
    label_en character varying(190),
    kind character varying(50) DEFAULT 'choice'::character varying NOT NULL,
    input_type character varying(50)
);


--
-- Name: hr_job_form_field_options_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_job_form_field_options_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_job_form_field_options_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_job_form_field_options_id_seq OWNED BY public.hr_job_form_field_options.id;


--
-- Name: hr_job_form_fields; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_job_form_fields (
    id bigint NOT NULL,
    field_key character varying(120) NOT NULL,
    label_ar character varying(190) NOT NULL,
    field_type character varying(255) NOT NULL,
    is_required boolean DEFAULT false NOT NULL,
    help_text_ar character varying(500),
    sort_order integer DEFAULT 0 NOT NULL,
    visible_when_key character varying(120),
    visible_when_equals character varying(190),
    file_accept character varying(190),
    file_inline_mb integer DEFAULT 0 NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    meta json,
    label_en character varying(190),
    help_text_en character varying(500),
    group_id bigint NOT NULL,
    CONSTRAINT hr_job_form_fields_field_type_check CHECK (((field_type)::text = ANY ((ARRAY['text'::character varying, 'textarea'::character varying, 'email'::character varying, 'tel'::character varying, 'number'::character varying, 'date'::character varying, 'yesno'::character varying, 'select'::character varying, 'multiselect'::character varying, 'radio'::character varying, 'checkbox'::character varying, 'file'::character varying, 'table'::character varying])::text[])))
);


--
-- Name: hr_job_form_fields_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_job_form_fields_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_job_form_fields_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_job_form_fields_id_seq OWNED BY public.hr_job_form_fields.id;


--
-- Name: hr_job_form_groups; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_job_form_groups (
    id bigint NOT NULL,
    section_id bigint NOT NULL,
    title_ar character varying(190),
    title_en character varying(190),
    sort_order integer DEFAULT 0 NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: hr_job_form_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_job_form_groups_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_job_form_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_job_form_groups_id_seq OWNED BY public.hr_job_form_groups.id;


--
-- Name: hr_job_form_sections; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_job_form_sections (
    id bigint NOT NULL,
    job_id bigint NOT NULL,
    title_ar character varying(190) NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    title_en character varying(190)
);


--
-- Name: hr_job_form_sections_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_job_form_sections_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_job_form_sections_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_job_form_sections_id_seq OWNED BY public.hr_job_form_sections.id;


--
-- Name: hr_job_questions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_job_questions (
    id bigint NOT NULL,
    job_id bigint NOT NULL,
    question_id bigint NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL
);


--
-- Name: hr_job_questions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_job_questions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_job_questions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_job_questions_id_seq OWNED BY public.hr_job_questions.id;


--
-- Name: hr_job_rules; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_job_rules (
    id bigint NOT NULL,
    job_id bigint NOT NULL,
    gender_rule character varying(255) DEFAULT 'any'::character varying NOT NULL,
    nationality_rule character varying(255) DEFAULT 'any'::character varying NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT hr_job_rules_gender_rule_check CHECK (((gender_rule)::text = ANY ((ARRAY['any'::character varying, 'male'::character varying, 'female'::character varying])::text[]))),
    CONSTRAINT hr_job_rules_nationality_rule_check CHECK (((nationality_rule)::text = ANY ((ARRAY['any'::character varying, 'saudi'::character varying])::text[])))
);


--
-- Name: hr_job_rules_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_job_rules_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_job_rules_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_job_rules_id_seq OWNED BY public.hr_job_rules.id;


--
-- Name: hr_job_skill_requirements; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_job_skill_requirements (
    id bigint NOT NULL,
    job_id bigint NOT NULL,
    skill_id bigint NOT NULL,
    is_required boolean DEFAULT true NOT NULL,
    min_value character varying(64),
    sort_order integer DEFAULT 0 NOT NULL
);


--
-- Name: hr_job_skill_requirements_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_job_skill_requirements_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_job_skill_requirements_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_job_skill_requirements_id_seq OWNED BY public.hr_job_skill_requirements.id;


--
-- Name: hr_jobs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_jobs (
    id bigint NOT NULL,
    title_ar character varying(190) NOT NULL,
    dept_ar character varying(190) NOT NULL,
    status character varying(255) DEFAULT 'active'::character varying NOT NULL,
    note_ar character varying(500),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    title_en character varying(190),
    dept_en character varying(190),
    note_en text,
    start_date date,
    end_date date,
    is_general boolean DEFAULT false NOT NULL,
    is_template boolean DEFAULT false NOT NULL,
    is_draft boolean DEFAULT false NOT NULL,
    CONSTRAINT hr_jobs_status_check CHECK (((status)::text = ANY ((ARRAY['active'::character varying, 'closed'::character varying])::text[])))
);


--
-- Name: hr_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_jobs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_jobs_id_seq OWNED BY public.hr_jobs.id;


--
-- Name: hr_question_options; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_question_options (
    id bigint NOT NULL,
    question_id bigint NOT NULL,
    value character varying(190) NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL
);


--
-- Name: hr_question_options_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_question_options_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_question_options_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_question_options_id_seq OWNED BY public.hr_question_options.id;


--
-- Name: hr_questions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_questions (
    id bigint NOT NULL,
    text character varying(600) NOT NULL,
    answer_type character varying(255) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT hr_questions_answer_type_check CHECK (((answer_type)::text = ANY ((ARRAY['text'::character varying, 'yesno'::character varying, 'select'::character varying])::text[])))
);


--
-- Name: hr_questions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_questions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_questions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_questions_id_seq OWNED BY public.hr_questions.id;


--
-- Name: hr_skill_scale_options; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_skill_scale_options (
    id bigint NOT NULL,
    skill_id bigint NOT NULL,
    value character varying(64) NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL
);


--
-- Name: hr_skill_scale_options_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_skill_scale_options_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_skill_scale_options_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_skill_scale_options_id_seq OWNED BY public.hr_skill_scale_options.id;


--
-- Name: hr_skills; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.hr_skills (
    id bigint NOT NULL,
    name character varying(190) NOT NULL,
    category character varying(255) DEFAULT 'other'::character varying NOT NULL,
    preset character varying(32),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT hr_skills_category_check CHECK (((category)::text = ANY ((ARRAY['technical'::character varying, 'soft'::character varying, 'language'::character varying, 'other'::character varying])::text[])))
);


--
-- Name: hr_skills_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.hr_skills_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: hr_skills_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.hr_skills_id_seq OWNED BY public.hr_skills.id;


--
-- Name: job_batches; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.job_batches (
    id character varying(255) NOT NULL,
    name character varying(255) NOT NULL,
    total_jobs integer NOT NULL,
    pending_jobs integer NOT NULL,
    failed_jobs integer NOT NULL,
    failed_job_ids text NOT NULL,
    options text,
    cancelled_at integer,
    created_at integer NOT NULL,
    finished_at integer
);


--
-- Name: jobs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jobs (
    id bigint NOT NULL,
    queue character varying(255) NOT NULL,
    payload text NOT NULL,
    attempts smallint NOT NULL,
    reserved_at integer,
    available_at integer NOT NULL,
    created_at integer NOT NULL
);


--
-- Name: jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.jobs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.jobs_id_seq OWNED BY public.jobs.id;


--
-- Name: level_upgrade_rules; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.level_upgrade_rules (
    id bigint NOT NULL,
    from_level_id bigint NOT NULL,
    to_level_id bigint NOT NULL,
    for_role_id bigint,
    metric_key character varying(255) NOT NULL,
    operator character varying(10) DEFAULT '>='::character varying NOT NULL,
    required_value character varying(255) NOT NULL,
    duration_days integer,
    description text,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: level_upgrade_rules_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.level_upgrade_rules_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: level_upgrade_rules_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.level_upgrade_rules_id_seq OWNED BY public.level_upgrade_rules.id;


--
-- Name: media; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.media (
    id bigint NOT NULL,
    model_type character varying(255) NOT NULL,
    model_id bigint NOT NULL,
    uuid uuid,
    collection_name character varying(255) NOT NULL,
    name character varying(255) NOT NULL,
    file_name character varying(255) NOT NULL,
    mime_type character varying(255),
    disk character varying(255) NOT NULL,
    conversions_disk character varying(255),
    size bigint NOT NULL,
    manipulations json NOT NULL,
    custom_properties json NOT NULL,
    generated_conversions json NOT NULL,
    responsive_images json NOT NULL,
    order_column integer,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: media_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.media_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: media_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.media_id_seq OWNED BY public.media.id;


--
-- Name: migrations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.migrations (
    id integer NOT NULL,
    migration character varying(255) NOT NULL,
    batch integer NOT NULL
);


--
-- Name: migrations_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.migrations_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: migrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.migrations_id_seq OWNED BY public.migrations.id;


--
-- Name: model_has_permissions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.model_has_permissions (
    permission_id bigint NOT NULL,
    model_type character varying(255) NOT NULL,
    model_id bigint NOT NULL
);


--
-- Name: model_has_roles; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.model_has_roles (
    role_id bigint NOT NULL,
    model_type character varying(255) NOT NULL,
    model_id bigint NOT NULL
);


--
-- Name: node_permissions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.node_permissions (
    id bigint NOT NULL,
    node_id bigint NOT NULL,
    permission_id bigint NOT NULL,
    is_inherited boolean DEFAULT false NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: node_permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.node_permissions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: node_permissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.node_permissions_id_seq OWNED BY public.node_permissions.id;


--
-- Name: opportunities; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.opportunities (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    reference_number character varying(50) NOT NULL,
    name character varying(255) NOT NULL,
    type character varying(20) NOT NULL,
    city character varying(100) NOT NULL,
    neighborhood character varying(100),
    latitude numeric(10,8),
    longitude numeric(11,8),
    coordinates_text character varying(255),
    land_area numeric(10,2),
    built_area numeric(10,2),
    price_per_sqm_amount numeric(15,2),
    price_per_sqm_currency character varying(3),
    total_value_amount numeric(15,2),
    total_value_currency character varying(3),
    current_stage_id uuid,
    current_status character varying(50) DEFAULT 'new'::character varying NOT NULL,
    notes text,
    basic_data jsonb,
    owner_user_id uuid NOT NULL,
    assigned_to uuid,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    completed_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    source character varying(255),
    rfi_state json,
    priority character varying(20),
    reminder_at timestamp(0) without time zone,
    rejection_reason text,
    rejected_by_user_id uuid,
    rejected_at timestamp(0) without time zone,
    stage_history json,
    stage_arrived_at timestamp(0) without time zone,
    is_new_to_stage boolean DEFAULT true NOT NULL,
    CONSTRAINT check_positive_areas CHECK (((land_area > (0)::numeric) AND ((built_area IS NULL) OR (built_area >= (0)::numeric)))),
    CONSTRAINT check_positive_price CHECK (((price_per_sqm_amount IS NULL) OR (price_per_sqm_amount >= (0)::numeric))),
    CONSTRAINT check_positive_total_value CHECK (((total_value_amount IS NULL) OR (total_value_amount >= (0)::numeric)))
);


--
-- Name: opportunities_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.opportunities_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: opportunities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.opportunities_id_seq OWNED BY public.opportunities.id;


--
-- Name: opportunity_comments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.opportunity_comments (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    opportunity_id uuid NOT NULL,
    stage_id uuid,
    content text NOT NULL,
    author_id uuid NOT NULL,
    parent_comment_id uuid,
    created_at timestamp(0) without time zone NOT NULL
);


--
-- Name: opportunity_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.opportunity_comments_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: opportunity_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.opportunity_comments_id_seq OWNED BY public.opportunity_comments.id;


--
-- Name: opportunity_contacts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.opportunity_contacts (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    opportunity_id bigint NOT NULL,
    name character varying(255) NOT NULL,
    phone character varying(255),
    email character varying(255),
    role character varying(255),
    notes text,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: opportunity_contacts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.opportunity_contacts_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: opportunity_contacts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.opportunity_contacts_id_seq OWNED BY public.opportunity_contacts.id;


--
-- Name: opportunity_properties; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.opportunity_properties (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    opportunity_id bigint NOT NULL,
    name character varying(255) NOT NULL,
    land_area numeric(10,2) NOT NULL,
    built_area numeric(10,2),
    zoning character varying(255),
    notes text,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    price_per_sqm numeric(15,2)
);


--
-- Name: opportunity_properties_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.opportunity_properties_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: opportunity_properties_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.opportunity_properties_id_seq OWNED BY public.opportunity_properties.id;


--
-- Name: opportunity_stage_data; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.opportunity_stage_data (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    opportunity_id uuid NOT NULL,
    stage_id uuid NOT NULL,
    data jsonb NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    updated_by uuid,
    completed_at timestamp(0) without time zone,
    status character varying(50)
);


--
-- Name: opportunity_stage_data_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.opportunity_stage_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: opportunity_stage_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.opportunity_stage_data_id_seq OWNED BY public.opportunity_stage_data.id;


--
-- Name: org_contracts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.org_contracts (
    id bigint NOT NULL,
    employee_id bigint NOT NULL,
    type character varying(255) NOT NULL,
    salary_amount numeric(15,2) NOT NULL,
    salary_currency character varying(3) NOT NULL,
    terms text NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    uuid uuid NOT NULL
);


--
-- Name: org_contracts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.org_contracts_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: org_contracts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.org_contracts_id_seq OWNED BY public.org_contracts.id;


--
-- Name: org_employees; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.org_employees (
    id bigint NOT NULL,
    first_name character varying(255),
    last_name character varying(255),
    email character varying(255),
    original_hire_date date NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    uuid uuid NOT NULL,
    code character varying(255),
    name json,
    date_of_birth date,
    gender character varying(255),
    nationality character varying(255),
    id_number character varying(255),
    id_type character varying(255),
    id_expiry_date date,
    phone character varying(255),
    manager_id bigint,
    meta json,
    status character varying(255) DEFAULT 'active'::character varying NOT NULL
);


--
-- Name: org_employees_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.org_employees_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: org_employees_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.org_employees_id_seq OWNED BY public.org_employees.id;


--
-- Name: org_job_histories; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.org_job_histories (
    id bigint NOT NULL,
    employee_id bigint NOT NULL,
    position_id bigint NOT NULL,
    contract_id bigint,
    start_date date NOT NULL,
    end_date date,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    uuid uuid NOT NULL
);


--
-- Name: org_job_histories_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.org_job_histories_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: org_job_histories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.org_job_histories_id_seq OWNED BY public.org_job_histories.id;


--
-- Name: org_job_titles; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.org_job_titles (
    id bigint NOT NULL,
    name json NOT NULL,
    grade_level character varying(255) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    code character varying(255) NOT NULL,
    uuid uuid NOT NULL,
    description json,
    meta json
);


--
-- Name: org_job_titles_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.org_job_titles_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: org_job_titles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.org_job_titles_id_seq OWNED BY public.org_job_titles.id;


--
-- Name: org_positions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.org_positions (
    id bigint NOT NULL,
    code character varying(255) NOT NULL,
    department_id bigint,
    job_title_id bigint,
    parent_id bigint,
    status character varying(255) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    name json,
    uuid uuid NOT NULL,
    type character varying(255) DEFAULT 'job'::character varying NOT NULL,
    meta json
);


--
-- Name: org_positions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.org_positions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: org_positions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.org_positions_id_seq OWNED BY public.org_positions.id;


--
-- Name: otps; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.otps (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    verifiable_type character varying(255) NOT NULL,
    verifiable_id bigint NOT NULL,
    code character varying(10) NOT NULL,
    channel character varying(20) DEFAULT 'sms'::character varying NOT NULL,
    expires_at timestamp(0) without time zone NOT NULL,
    verified_at timestamp(0) without time zone,
    attempts smallint DEFAULT '0'::smallint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: otps_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.otps_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: otps_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.otps_id_seq OWNED BY public.otps.id;


--
-- Name: password_reset_tokens; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.password_reset_tokens (
    email character varying(255) NOT NULL,
    token character varying(255) NOT NULL,
    created_at timestamp(0) without time zone
);


--
-- Name: permissions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.permissions (
    id bigint NOT NULL,
    name character varying(255) NOT NULL,
    guard_name character varying(255) NOT NULL,
    module character varying(255),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    resource_type character varying(255) DEFAULT 'global'::character varying NOT NULL,
    action character varying(255) DEFAULT 'view'::character varying NOT NULL,
    display_name json,
    uuid uuid
);


--
-- Name: permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.permissions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: permissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.permissions_id_seq OWNED BY public.permissions.id;


--
-- Name: personal_access_tokens; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.personal_access_tokens (
    id bigint NOT NULL,
    tokenable_type character varying(255) NOT NULL,
    tokenable_id bigint NOT NULL,
    name character varying(255) NOT NULL,
    token character varying(64) NOT NULL,
    abilities text,
    last_used_at timestamp(0) without time zone,
    expires_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: personal_access_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.personal_access_tokens_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: personal_access_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.personal_access_tokens_id_seq OWNED BY public.personal_access_tokens.id;


--
-- Name: profile_completion_weights; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.profile_completion_weights (
    key character varying(255) NOT NULL,
    description_ar character varying(255) NOT NULL,
    description_en character varying(255),
    points smallint DEFAULT '0'::smallint NOT NULL,
    for_role_id bigint,
    for_level_id bigint,
    is_active boolean DEFAULT true NOT NULL
);


--
-- Name: profile_levels; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.profile_levels (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    name text NOT NULL,
    slug character varying(255),
    description text NOT NULL,
    rank integer DEFAULT 0 NOT NULL,
    icon_path character varying(255),
    color_hex character varying(7),
    is_active boolean DEFAULT true NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone
);


--
-- Name: profile_levels_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.profile_levels_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: profile_levels_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.profile_levels_id_seq OWNED BY public.profile_levels.id;


--
-- Name: profile_roles; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.profile_roles (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    slug character varying(255) NOT NULL,
    name text NOT NULL,
    description text,
    is_active boolean DEFAULT true NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone
);


--
-- Name: profile_roles_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.profile_roles_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: profile_roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.profile_roles_id_seq OWNED BY public.profile_roles.id;


--
-- Name: profiles; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.profiles (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    owner_user_uuid uuid NOT NULL,
    profile_name character varying(255) NOT NULL,
    profile_slug character varying(255),
    profile_type character varying(255) NOT NULL,
    profile_role_name character varying(255),
    profile_role_id bigint NOT NULL,
    profile_level_id bigint NOT NULL,
    profile_logo uuid,
    profile_cover uuid,
    profilable_type character varying(255) NOT NULL,
    profilable_id uuid NOT NULL,
    completion_percentage smallint DEFAULT '0'::smallint NOT NULL,
    last_completion_calculated_at timestamp(0) without time zone,
    status character varying(255) DEFAULT 'draft'::character varying NOT NULL,
    verified_at timestamp(0) without time zone,
    flags json,
    settings json,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    CONSTRAINT profiles_profile_type_check CHECK (((profile_type)::text = ANY ((ARRAY['individual'::character varying, 'company'::character varying])::text[])))
);


--
-- Name: profiles_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.profiles_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: profiles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.profiles_id_seq OWNED BY public.profiles.id;


--
-- Name: role_has_permissions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.role_has_permissions (
    permission_id bigint NOT NULL,
    role_id bigint NOT NULL
);


--
-- Name: roles; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.roles (
    id bigint NOT NULL,
    name character varying(255) NOT NULL,
    guard_name character varying(255) NOT NULL,
    description character varying(255),
    is_system boolean DEFAULT false NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    display_name json,
    uuid uuid
);


--
-- Name: roles_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.roles_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.roles_id_seq OWNED BY public.roles.id;


--
-- Name: sessions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sessions (
    id character varying(255) NOT NULL,
    user_id bigint,
    ip_address character varying(45),
    user_agent text,
    payload text NOT NULL,
    last_activity integer NOT NULL
);


--
-- Name: stages; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.stages (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    code character varying(50) NOT NULL,
    name_ar character varying(255) NOT NULL,
    name_en character varying(255) NOT NULL,
    description_ar text,
    description_en text,
    icon character varying(100),
    color character varying(20),
    sort_order integer DEFAULT 0 NOT NULL,
    is_initial boolean DEFAULT false NOT NULL,
    is_final boolean DEFAULT false NOT NULL,
    config jsonb,
    is_active boolean DEFAULT true NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT check_initial_or_final CHECK ((NOT ((is_initial = true) AND (is_final = true)))),
    CONSTRAINT check_sort_order CHECK ((sort_order >= 0))
);


--
-- Name: stages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.stages_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: stages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.stages_id_seq OWNED BY public.stages.id;


--
-- Name: system_nodes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.system_nodes (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    type character varying(255) NOT NULL,
    parent_id bigint,
    code character varying(100),
    slug character varying(255),
    name json NOT NULL,
    description json,
    metadata json,
    route character varying(255),
    icon character varying(100),
    color character varying(50),
    component_path character varying(255),
    path character varying(500),
    depth smallint DEFAULT '0'::smallint NOT NULL,
    "position" numeric(10,2) DEFAULT '100'::numeric NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    is_visible boolean DEFAULT true NOT NULL,
    requires_auth boolean DEFAULT true NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    CONSTRAINT system_nodes_type_check CHECK (((type)::text = ANY ((ARRAY['module'::character varying, 'section'::character varying, 'page'::character varying])::text[])))
);


--
-- Name: system_nodes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.system_nodes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: system_nodes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.system_nodes_id_seq OWNED BY public.system_nodes.id;


--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.users (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    name character varying(255),
    phone character varying(255),
    dialing_code character varying(10),
    country_code character varying(3),
    email character varying(255),
    phone_verified_at timestamp(0) without time zone,
    email_verified_at timestamp(0) without time zone,
    username character varying(50),
    password character varying(255),
    status character varying(255) DEFAULT 'pending_phone_verification'::character varying NOT NULL,
    last_login_at timestamp(0) without time zone,
    timezone character varying(100),
    preferred_language character varying(5),
    remember_token character varying(100),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    CONSTRAINT users_status_check CHECK (((status)::text = ANY ((ARRAY['active'::character varying, 'inactive'::character varying, 'pending_phone_verification'::character varying, 'pending_email_verification'::character varying, 'suspended'::character varying, 'banned'::character varying, 'deleted'::character varying, 'deactivated'::character varying, 'incomplete_profile'::character varying, 'pending_approval'::character varying, 'archived'::character varying])::text[])))
);


--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.users_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;


--
-- Name: workflow_approvals; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workflow_approvals (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    workflow_instance_id bigint NOT NULL,
    workflow_node_id bigint NOT NULL,
    step_number integer DEFAULT 1 NOT NULL,
    step_name json,
    approver_user_id uuid,
    approver_role character varying(100),
    status character varying(255) DEFAULT 'pending'::character varying NOT NULL,
    decision_at timestamp(0) without time zone,
    comment text,
    delegated_to_user_id uuid,
    delegated_at timestamp(0) without time zone,
    due_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT workflow_approvals_status_check CHECK (((status)::text = ANY ((ARRAY['pending'::character varying, 'approved'::character varying, 'rejected'::character varying])::text[])))
);


--
-- Name: workflow_approvals_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.workflow_approvals_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: workflow_approvals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workflow_approvals_id_seq OWNED BY public.workflow_approvals.id;


--
-- Name: workflow_definitions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workflow_definitions (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    code character varying(100) NOT NULL,
    name json NOT NULL,
    description json,
    entity_type character varying(255) NOT NULL,
    diagram_json json,
    version integer DEFAULT 1 NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    is_default_for_entity boolean DEFAULT false NOT NULL,
    created_by_user_id uuid,
    updated_by_user_id uuid,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: workflow_definitions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.workflow_definitions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: workflow_definitions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workflow_definitions_id_seq OWNED BY public.workflow_definitions.id;


--
-- Name: workflow_events; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workflow_events (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    workflow_instance_id bigint NOT NULL,
    event_type character varying(100) NOT NULL,
    event_data json,
    severity character varying(255) DEFAULT 'info'::character varying NOT NULL,
    node_id bigint,
    transition_id bigint,
    user_id uuid,
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    CONSTRAINT workflow_events_severity_check CHECK (((severity)::text = ANY ((ARRAY['info'::character varying, 'warning'::character varying, 'error'::character varying, 'critical'::character varying])::text[])))
);


--
-- Name: workflow_events_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.workflow_events_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: workflow_events_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workflow_events_id_seq OWNED BY public.workflow_events.id;


--
-- Name: workflow_instance_history; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workflow_instance_history (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    workflow_instance_id bigint NOT NULL,
    from_node_id bigint NOT NULL,
    to_node_id bigint NOT NULL,
    transition_id bigint,
    action_type character varying(255) NOT NULL,
    performed_by_user_id uuid NOT NULL,
    reason text,
    comment text,
    metadata json,
    duration_seconds integer,
    created_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    CONSTRAINT workflow_instance_history_action_type_check CHECK (((action_type)::text = ANY ((ARRAY['transition'::character varying, 'approval'::character varying, 'rejection'::character varying, 'rollback'::character varying, 'cancel'::character varying, 'pause'::character varying, 'resume'::character varying])::text[])))
);


--
-- Name: workflow_instance_history_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.workflow_instance_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: workflow_instance_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workflow_instance_history_id_seq OWNED BY public.workflow_instance_history.id;


--
-- Name: workflow_instances; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workflow_instances (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    workflow_definition_id bigint NOT NULL,
    entity_type character varying(255) NOT NULL,
    entity_id uuid NOT NULL,
    current_node_id bigint NOT NULL,
    previous_node_id bigint,
    status character varying(255) DEFAULT 'running'::character varying NOT NULL,
    context_data json,
    started_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    completed_at timestamp(0) without time zone,
    cancelled_at timestamp(0) without time zone,
    started_by_user_id uuid,
    current_assignee_user_id uuid,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT workflow_instances_status_check CHECK (((status)::text = ANY ((ARRAY['running'::character varying, 'waiting_approval'::character varying, 'paused'::character varying, 'completed'::character varying, 'cancelled'::character varying, 'failed'::character varying])::text[])))
);


--
-- Name: workflow_instances_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.workflow_instances_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: workflow_instances_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workflow_instances_id_seq OWNED BY public.workflow_instances.id;


--
-- Name: workflow_nodes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workflow_nodes (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    workflow_definition_id bigint NOT NULL,
    code character varying(100) NOT NULL,
    name json NOT NULL,
    description json,
    node_type character varying(255) NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL,
    position_x integer,
    position_y integer,
    config json,
    requires_approval boolean DEFAULT false NOT NULL,
    approval_config json,
    on_entry_actions json,
    on_exit_actions json,
    is_active boolean DEFAULT true NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT workflow_nodes_node_type_check CHECK (((node_type)::text = ANY ((ARRAY['start'::character varying, 'stage'::character varying, 'approval'::character varying, 'decision'::character varying, 'parallel_gateway'::character varying, 'merge_gateway'::character varying, 'end'::character varying])::text[])))
);


--
-- Name: workflow_nodes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.workflow_nodes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: workflow_nodes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workflow_nodes_id_seq OWNED BY public.workflow_nodes.id;


--
-- Name: workflow_schedules; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workflow_schedules (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    workflow_definition_id bigint NOT NULL,
    schedule_type character varying(255) NOT NULL,
    cron_expression character varying(100),
    interval_minutes integer,
    specific_datetime timestamp(0) without time zone,
    entity_factory_config json,
    is_active boolean DEFAULT true NOT NULL,
    last_run_at timestamp(0) without time zone,
    next_run_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT workflow_schedules_schedule_type_check CHECK (((schedule_type)::text = ANY ((ARRAY['cron'::character varying, 'interval'::character varying, 'specific_date'::character varying])::text[])))
);


--
-- Name: workflow_schedules_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.workflow_schedules_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: workflow_schedules_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workflow_schedules_id_seq OWNED BY public.workflow_schedules.id;


--
-- Name: workflow_transitions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.workflow_transitions (
    id bigint NOT NULL,
    uuid uuid NOT NULL,
    workflow_definition_id bigint NOT NULL,
    code character varying(100) NOT NULL,
    name json NOT NULL,
    from_node_id bigint NOT NULL,
    to_node_id bigint NOT NULL,
    transition_type character varying(255) DEFAULT 'manual'::character varying NOT NULL,
    conditions json,
    actions json,
    required_permission character varying(255),
    allowed_roles json,
    priority integer DEFAULT 0 NOT NULL,
    button_label json,
    button_color character varying(20),
    button_icon character varying(50),
    confirm_message json,
    requires_reason boolean DEFAULT false NOT NULL,
    is_active boolean DEFAULT true NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    CONSTRAINT workflow_transitions_transition_type_check CHECK (((transition_type)::text = ANY ((ARRAY['automatic'::character varying, 'manual'::character varying, 'approval'::character varying, 'rejection'::character varying, 'timeout'::character varying, 'conditional'::character varying])::text[])))
);


--
-- Name: workflow_transitions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.workflow_transitions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: workflow_transitions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.workflow_transitions_id_seq OWNED BY public.workflow_transitions.id;


--
-- Name: activity_log id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.activity_log ALTER COLUMN id SET DEFAULT nextval('public.activity_log_id_seq'::regclass);


--
-- Name: approval_flows id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_flows ALTER COLUMN id SET DEFAULT nextval('public.approval_flows_id_seq'::regclass);


--
-- Name: approval_instance_steps id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_instance_steps ALTER COLUMN id SET DEFAULT nextval('public.approval_instance_steps_id_seq'::regclass);


--
-- Name: approval_instances id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_instances ALTER COLUMN id SET DEFAULT nextval('public.approval_instances_id_seq'::regclass);


--
-- Name: approval_steps id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_steps ALTER COLUMN id SET DEFAULT nextval('public.approval_steps_id_seq'::regclass);


--
-- Name: approvals id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approvals ALTER COLUMN id SET DEFAULT nextval('public.approvals_id_seq'::regclass);


--
-- Name: audit_logs id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.audit_logs ALTER COLUMN id SET DEFAULT nextval('public.audit_logs_id_seq'::regclass);


--
-- Name: configurable_features id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.configurable_features ALTER COLUMN id SET DEFAULT nextval('public.configurable_features_id_seq'::regclass);


--
-- Name: department_stage_assignments id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.department_stage_assignments ALTER COLUMN id SET DEFAULT nextval('public.department_stage_assignments_id_seq'::regclass);


--
-- Name: departments id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.departments ALTER COLUMN id SET DEFAULT nextval('public.departments_id_seq'::regclass);


--
-- Name: device_users id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.device_users ALTER COLUMN id SET DEFAULT nextval('public.device_users_id_seq'::regclass);


--
-- Name: devices id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.devices ALTER COLUMN id SET DEFAULT nextval('public.devices_id_seq'::regclass);


--
-- Name: failed_jobs id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.failed_jobs ALTER COLUMN id SET DEFAULT nextval('public.failed_jobs_id_seq'::regclass);


--
-- Name: features id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.features ALTER COLUMN id SET DEFAULT nextval('public.features_id_seq'::regclass);


--
-- Name: hr_application_activities id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_activities ALTER COLUMN id SET DEFAULT nextval('public.hr_application_activities_id_seq'::regclass);


--
-- Name: hr_application_attachments id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_attachments ALTER COLUMN id SET DEFAULT nextval('public.hr_application_attachments_id_seq'::regclass);


--
-- Name: hr_application_field_values id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_field_values ALTER COLUMN id SET DEFAULT nextval('public.hr_application_field_values_id_seq'::regclass);


--
-- Name: hr_application_question_answers id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_question_answers ALTER COLUMN id SET DEFAULT nextval('public.hr_application_question_answers_id_seq'::regclass);


--
-- Name: hr_application_skill_ratings id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_skill_ratings ALTER COLUMN id SET DEFAULT nextval('public.hr_application_skill_ratings_id_seq'::regclass);


--
-- Name: hr_application_statuses id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_statuses ALTER COLUMN id SET DEFAULT nextval('public.hr_application_statuses_id_seq'::regclass);


--
-- Name: hr_applications id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_applications ALTER COLUMN id SET DEFAULT nextval('public.hr_applications_id_seq'::regclass);


--
-- Name: hr_filter_groups id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_filter_groups ALTER COLUMN id SET DEFAULT nextval('public.hr_filter_groups_id_seq'::regclass);


--
-- Name: hr_filter_options id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_filter_options ALTER COLUMN id SET DEFAULT nextval('public.hr_filter_options_id_seq'::regclass);


--
-- Name: hr_job_form_field_options id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_field_options ALTER COLUMN id SET DEFAULT nextval('public.hr_job_form_field_options_id_seq'::regclass);


--
-- Name: hr_job_form_fields id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_fields ALTER COLUMN id SET DEFAULT nextval('public.hr_job_form_fields_id_seq'::regclass);


--
-- Name: hr_job_form_groups id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_groups ALTER COLUMN id SET DEFAULT nextval('public.hr_job_form_groups_id_seq'::regclass);


--
-- Name: hr_job_form_sections id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_sections ALTER COLUMN id SET DEFAULT nextval('public.hr_job_form_sections_id_seq'::regclass);


--
-- Name: hr_job_questions id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_questions ALTER COLUMN id SET DEFAULT nextval('public.hr_job_questions_id_seq'::regclass);


--
-- Name: hr_job_rules id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_rules ALTER COLUMN id SET DEFAULT nextval('public.hr_job_rules_id_seq'::regclass);


--
-- Name: hr_job_skill_requirements id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_skill_requirements ALTER COLUMN id SET DEFAULT nextval('public.hr_job_skill_requirements_id_seq'::regclass);


--
-- Name: hr_jobs id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_jobs ALTER COLUMN id SET DEFAULT nextval('public.hr_jobs_id_seq'::regclass);


--
-- Name: hr_question_options id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_question_options ALTER COLUMN id SET DEFAULT nextval('public.hr_question_options_id_seq'::regclass);


--
-- Name: hr_questions id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_questions ALTER COLUMN id SET DEFAULT nextval('public.hr_questions_id_seq'::regclass);


--
-- Name: hr_skill_scale_options id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_skill_scale_options ALTER COLUMN id SET DEFAULT nextval('public.hr_skill_scale_options_id_seq'::regclass);


--
-- Name: hr_skills id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_skills ALTER COLUMN id SET DEFAULT nextval('public.hr_skills_id_seq'::regclass);


--
-- Name: jobs id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jobs ALTER COLUMN id SET DEFAULT nextval('public.jobs_id_seq'::regclass);


--
-- Name: level_upgrade_rules id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.level_upgrade_rules ALTER COLUMN id SET DEFAULT nextval('public.level_upgrade_rules_id_seq'::regclass);


--
-- Name: media id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.media ALTER COLUMN id SET DEFAULT nextval('public.media_id_seq'::regclass);


--
-- Name: migrations id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.migrations ALTER COLUMN id SET DEFAULT nextval('public.migrations_id_seq'::regclass);


--
-- Name: node_permissions id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.node_permissions ALTER COLUMN id SET DEFAULT nextval('public.node_permissions_id_seq'::regclass);


--
-- Name: opportunities id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunities ALTER COLUMN id SET DEFAULT nextval('public.opportunities_id_seq'::regclass);


--
-- Name: opportunity_comments id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_comments ALTER COLUMN id SET DEFAULT nextval('public.opportunity_comments_id_seq'::regclass);


--
-- Name: opportunity_contacts id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_contacts ALTER COLUMN id SET DEFAULT nextval('public.opportunity_contacts_id_seq'::regclass);


--
-- Name: opportunity_properties id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_properties ALTER COLUMN id SET DEFAULT nextval('public.opportunity_properties_id_seq'::regclass);


--
-- Name: opportunity_stage_data id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_stage_data ALTER COLUMN id SET DEFAULT nextval('public.opportunity_stage_data_id_seq'::regclass);


--
-- Name: org_contracts id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_contracts ALTER COLUMN id SET DEFAULT nextval('public.org_contracts_id_seq'::regclass);


--
-- Name: org_employees id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_employees ALTER COLUMN id SET DEFAULT nextval('public.org_employees_id_seq'::regclass);


--
-- Name: org_job_histories id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_job_histories ALTER COLUMN id SET DEFAULT nextval('public.org_job_histories_id_seq'::regclass);


--
-- Name: org_job_titles id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_job_titles ALTER COLUMN id SET DEFAULT nextval('public.org_job_titles_id_seq'::regclass);


--
-- Name: org_positions id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_positions ALTER COLUMN id SET DEFAULT nextval('public.org_positions_id_seq'::regclass);


--
-- Name: otps id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.otps ALTER COLUMN id SET DEFAULT nextval('public.otps_id_seq'::regclass);


--
-- Name: permissions id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.permissions ALTER COLUMN id SET DEFAULT nextval('public.permissions_id_seq'::regclass);


--
-- Name: personal_access_tokens id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.personal_access_tokens ALTER COLUMN id SET DEFAULT nextval('public.personal_access_tokens_id_seq'::regclass);


--
-- Name: profile_levels id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profile_levels ALTER COLUMN id SET DEFAULT nextval('public.profile_levels_id_seq'::regclass);


--
-- Name: profile_roles id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profile_roles ALTER COLUMN id SET DEFAULT nextval('public.profile_roles_id_seq'::regclass);


--
-- Name: profiles id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profiles ALTER COLUMN id SET DEFAULT nextval('public.profiles_id_seq'::regclass);


--
-- Name: roles id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.roles ALTER COLUMN id SET DEFAULT nextval('public.roles_id_seq'::regclass);


--
-- Name: stages id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stages ALTER COLUMN id SET DEFAULT nextval('public.stages_id_seq'::regclass);


--
-- Name: system_nodes id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.system_nodes ALTER COLUMN id SET DEFAULT nextval('public.system_nodes_id_seq'::regclass);


--
-- Name: users id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);


--
-- Name: workflow_approvals id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_approvals ALTER COLUMN id SET DEFAULT nextval('public.workflow_approvals_id_seq'::regclass);


--
-- Name: workflow_definitions id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_definitions ALTER COLUMN id SET DEFAULT nextval('public.workflow_definitions_id_seq'::regclass);


--
-- Name: workflow_events id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_events ALTER COLUMN id SET DEFAULT nextval('public.workflow_events_id_seq'::regclass);


--
-- Name: workflow_instance_history id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instance_history ALTER COLUMN id SET DEFAULT nextval('public.workflow_instance_history_id_seq'::regclass);


--
-- Name: workflow_instances id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instances ALTER COLUMN id SET DEFAULT nextval('public.workflow_instances_id_seq'::regclass);


--
-- Name: workflow_nodes id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_nodes ALTER COLUMN id SET DEFAULT nextval('public.workflow_nodes_id_seq'::regclass);


--
-- Name: workflow_schedules id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_schedules ALTER COLUMN id SET DEFAULT nextval('public.workflow_schedules_id_seq'::regclass);


--
-- Name: workflow_transitions id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_transitions ALTER COLUMN id SET DEFAULT nextval('public.workflow_transitions_id_seq'::regclass);


--
-- Name: activity_log activity_log_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.activity_log
    ADD CONSTRAINT activity_log_pkey PRIMARY KEY (id);


--
-- Name: approval_flows approval_flows_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_flows
    ADD CONSTRAINT approval_flows_code_unique UNIQUE (code);


--
-- Name: approval_flows approval_flows_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_flows
    ADD CONSTRAINT approval_flows_pkey PRIMARY KEY (id);


--
-- Name: approval_flows approval_flows_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_flows
    ADD CONSTRAINT approval_flows_uuid_unique UNIQUE (uuid);


--
-- Name: approval_instance_steps approval_instance_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_instance_steps
    ADD CONSTRAINT approval_instance_steps_pkey PRIMARY KEY (id);


--
-- Name: approval_instance_steps approval_instance_steps_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_instance_steps
    ADD CONSTRAINT approval_instance_steps_uuid_unique UNIQUE (uuid);


--
-- Name: approval_instances approval_instances_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_instances
    ADD CONSTRAINT approval_instances_pkey PRIMARY KEY (id);


--
-- Name: approval_instances approval_instances_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_instances
    ADD CONSTRAINT approval_instances_uuid_unique UNIQUE (uuid);


--
-- Name: approval_steps approval_steps_approval_flow_id_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_steps
    ADD CONSTRAINT approval_steps_approval_flow_id_code_unique UNIQUE (approval_flow_id, code);


--
-- Name: approval_steps approval_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_steps
    ADD CONSTRAINT approval_steps_pkey PRIMARY KEY (id);


--
-- Name: approval_steps approval_steps_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_steps
    ADD CONSTRAINT approval_steps_uuid_unique UNIQUE (uuid);


--
-- Name: approvals approvals_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approvals
    ADD CONSTRAINT approvals_pkey PRIMARY KEY (id);


--
-- Name: approvals approvals_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approvals
    ADD CONSTRAINT approvals_uuid_unique UNIQUE (uuid);


--
-- Name: audit_logs audit_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.audit_logs
    ADD CONSTRAINT audit_logs_pkey PRIMARY KEY (id);


--
-- Name: audit_logs audit_logs_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.audit_logs
    ADD CONSTRAINT audit_logs_uuid_unique UNIQUE (uuid);


--
-- Name: cache_locks cache_locks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cache_locks
    ADD CONSTRAINT cache_locks_pkey PRIMARY KEY (key);


--
-- Name: cache cache_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cache
    ADD CONSTRAINT cache_pkey PRIMARY KEY (key);


--
-- Name: configurable_features config_features_unq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.configurable_features
    ADD CONSTRAINT config_features_unq UNIQUE (feature_id, configurable_id, configurable_type);


--
-- Name: configurable_features configurable_features_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.configurable_features
    ADD CONSTRAINT configurable_features_pkey PRIMARY KEY (id);


--
-- Name: department_stage_assignments department_stage_assignments_department_id_stage_id_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.department_stage_assignments
    ADD CONSTRAINT department_stage_assignments_department_id_stage_id_unique UNIQUE (department_id, stage_id);


--
-- Name: department_stage_assignments department_stage_assignments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.department_stage_assignments
    ADD CONSTRAINT department_stage_assignments_pkey PRIMARY KEY (id);


--
-- Name: department_stage_assignments department_stage_assignments_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.department_stage_assignments
    ADD CONSTRAINT department_stage_assignments_uuid_unique UNIQUE (uuid);


--
-- Name: departments departments_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.departments
    ADD CONSTRAINT departments_code_unique UNIQUE (code);


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

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


--
-- Name: departments departments_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.departments
    ADD CONSTRAINT departments_uuid_unique UNIQUE (uuid);


--
-- Name: device_users device_user_unique_link; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.device_users
    ADD CONSTRAINT device_user_unique_link UNIQUE (user_id, device_id);


--
-- Name: device_users device_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.device_users
    ADD CONSTRAINT device_users_pkey PRIMARY KEY (id);


--
-- Name: device_users device_users_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.device_users
    ADD CONSTRAINT device_users_uuid_unique UNIQUE (uuid);


--
-- Name: devices devices_device_hash_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.devices
    ADD CONSTRAINT devices_device_hash_unique UNIQUE (device_hash);


--
-- Name: devices devices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.devices
    ADD CONSTRAINT devices_pkey PRIMARY KEY (id);


--
-- Name: devices devices_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.devices
    ADD CONSTRAINT devices_uuid_unique UNIQUE (uuid);


--
-- Name: failed_jobs failed_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.failed_jobs
    ADD CONSTRAINT failed_jobs_pkey PRIMARY KEY (id);


--
-- Name: failed_jobs failed_jobs_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.failed_jobs
    ADD CONSTRAINT failed_jobs_uuid_unique UNIQUE (uuid);


--
-- Name: features features_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.features
    ADD CONSTRAINT features_pkey PRIMARY KEY (id);


--
-- Name: features features_slug_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.features
    ADD CONSTRAINT features_slug_unique UNIQUE (slug);


--
-- Name: features features_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.features
    ADD CONSTRAINT features_uuid_unique UNIQUE (uuid);


--
-- Name: form_audit_trails form_audit_trails_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.form_audit_trails
    ADD CONSTRAINT form_audit_trails_pkey PRIMARY KEY (id);


--
-- Name: form_blueprints form_blueprints_code_version_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.form_blueprints
    ADD CONSTRAINT form_blueprints_code_version_unique UNIQUE (code, version);


--
-- Name: form_blueprints form_blueprints_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.form_blueprints
    ADD CONSTRAINT form_blueprints_pkey PRIMARY KEY (id);


--
-- Name: form_instances form_instances_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.form_instances
    ADD CONSTRAINT form_instances_pkey PRIMARY KEY (id);


--
-- Name: hr_application_activities hr_application_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_activities
    ADD CONSTRAINT hr_application_activities_pkey PRIMARY KEY (id);


--
-- Name: hr_application_attachments hr_application_attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_attachments
    ADD CONSTRAINT hr_application_attachments_pkey PRIMARY KEY (id);


--
-- Name: hr_application_field_values hr_application_field_values_application_id_field_key_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_field_values
    ADD CONSTRAINT hr_application_field_values_application_id_field_key_unique UNIQUE (application_id, field_key);


--
-- Name: hr_application_field_values hr_application_field_values_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_field_values
    ADD CONSTRAINT hr_application_field_values_pkey PRIMARY KEY (id);


--
-- Name: hr_application_question_answers hr_application_question_answers_application_id_question_id_uniq; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_question_answers
    ADD CONSTRAINT hr_application_question_answers_application_id_question_id_uniq UNIQUE (application_id, question_id);


--
-- Name: hr_application_question_answers hr_application_question_answers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_question_answers
    ADD CONSTRAINT hr_application_question_answers_pkey PRIMARY KEY (id);


--
-- Name: hr_application_skill_ratings hr_application_skill_ratings_application_id_skill_id_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_skill_ratings
    ADD CONSTRAINT hr_application_skill_ratings_application_id_skill_id_unique UNIQUE (application_id, skill_id);


--
-- Name: hr_application_skill_ratings hr_application_skill_ratings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_skill_ratings
    ADD CONSTRAINT hr_application_skill_ratings_pkey PRIMARY KEY (id);


--
-- Name: hr_application_statuses hr_application_statuses_key_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_statuses
    ADD CONSTRAINT hr_application_statuses_key_unique UNIQUE (key);


--
-- Name: hr_application_statuses hr_application_statuses_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_statuses
    ADD CONSTRAINT hr_application_statuses_pkey PRIMARY KEY (id);


--
-- Name: hr_applications hr_applications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_applications
    ADD CONSTRAINT hr_applications_pkey PRIMARY KEY (id);


--
-- Name: hr_filter_groups hr_filter_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_filter_groups
    ADD CONSTRAINT hr_filter_groups_pkey PRIMARY KEY (id);


--
-- Name: hr_filter_groups hr_filter_groups_scope_key_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_filter_groups
    ADD CONSTRAINT hr_filter_groups_scope_key_unique UNIQUE (scope, key);


--
-- Name: hr_filter_options hr_filter_options_group_id_key_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_filter_options
    ADD CONSTRAINT hr_filter_options_group_id_key_unique UNIQUE (group_id, key);


--
-- Name: hr_filter_options hr_filter_options_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_filter_options
    ADD CONSTRAINT hr_filter_options_pkey PRIMARY KEY (id);


--
-- Name: hr_job_form_field_options hr_job_form_field_options_field_id_value_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_field_options
    ADD CONSTRAINT hr_job_form_field_options_field_id_value_unique UNIQUE (field_id, value);


--
-- Name: hr_job_form_field_options hr_job_form_field_options_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_field_options
    ADD CONSTRAINT hr_job_form_field_options_pkey PRIMARY KEY (id);


--
-- Name: hr_job_form_fields hr_job_form_fields_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_fields
    ADD CONSTRAINT hr_job_form_fields_pkey PRIMARY KEY (id);


--
-- Name: hr_job_form_groups hr_job_form_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_groups
    ADD CONSTRAINT hr_job_form_groups_pkey PRIMARY KEY (id);


--
-- Name: hr_job_form_sections hr_job_form_sections_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_sections
    ADD CONSTRAINT hr_job_form_sections_pkey PRIMARY KEY (id);


--
-- Name: hr_job_questions hr_job_questions_job_id_question_id_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_questions
    ADD CONSTRAINT hr_job_questions_job_id_question_id_unique UNIQUE (job_id, question_id);


--
-- Name: hr_job_questions hr_job_questions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_questions
    ADD CONSTRAINT hr_job_questions_pkey PRIMARY KEY (id);


--
-- Name: hr_job_rules hr_job_rules_job_id_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_rules
    ADD CONSTRAINT hr_job_rules_job_id_unique UNIQUE (job_id);


--
-- Name: hr_job_rules hr_job_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_rules
    ADD CONSTRAINT hr_job_rules_pkey PRIMARY KEY (id);


--
-- Name: hr_job_skill_requirements hr_job_skill_requirements_job_id_skill_id_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_skill_requirements
    ADD CONSTRAINT hr_job_skill_requirements_job_id_skill_id_unique UNIQUE (job_id, skill_id);


--
-- Name: hr_job_skill_requirements hr_job_skill_requirements_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_skill_requirements
    ADD CONSTRAINT hr_job_skill_requirements_pkey PRIMARY KEY (id);


--
-- Name: hr_jobs hr_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_jobs
    ADD CONSTRAINT hr_jobs_pkey PRIMARY KEY (id);


--
-- Name: hr_question_options hr_question_options_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_question_options
    ADD CONSTRAINT hr_question_options_pkey PRIMARY KEY (id);


--
-- Name: hr_question_options hr_question_options_question_id_value_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_question_options
    ADD CONSTRAINT hr_question_options_question_id_value_unique UNIQUE (question_id, value);


--
-- Name: hr_questions hr_questions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_questions
    ADD CONSTRAINT hr_questions_pkey PRIMARY KEY (id);


--
-- Name: hr_skill_scale_options hr_skill_scale_options_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_skill_scale_options
    ADD CONSTRAINT hr_skill_scale_options_pkey PRIMARY KEY (id);


--
-- Name: hr_skill_scale_options hr_skill_scale_options_skill_id_value_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_skill_scale_options
    ADD CONSTRAINT hr_skill_scale_options_skill_id_value_unique UNIQUE (skill_id, value);


--
-- Name: hr_skills hr_skills_name_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_skills
    ADD CONSTRAINT hr_skills_name_unique UNIQUE (name);


--
-- Name: hr_skills hr_skills_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_skills
    ADD CONSTRAINT hr_skills_pkey PRIMARY KEY (id);


--
-- Name: job_batches job_batches_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.job_batches
    ADD CONSTRAINT job_batches_pkey PRIMARY KEY (id);


--
-- Name: jobs jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jobs
    ADD CONSTRAINT jobs_pkey PRIMARY KEY (id);


--
-- Name: level_upgrade_rules level_upgrade_rules_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.level_upgrade_rules
    ADD CONSTRAINT level_upgrade_rules_pkey PRIMARY KEY (id);


--
-- Name: level_upgrade_rules level_upgrade_rules_unique_constraint; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.level_upgrade_rules
    ADD CONSTRAINT level_upgrade_rules_unique_constraint UNIQUE (from_level_id, to_level_id, for_role_id, metric_key, duration_days);


--
-- Name: media media_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.media
    ADD CONSTRAINT media_pkey PRIMARY KEY (id);


--
-- Name: media media_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.media
    ADD CONSTRAINT media_uuid_unique UNIQUE (uuid);


--
-- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.migrations
    ADD CONSTRAINT migrations_pkey PRIMARY KEY (id);


--
-- Name: model_has_permissions model_has_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.model_has_permissions
    ADD CONSTRAINT model_has_permissions_pkey PRIMARY KEY (permission_id, model_id, model_type);


--
-- Name: model_has_roles model_has_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.model_has_roles
    ADD CONSTRAINT model_has_roles_pkey PRIMARY KEY (role_id, model_id, model_type);


--
-- Name: node_permissions node_permissions_node_id_permission_id_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.node_permissions
    ADD CONSTRAINT node_permissions_node_id_permission_id_unique UNIQUE (node_id, permission_id);


--
-- Name: node_permissions node_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.node_permissions
    ADD CONSTRAINT node_permissions_pkey PRIMARY KEY (id);


--
-- Name: opportunities opportunities_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunities
    ADD CONSTRAINT opportunities_pkey PRIMARY KEY (id);


--
-- Name: opportunities opportunities_reference_number_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunities
    ADD CONSTRAINT opportunities_reference_number_unique UNIQUE (reference_number);


--
-- Name: opportunities opportunities_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunities
    ADD CONSTRAINT opportunities_uuid_unique UNIQUE (uuid);


--
-- Name: opportunity_comments opportunity_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_comments
    ADD CONSTRAINT opportunity_comments_pkey PRIMARY KEY (id);


--
-- Name: opportunity_comments opportunity_comments_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_comments
    ADD CONSTRAINT opportunity_comments_uuid_unique UNIQUE (uuid);


--
-- Name: opportunity_contacts opportunity_contacts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_contacts
    ADD CONSTRAINT opportunity_contacts_pkey PRIMARY KEY (id);


--
-- Name: opportunity_contacts opportunity_contacts_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_contacts
    ADD CONSTRAINT opportunity_contacts_uuid_unique UNIQUE (uuid);


--
-- Name: opportunity_properties opportunity_properties_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_properties
    ADD CONSTRAINT opportunity_properties_pkey PRIMARY KEY (id);


--
-- Name: opportunity_properties opportunity_properties_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_properties
    ADD CONSTRAINT opportunity_properties_uuid_unique UNIQUE (uuid);


--
-- Name: opportunity_stage_data opportunity_stage_data_opportunity_id_stage_id_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_stage_data
    ADD CONSTRAINT opportunity_stage_data_opportunity_id_stage_id_unique UNIQUE (opportunity_id, stage_id);


--
-- Name: opportunity_stage_data opportunity_stage_data_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_stage_data
    ADD CONSTRAINT opportunity_stage_data_pkey PRIMARY KEY (id);


--
-- Name: opportunity_stage_data opportunity_stage_data_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_stage_data
    ADD CONSTRAINT opportunity_stage_data_uuid_unique UNIQUE (uuid);


--
-- Name: org_contracts org_contracts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_contracts
    ADD CONSTRAINT org_contracts_pkey PRIMARY KEY (id);


--
-- Name: org_contracts org_contracts_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_contracts
    ADD CONSTRAINT org_contracts_uuid_unique UNIQUE (uuid);


--
-- Name: org_employees org_employees_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_employees
    ADD CONSTRAINT org_employees_code_unique UNIQUE (code);


--
-- Name: org_employees org_employees_email_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_employees
    ADD CONSTRAINT org_employees_email_unique UNIQUE (email);


--
-- Name: org_employees org_employees_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_employees
    ADD CONSTRAINT org_employees_pkey PRIMARY KEY (id);


--
-- Name: org_employees org_employees_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_employees
    ADD CONSTRAINT org_employees_uuid_unique UNIQUE (uuid);


--
-- Name: org_job_histories org_job_histories_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_job_histories
    ADD CONSTRAINT org_job_histories_pkey PRIMARY KEY (id);


--
-- Name: org_job_histories org_job_histories_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_job_histories
    ADD CONSTRAINT org_job_histories_uuid_unique UNIQUE (uuid);


--
-- Name: org_job_titles org_job_titles_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_job_titles
    ADD CONSTRAINT org_job_titles_code_unique UNIQUE (code);


--
-- Name: org_job_titles org_job_titles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_job_titles
    ADD CONSTRAINT org_job_titles_pkey PRIMARY KEY (id);


--
-- Name: org_job_titles org_job_titles_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_job_titles
    ADD CONSTRAINT org_job_titles_uuid_unique UNIQUE (uuid);


--
-- Name: org_positions org_positions_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_positions
    ADD CONSTRAINT org_positions_code_unique UNIQUE (code);


--
-- Name: org_positions org_positions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_positions
    ADD CONSTRAINT org_positions_pkey PRIMARY KEY (id);


--
-- Name: org_positions org_positions_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_positions
    ADD CONSTRAINT org_positions_uuid_unique UNIQUE (uuid);


--
-- Name: otps otps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.otps
    ADD CONSTRAINT otps_pkey PRIMARY KEY (id);


--
-- Name: otps otps_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.otps
    ADD CONSTRAINT otps_uuid_unique UNIQUE (uuid);


--
-- Name: password_reset_tokens password_reset_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.password_reset_tokens
    ADD CONSTRAINT password_reset_tokens_pkey PRIMARY KEY (email);


--
-- Name: permissions permissions_name_guard_name_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.permissions
    ADD CONSTRAINT permissions_name_guard_name_unique UNIQUE (name, guard_name);


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

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


--
-- Name: permissions permissions_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.permissions
    ADD CONSTRAINT permissions_uuid_unique UNIQUE (uuid);


--
-- Name: personal_access_tokens personal_access_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.personal_access_tokens
    ADD CONSTRAINT personal_access_tokens_pkey PRIMARY KEY (id);


--
-- Name: personal_access_tokens personal_access_tokens_token_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.personal_access_tokens
    ADD CONSTRAINT personal_access_tokens_token_unique UNIQUE (token);


--
-- Name: profile_completion_weights profile_completion_weights_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profile_completion_weights
    ADD CONSTRAINT profile_completion_weights_pkey PRIMARY KEY (key);


--
-- Name: profile_levels profile_levels_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profile_levels
    ADD CONSTRAINT profile_levels_pkey PRIMARY KEY (id);


--
-- Name: profile_levels profile_levels_slug_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profile_levels
    ADD CONSTRAINT profile_levels_slug_unique UNIQUE (slug);


--
-- Name: profile_levels profile_levels_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profile_levels
    ADD CONSTRAINT profile_levels_uuid_unique UNIQUE (uuid);


--
-- Name: profile_roles profile_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profile_roles
    ADD CONSTRAINT profile_roles_pkey PRIMARY KEY (id);


--
-- Name: profile_roles profile_roles_slug_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profile_roles
    ADD CONSTRAINT profile_roles_slug_unique UNIQUE (slug);


--
-- Name: profile_roles profile_roles_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profile_roles
    ADD CONSTRAINT profile_roles_uuid_unique UNIQUE (uuid);


--
-- Name: profiles profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profiles
    ADD CONSTRAINT profiles_pkey PRIMARY KEY (id);


--
-- Name: profiles profiles_profile_slug_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profiles
    ADD CONSTRAINT profiles_profile_slug_unique UNIQUE (profile_slug);


--
-- Name: profiles profiles_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profiles
    ADD CONSTRAINT profiles_uuid_unique UNIQUE (uuid);


--
-- Name: role_has_permissions role_has_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.role_has_permissions
    ADD CONSTRAINT role_has_permissions_pkey PRIMARY KEY (permission_id, role_id);


--
-- Name: roles roles_name_guard_name_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.roles
    ADD CONSTRAINT roles_name_guard_name_unique UNIQUE (name, guard_name);


--
-- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.roles
    ADD CONSTRAINT roles_pkey PRIMARY KEY (id);


--
-- Name: roles roles_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.roles
    ADD CONSTRAINT roles_uuid_unique UNIQUE (uuid);


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

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


--
-- Name: stages stages_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stages
    ADD CONSTRAINT stages_code_unique UNIQUE (code);


--
-- Name: stages stages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stages
    ADD CONSTRAINT stages_pkey PRIMARY KEY (id);


--
-- Name: stages stages_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.stages
    ADD CONSTRAINT stages_uuid_unique UNIQUE (uuid);


--
-- Name: system_nodes system_nodes_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.system_nodes
    ADD CONSTRAINT system_nodes_code_unique UNIQUE (code);


--
-- Name: system_nodes system_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.system_nodes
    ADD CONSTRAINT system_nodes_pkey PRIMARY KEY (id);


--
-- Name: system_nodes system_nodes_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.system_nodes
    ADD CONSTRAINT system_nodes_uuid_unique UNIQUE (uuid);


--
-- Name: users users_email_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_email_unique UNIQUE (email);


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

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


--
-- Name: users users_username_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_username_unique UNIQUE (username);


--
-- Name: users users_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_uuid_unique UNIQUE (uuid);


--
-- Name: workflow_approvals workflow_approvals_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_approvals
    ADD CONSTRAINT workflow_approvals_pkey PRIMARY KEY (id);


--
-- Name: workflow_approvals workflow_approvals_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_approvals
    ADD CONSTRAINT workflow_approvals_uuid_unique UNIQUE (uuid);


--
-- Name: workflow_definitions workflow_definitions_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_definitions
    ADD CONSTRAINT workflow_definitions_code_unique UNIQUE (code);


--
-- Name: workflow_definitions workflow_definitions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_definitions
    ADD CONSTRAINT workflow_definitions_pkey PRIMARY KEY (id);


--
-- Name: workflow_definitions workflow_definitions_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_definitions
    ADD CONSTRAINT workflow_definitions_uuid_unique UNIQUE (uuid);


--
-- Name: workflow_events workflow_events_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_events
    ADD CONSTRAINT workflow_events_pkey PRIMARY KEY (id);


--
-- Name: workflow_events workflow_events_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_events
    ADD CONSTRAINT workflow_events_uuid_unique UNIQUE (uuid);


--
-- Name: workflow_instance_history workflow_instance_history_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instance_history
    ADD CONSTRAINT workflow_instance_history_pkey PRIMARY KEY (id);


--
-- Name: workflow_instance_history workflow_instance_history_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instance_history
    ADD CONSTRAINT workflow_instance_history_uuid_unique UNIQUE (uuid);


--
-- Name: workflow_instances workflow_instances_entity_type_entity_id_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instances
    ADD CONSTRAINT workflow_instances_entity_type_entity_id_unique UNIQUE (entity_type, entity_id);


--
-- Name: workflow_instances workflow_instances_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instances
    ADD CONSTRAINT workflow_instances_pkey PRIMARY KEY (id);


--
-- Name: workflow_instances workflow_instances_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instances
    ADD CONSTRAINT workflow_instances_uuid_unique UNIQUE (uuid);


--
-- Name: workflow_nodes workflow_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_nodes
    ADD CONSTRAINT workflow_nodes_pkey PRIMARY KEY (id);


--
-- Name: workflow_nodes workflow_nodes_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_nodes
    ADD CONSTRAINT workflow_nodes_uuid_unique UNIQUE (uuid);


--
-- Name: workflow_nodes workflow_nodes_workflow_definition_id_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_nodes
    ADD CONSTRAINT workflow_nodes_workflow_definition_id_code_unique UNIQUE (workflow_definition_id, code);


--
-- Name: workflow_schedules workflow_schedules_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_schedules
    ADD CONSTRAINT workflow_schedules_pkey PRIMARY KEY (id);


--
-- Name: workflow_schedules workflow_schedules_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_schedules
    ADD CONSTRAINT workflow_schedules_uuid_unique UNIQUE (uuid);


--
-- Name: workflow_transitions workflow_transitions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_transitions
    ADD CONSTRAINT workflow_transitions_pkey PRIMARY KEY (id);


--
-- Name: workflow_transitions workflow_transitions_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_transitions
    ADD CONSTRAINT workflow_transitions_uuid_unique UNIQUE (uuid);


--
-- Name: workflow_transitions workflow_transitions_workflow_definition_id_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_transitions
    ADD CONSTRAINT workflow_transitions_workflow_definition_id_code_unique UNIQUE (workflow_definition_id, code);


--
-- Name: activity_log_log_name_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX activity_log_log_name_index ON public.activity_log USING btree (log_name);


--
-- Name: approval_flows_model_type_run_on_is_active_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_flows_model_type_run_on_is_active_index ON public.approval_flows USING btree (model_type, run_on, is_active);


--
-- Name: approval_flows_run_on_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_flows_run_on_status_index ON public.approval_flows USING btree (run_on_status);


--
-- Name: approval_instance_steps_approval_flow_id_approval_step_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instance_steps_approval_flow_id_approval_step_id_index ON public.approval_instance_steps USING btree (approval_flow_id, approval_step_id);


--
-- Name: approval_instance_steps_approval_instance_id_code_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instance_steps_approval_instance_id_code_index ON public.approval_instance_steps USING btree (approval_instance_id, code);


--
-- Name: approval_instance_steps_approval_step_id_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instance_steps_approval_step_id_status_index ON public.approval_instance_steps USING btree (approval_step_id, status);


--
-- Name: approval_instance_steps_approver_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instance_steps_approver_id_index ON public.approval_instance_steps USING btree (approver_id);


--
-- Name: approval_instance_steps_approver_id_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instance_steps_approver_id_status_index ON public.approval_instance_steps USING btree (approver_id, status);


--
-- Name: approval_instance_steps_approver_role_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instance_steps_approver_role_index ON public.approval_instance_steps USING btree (approver_role);


--
-- Name: approval_instance_steps_created_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instance_steps_created_at_index ON public.approval_instance_steps USING btree (created_at);


--
-- Name: approval_instances_approvable_type_approvable_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instances_approvable_type_approvable_id_index ON public.approval_instances USING btree (approvable_type, approvable_id);


--
-- Name: approval_instances_approval_flow_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instances_approval_flow_id_index ON public.approval_instances USING btree (approval_flow_id);


--
-- Name: approval_instances_approval_flow_id_is_completed_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instances_approval_flow_id_is_completed_index ON public.approval_instances USING btree (approval_flow_id, is_completed);


--
-- Name: approval_instances_code_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instances_code_index ON public.approval_instances USING btree (code);


--
-- Name: approval_instances_created_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instances_created_at_index ON public.approval_instances USING btree (created_at);


--
-- Name: approval_instances_current_step_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instances_current_step_id_index ON public.approval_instances USING btree (current_step_id);


--
-- Name: approval_instances_next_step_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_instances_next_step_id_index ON public.approval_instances USING btree (next_step_id);


--
-- Name: approval_steps_approval_flow_id_step_order_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_steps_approval_flow_id_step_order_index ON public.approval_steps USING btree (approval_flow_id, step_order);


--
-- Name: approval_steps_approver_role_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_steps_approver_role_index ON public.approval_steps USING btree (approver_role);


--
-- Name: approval_steps_approver_user_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approval_steps_approver_user_id_index ON public.approval_steps USING btree (approver_user_id);


--
-- Name: approvals_approvable_type_approvable_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approvals_approvable_type_approvable_id_index ON public.approvals USING btree (approvable_type, approvable_id);


--
-- Name: approvals_approvable_type_approvable_id_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approvals_approvable_type_approvable_id_status_index ON public.approvals USING btree (approvable_type, approvable_id, status);


--
-- Name: approvals_approval_step_id_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approvals_approval_step_id_status_index ON public.approvals USING btree (approval_step_id, status);


--
-- Name: approvals_approver_id_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approvals_approver_id_status_index ON public.approvals USING btree (approver_id, status);


--
-- Name: approvals_created_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX approvals_created_at_index ON public.approvals USING btree (created_at);


--
-- Name: audit_logs_actor_device_uuid_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX audit_logs_actor_device_uuid_index ON public.audit_logs USING btree (actor_device_uuid);


--
-- Name: audit_logs_actor_user_uuid_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX audit_logs_actor_user_uuid_index ON public.audit_logs USING btree (actor_user_uuid);


--
-- Name: audit_logs_target_entity_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX audit_logs_target_entity_id_index ON public.audit_logs USING btree (target_entity_id);


--
-- Name: audit_logs_target_entity_type_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX audit_logs_target_entity_type_index ON public.audit_logs USING btree (target_entity_type);


--
-- Name: audit_logs_target_entity_uuid_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX audit_logs_target_entity_uuid_index ON public.audit_logs USING btree (target_entity_uuid);


--
-- Name: audit_logs_trace_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX audit_logs_trace_id_index ON public.audit_logs USING btree (trace_id);


--
-- Name: causer; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX causer ON public.activity_log USING btree (causer_type, causer_id);


--
-- Name: configurable_features_configurable_type_configurable_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX configurable_features_configurable_type_configurable_id_index ON public.configurable_features USING btree (configurable_type, configurable_id);


--
-- Name: department_stage_assignments_config_gin_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX department_stage_assignments_config_gin_idx ON public.department_stage_assignments USING gin (assignment_config);


--
-- Name: department_stage_assignments_department_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX department_stage_assignments_department_id_index ON public.department_stage_assignments USING btree (department_id);


--
-- Name: department_stage_assignments_stage_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX department_stage_assignments_stage_id_index ON public.department_stage_assignments USING btree (stage_id);


--
-- Name: departments_code_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX departments_code_index ON public.departments USING btree (code);


--
-- Name: departments_is_active_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX departments_is_active_index ON public.departments USING btree (is_active);


--
-- Name: departments_settings_gin_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX departments_settings_gin_idx ON public.departments USING gin (settings);


--
-- Name: device_users_link_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX device_users_link_status_index ON public.device_users USING btree (link_status);


--
-- Name: devices_device_hash_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX devices_device_hash_index ON public.devices USING btree (device_hash);


--
-- Name: devices_platform_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX devices_platform_index ON public.devices USING btree (platform);


--
-- Name: devices_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX devices_status_index ON public.devices USING btree (status);


--
-- Name: form_blueprints_code_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX form_blueprints_code_index ON public.form_blueprints USING btree (code);


--
-- Name: form_instances_entity_type_entity_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX form_instances_entity_type_entity_id_index ON public.form_instances USING btree (entity_type, entity_id);


--
-- Name: hr_application_activities_application_id_created_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_application_activities_application_id_created_at_index ON public.hr_application_activities USING btree (application_id, created_at);


--
-- Name: hr_application_attachments_application_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_application_attachments_application_id_index ON public.hr_application_attachments USING btree (application_id);


--
-- Name: hr_application_attachments_field_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_application_attachments_field_id_index ON public.hr_application_attachments USING btree (field_id);


--
-- Name: hr_application_field_values_application_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_application_field_values_application_id_index ON public.hr_application_field_values USING btree (application_id);


--
-- Name: hr_application_field_values_field_key_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_application_field_values_field_key_index ON public.hr_application_field_values USING btree (field_key);


--
-- Name: hr_application_question_answers_application_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_application_question_answers_application_id_index ON public.hr_application_question_answers USING btree (application_id);


--
-- Name: hr_application_skill_ratings_application_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_application_skill_ratings_application_id_index ON public.hr_application_skill_ratings USING btree (application_id);


--
-- Name: hr_applications_applicant_email_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_applications_applicant_email_index ON public.hr_applications USING btree (applicant_email);


--
-- Name: hr_applications_job_id_submitted_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_applications_job_id_submitted_at_index ON public.hr_applications USING btree (job_id, submitted_at);


--
-- Name: hr_applications_status_submitted_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_applications_status_submitted_at_index ON public.hr_applications USING btree (status, submitted_at);


--
-- Name: hr_filter_groups_scope_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_filter_groups_scope_index ON public.hr_filter_groups USING btree (scope);


--
-- Name: hr_filter_options_group_id_parent_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_filter_options_group_id_parent_id_index ON public.hr_filter_options USING btree (group_id, parent_id);


--
-- Name: hr_job_form_field_options_field_id_sort_order_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_job_form_field_options_field_id_sort_order_index ON public.hr_job_form_field_options USING btree (field_id, sort_order);


--
-- Name: hr_job_form_fields_visible_when_key_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_job_form_fields_visible_when_key_index ON public.hr_job_form_fields USING btree (visible_when_key);


--
-- Name: hr_job_form_groups_section_id_sort_order_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_job_form_groups_section_id_sort_order_index ON public.hr_job_form_groups USING btree (section_id, sort_order);


--
-- Name: hr_job_form_sections_job_id_sort_order_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_job_form_sections_job_id_sort_order_index ON public.hr_job_form_sections USING btree (job_id, sort_order);


--
-- Name: hr_job_questions_job_id_sort_order_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_job_questions_job_id_sort_order_index ON public.hr_job_questions USING btree (job_id, sort_order);


--
-- Name: hr_job_skill_requirements_job_id_sort_order_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_job_skill_requirements_job_id_sort_order_index ON public.hr_job_skill_requirements USING btree (job_id, sort_order);


--
-- Name: hr_jobs_is_draft_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_jobs_is_draft_index ON public.hr_jobs USING btree (is_draft);


--
-- Name: hr_jobs_is_template_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_jobs_is_template_index ON public.hr_jobs USING btree (is_template);


--
-- Name: hr_jobs_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_jobs_status_index ON public.hr_jobs USING btree (status);


--
-- Name: hr_jobs_title_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_jobs_title_index ON public.hr_jobs USING btree (title_ar);


--
-- Name: hr_question_options_question_id_sort_order_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_question_options_question_id_sort_order_index ON public.hr_question_options USING btree (question_id, sort_order);


--
-- Name: hr_skill_scale_options_skill_id_sort_order_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_skill_scale_options_skill_id_sort_order_index ON public.hr_skill_scale_options USING btree (skill_id, sort_order);


--
-- Name: hr_skills_category_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hr_skills_category_index ON public.hr_skills USING btree (category);


--
-- Name: jobs_queue_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jobs_queue_index ON public.jobs USING btree (queue);


--
-- Name: level_upgrade_rules_metric_key_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX level_upgrade_rules_metric_key_index ON public.level_upgrade_rules USING btree (metric_key);


--
-- Name: media_model_type_model_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX media_model_type_model_id_index ON public.media USING btree (model_type, model_id);


--
-- Name: media_order_column_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX media_order_column_index ON public.media USING btree (order_column);


--
-- Name: model_has_permissions_model_id_model_type_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX model_has_permissions_model_id_model_type_index ON public.model_has_permissions USING btree (model_id, model_type);


--
-- Name: model_has_roles_model_id_model_type_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX model_has_roles_model_id_model_type_index ON public.model_has_roles USING btree (model_id, model_type);


--
-- Name: node_permissions_is_inherited_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX node_permissions_is_inherited_index ON public.node_permissions USING btree (is_inherited);


--
-- Name: opportunities_basic_data_gin_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_basic_data_gin_idx ON public.opportunities USING gin (basic_data);


--
-- Name: opportunities_city_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_city_index ON public.opportunities USING btree (city);


--
-- Name: opportunities_created_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_created_at_index ON public.opportunities USING btree (created_at);


--
-- Name: opportunities_current_stage_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_current_stage_id_index ON public.opportunities USING btree (current_stage_id);


--
-- Name: opportunities_current_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_current_status_index ON public.opportunities USING btree (current_status);


--
-- Name: opportunities_lat_long_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_lat_long_idx ON public.opportunities USING btree (latitude, longitude);


--
-- Name: opportunities_name_fulltext_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_name_fulltext_idx ON public.opportunities USING gin (to_tsvector('arabic'::regconfig, (name)::text));


--
-- Name: opportunities_owner_user_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_owner_user_id_index ON public.opportunities USING btree (owner_user_id);


--
-- Name: opportunities_priority_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_priority_index ON public.opportunities USING btree (priority);


--
-- Name: opportunities_rejected_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_rejected_at_index ON public.opportunities USING btree (rejected_at);


--
-- Name: opportunities_reminder_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_reminder_at_index ON public.opportunities USING btree (reminder_at);


--
-- Name: opportunities_type_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunities_type_index ON public.opportunities USING btree (type);


--
-- Name: opportunity_comments_author_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunity_comments_author_id_index ON public.opportunity_comments USING btree (author_id);


--
-- Name: opportunity_comments_content_fulltext_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunity_comments_content_fulltext_idx ON public.opportunity_comments USING gin (to_tsvector('arabic'::regconfig, content));


--
-- Name: opportunity_comments_opportunity_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunity_comments_opportunity_id_index ON public.opportunity_comments USING btree (opportunity_id);


--
-- Name: opportunity_comments_parent_comment_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunity_comments_parent_comment_id_index ON public.opportunity_comments USING btree (parent_comment_id);


--
-- Name: opportunity_comments_stage_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunity_comments_stage_id_index ON public.opportunity_comments USING btree (stage_id);


--
-- Name: opportunity_stage_data_completed_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunity_stage_data_completed_at_index ON public.opportunity_stage_data USING btree (completed_at);


--
-- Name: opportunity_stage_data_data_gin_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunity_stage_data_data_gin_idx ON public.opportunity_stage_data USING gin (data);


--
-- Name: opportunity_stage_data_opportunity_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunity_stage_data_opportunity_id_index ON public.opportunity_stage_data USING btree (opportunity_id);


--
-- Name: opportunity_stage_data_stage_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunity_stage_data_stage_id_index ON public.opportunity_stage_data USING btree (stage_id);


--
-- Name: opportunity_stage_data_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunity_stage_data_status_index ON public.opportunity_stage_data USING btree (status);


--
-- Name: opportunity_stage_data_updated_by_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX opportunity_stage_data_updated_by_index ON public.opportunity_stage_data USING btree (updated_by);


--
-- Name: otps_expires_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX otps_expires_at_index ON public.otps USING btree (expires_at);


--
-- Name: otps_verifiable_id_verifiable_type_channel_code_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX otps_verifiable_id_verifiable_type_channel_code_index ON public.otps USING btree (verifiable_id, verifiable_type, channel, code);


--
-- Name: otps_verifiable_id_verifiable_type_channel_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX otps_verifiable_id_verifiable_type_channel_index ON public.otps USING btree (verifiable_id, verifiable_type, channel);


--
-- Name: otps_verifiable_type_verifiable_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX otps_verifiable_type_verifiable_id_index ON public.otps USING btree (verifiable_type, verifiable_id);


--
-- Name: otps_verified_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX otps_verified_at_index ON public.otps USING btree (verified_at);


--
-- Name: personal_access_tokens_tokenable_type_tokenable_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX personal_access_tokens_tokenable_type_tokenable_id_index ON public.personal_access_tokens USING btree (tokenable_type, tokenable_id);


--
-- Name: profile_levels_rank_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX profile_levels_rank_index ON public.profile_levels USING btree (rank);


--
-- Name: profiles_completion_percentage_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX profiles_completion_percentage_index ON public.profiles USING btree (completion_percentage);


--
-- Name: profiles_profilable_type_profilable_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX profiles_profilable_type_profilable_id_index ON public.profiles USING btree (profilable_type, profilable_id);


--
-- Name: profiles_profile_name_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX profiles_profile_name_index ON public.profiles USING btree (profile_name);


--
-- Name: profiles_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX profiles_status_index ON public.profiles USING btree (status);


--
-- Name: sessions_last_activity_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX sessions_last_activity_index ON public.sessions USING btree (last_activity);


--
-- Name: sessions_user_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX sessions_user_id_index ON public.sessions USING btree (user_id);


--
-- Name: stages_code_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX stages_code_index ON public.stages USING btree (code);


--
-- Name: stages_config_gin_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX stages_config_gin_idx ON public.stages USING gin (config);


--
-- Name: stages_is_active_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX stages_is_active_index ON public.stages USING btree (is_active);


--
-- Name: stages_sort_order_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX stages_sort_order_index ON public.stages USING btree (sort_order);


--
-- Name: subject; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX subject ON public.activity_log USING btree (subject_type, subject_id);


--
-- Name: system_nodes_code_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX system_nodes_code_index ON public.system_nodes USING btree (code);


--
-- Name: system_nodes_is_active_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX system_nodes_is_active_index ON public.system_nodes USING btree (is_active);


--
-- Name: system_nodes_parent_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX system_nodes_parent_id_index ON public.system_nodes USING btree (parent_id);


--
-- Name: system_nodes_parent_id_position_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX system_nodes_parent_id_position_index ON public.system_nodes USING btree (parent_id, "position");


--
-- Name: system_nodes_path_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX system_nodes_path_index ON public.system_nodes USING btree (path);


--
-- Name: system_nodes_position_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX system_nodes_position_index ON public.system_nodes USING btree ("position");


--
-- Name: system_nodes_type_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX system_nodes_type_index ON public.system_nodes USING btree (type);


--
-- Name: users_country_code_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX users_country_code_index ON public.users USING btree (country_code);


--
-- Name: users_phone_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX users_phone_index ON public.users USING btree (phone);


--
-- Name: users_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX users_status_index ON public.users USING btree (status);


--
-- Name: workflow_approvals_approver_user_id_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_approvals_approver_user_id_status_index ON public.workflow_approvals USING btree (approver_user_id, status);


--
-- Name: workflow_approvals_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_approvals_status_index ON public.workflow_approvals USING btree (status);


--
-- Name: workflow_approvals_workflow_instance_id_workflow_node_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_approvals_workflow_instance_id_workflow_node_id_index ON public.workflow_approvals USING btree (workflow_instance_id, workflow_node_id);


--
-- Name: workflow_definitions_code_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_definitions_code_index ON public.workflow_definitions USING btree (code);


--
-- Name: workflow_definitions_entity_type_is_active_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_definitions_entity_type_is_active_index ON public.workflow_definitions USING btree (entity_type, is_active);


--
-- Name: workflow_definitions_entity_type_is_default_for_entity_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_definitions_entity_type_is_default_for_entity_index ON public.workflow_definitions USING btree (entity_type, is_default_for_entity);


--
-- Name: workflow_events_created_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_events_created_at_index ON public.workflow_events USING btree (created_at);


--
-- Name: workflow_events_severity_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_events_severity_index ON public.workflow_events USING btree (severity);


--
-- Name: workflow_events_workflow_instance_id_event_type_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_events_workflow_instance_id_event_type_index ON public.workflow_events USING btree (workflow_instance_id, event_type);


--
-- Name: workflow_instance_history_action_type_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_instance_history_action_type_index ON public.workflow_instance_history USING btree (action_type);


--
-- Name: workflow_instance_history_performed_by_user_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_instance_history_performed_by_user_id_index ON public.workflow_instance_history USING btree (performed_by_user_id);


--
-- Name: workflow_instance_history_workflow_instance_id_created_at_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_instance_history_workflow_instance_id_created_at_index ON public.workflow_instance_history USING btree (workflow_instance_id, created_at);


--
-- Name: workflow_instances_current_assignee_user_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_instances_current_assignee_user_id_index ON public.workflow_instances USING btree (current_assignee_user_id);


--
-- Name: workflow_instances_current_node_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_instances_current_node_id_index ON public.workflow_instances USING btree (current_node_id);


--
-- Name: workflow_instances_status_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_instances_status_index ON public.workflow_instances USING btree (status);


--
-- Name: workflow_nodes_workflow_definition_id_node_type_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_nodes_workflow_definition_id_node_type_index ON public.workflow_nodes USING btree (workflow_definition_id, node_type);


--
-- Name: workflow_nodes_workflow_definition_id_sort_order_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_nodes_workflow_definition_id_sort_order_index ON public.workflow_nodes USING btree (workflow_definition_id, sort_order);


--
-- Name: workflow_schedules_next_run_at_is_active_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_schedules_next_run_at_is_active_index ON public.workflow_schedules USING btree (next_run_at, is_active);


--
-- Name: workflow_transitions_from_node_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_transitions_from_node_id_index ON public.workflow_transitions USING btree (from_node_id);


--
-- Name: workflow_transitions_to_node_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX workflow_transitions_to_node_id_index ON public.workflow_transitions USING btree (to_node_id);


--
-- Name: approval_instance_steps approval_instance_steps_approval_flow_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_instance_steps
    ADD CONSTRAINT approval_instance_steps_approval_flow_id_foreign FOREIGN KEY (approval_flow_id) REFERENCES public.approval_flows(id) ON DELETE SET NULL;


--
-- Name: approval_instance_steps approval_instance_steps_approval_instance_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_instance_steps
    ADD CONSTRAINT approval_instance_steps_approval_instance_id_foreign FOREIGN KEY (approval_instance_id) REFERENCES public.approval_instances(id) ON DELETE CASCADE;


--
-- Name: approval_instance_steps approval_instance_steps_approval_step_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_instance_steps
    ADD CONSTRAINT approval_instance_steps_approval_step_id_foreign FOREIGN KEY (approval_step_id) REFERENCES public.approval_steps(id) ON DELETE SET NULL;


--
-- Name: approval_instance_steps approval_instance_steps_approver_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_instance_steps
    ADD CONSTRAINT approval_instance_steps_approver_id_foreign FOREIGN KEY (approver_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: approval_instances approval_instances_approval_flow_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_instances
    ADD CONSTRAINT approval_instances_approval_flow_id_foreign FOREIGN KEY (approval_flow_id) REFERENCES public.approval_flows(id);


--
-- Name: approval_steps approval_steps_approval_flow_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_steps
    ADD CONSTRAINT approval_steps_approval_flow_id_foreign FOREIGN KEY (approval_flow_id) REFERENCES public.approval_flows(id) ON DELETE CASCADE;


--
-- Name: approval_steps approval_steps_approver_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approval_steps
    ADD CONSTRAINT approval_steps_approver_user_id_foreign FOREIGN KEY (approver_user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: approvals approvals_approval_instance_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approvals
    ADD CONSTRAINT approvals_approval_instance_id_foreign FOREIGN KEY (approval_instance_id) REFERENCES public.approval_instances(id) ON DELETE CASCADE;


--
-- Name: approvals approvals_approval_instance_step_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approvals
    ADD CONSTRAINT approvals_approval_instance_step_id_foreign FOREIGN KEY (approval_instance_step_id) REFERENCES public.approval_instance_steps(id) ON DELETE CASCADE;


--
-- Name: approvals approvals_approval_step_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approvals
    ADD CONSTRAINT approvals_approval_step_id_foreign FOREIGN KEY (approval_step_id) REFERENCES public.approval_steps(id) ON DELETE CASCADE;


--
-- Name: approvals approvals_approver_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.approvals
    ADD CONSTRAINT approvals_approver_id_foreign FOREIGN KEY (approver_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: audit_logs audit_logs_actor_device_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.audit_logs
    ADD CONSTRAINT audit_logs_actor_device_id_foreign FOREIGN KEY (actor_device_id) REFERENCES public.devices(id) ON DELETE SET NULL;


--
-- Name: audit_logs audit_logs_actor_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.audit_logs
    ADD CONSTRAINT audit_logs_actor_user_id_foreign FOREIGN KEY (actor_user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: configurable_features configurable_features_feature_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.configurable_features
    ADD CONSTRAINT configurable_features_feature_id_foreign FOREIGN KEY (feature_id) REFERENCES public.features(id) ON DELETE CASCADE;


--
-- Name: departments departments_manager_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.departments
    ADD CONSTRAINT departments_manager_id_foreign FOREIGN KEY (manager_id) REFERENCES public.org_employees(id) ON DELETE SET NULL;


--
-- Name: departments departments_parent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.departments
    ADD CONSTRAINT departments_parent_id_foreign FOREIGN KEY (parent_id) REFERENCES public.departments(id) ON DELETE SET NULL;


--
-- Name: device_users device_users_device_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.device_users
    ADD CONSTRAINT device_users_device_id_foreign FOREIGN KEY (device_id) REFERENCES public.devices(id) ON DELETE CASCADE;


--
-- Name: device_users device_users_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.device_users
    ADD CONSTRAINT device_users_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: form_audit_trails form_audit_trails_instance_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.form_audit_trails
    ADD CONSTRAINT form_audit_trails_instance_id_foreign FOREIGN KEY (instance_id) REFERENCES public.form_instances(id) ON DELETE CASCADE;


--
-- Name: form_instances form_instances_blueprint_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.form_instances
    ADD CONSTRAINT form_instances_blueprint_id_foreign FOREIGN KEY (blueprint_id) REFERENCES public.form_blueprints(id);


--
-- Name: hr_application_activities hr_application_activities_actor_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_activities
    ADD CONSTRAINT hr_application_activities_actor_user_id_foreign FOREIGN KEY (actor_user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: hr_application_activities hr_application_activities_application_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_activities
    ADD CONSTRAINT hr_application_activities_application_id_foreign FOREIGN KEY (application_id) REFERENCES public.hr_applications(id) ON DELETE CASCADE;


--
-- Name: hr_application_attachments hr_application_attachments_application_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_attachments
    ADD CONSTRAINT hr_application_attachments_application_id_foreign FOREIGN KEY (application_id) REFERENCES public.hr_applications(id) ON DELETE CASCADE;


--
-- Name: hr_application_attachments hr_application_attachments_field_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_attachments
    ADD CONSTRAINT hr_application_attachments_field_id_foreign FOREIGN KEY (field_id) REFERENCES public.hr_job_form_fields(id) ON DELETE SET NULL;


--
-- Name: hr_application_field_values hr_application_field_values_application_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_field_values
    ADD CONSTRAINT hr_application_field_values_application_id_foreign FOREIGN KEY (application_id) REFERENCES public.hr_applications(id) ON DELETE CASCADE;


--
-- Name: hr_application_field_values hr_application_field_values_field_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_field_values
    ADD CONSTRAINT hr_application_field_values_field_id_foreign FOREIGN KEY (field_id) REFERENCES public.hr_job_form_fields(id) ON DELETE SET NULL;


--
-- Name: hr_application_question_answers hr_application_question_answers_application_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_question_answers
    ADD CONSTRAINT hr_application_question_answers_application_id_foreign FOREIGN KEY (application_id) REFERENCES public.hr_applications(id) ON DELETE CASCADE;


--
-- Name: hr_application_question_answers hr_application_question_answers_question_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_question_answers
    ADD CONSTRAINT hr_application_question_answers_question_id_foreign FOREIGN KEY (question_id) REFERENCES public.hr_questions(id) ON DELETE RESTRICT;


--
-- Name: hr_application_skill_ratings hr_application_skill_ratings_application_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_skill_ratings
    ADD CONSTRAINT hr_application_skill_ratings_application_id_foreign FOREIGN KEY (application_id) REFERENCES public.hr_applications(id) ON DELETE CASCADE;


--
-- Name: hr_application_skill_ratings hr_application_skill_ratings_skill_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_application_skill_ratings
    ADD CONSTRAINT hr_application_skill_ratings_skill_id_foreign FOREIGN KEY (skill_id) REFERENCES public.hr_skills(id) ON DELETE RESTRICT;


--
-- Name: hr_applications hr_applications_job_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_applications
    ADD CONSTRAINT hr_applications_job_id_foreign FOREIGN KEY (job_id) REFERENCES public.hr_jobs(id) ON DELETE RESTRICT;


--
-- Name: hr_filter_options hr_filter_options_group_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_filter_options
    ADD CONSTRAINT hr_filter_options_group_id_foreign FOREIGN KEY (group_id) REFERENCES public.hr_filter_groups(id) ON DELETE CASCADE;


--
-- Name: hr_filter_options hr_filter_options_parent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_filter_options
    ADD CONSTRAINT hr_filter_options_parent_id_foreign FOREIGN KEY (parent_id) REFERENCES public.hr_filter_options(id) ON DELETE CASCADE;


--
-- Name: hr_job_form_field_options hr_job_form_field_options_field_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_field_options
    ADD CONSTRAINT hr_job_form_field_options_field_id_foreign FOREIGN KEY (field_id) REFERENCES public.hr_job_form_fields(id) ON DELETE CASCADE;


--
-- Name: hr_job_form_fields hr_job_form_fields_group_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_fields
    ADD CONSTRAINT hr_job_form_fields_group_id_foreign FOREIGN KEY (group_id) REFERENCES public.hr_job_form_groups(id) ON DELETE CASCADE;


--
-- Name: hr_job_form_groups hr_job_form_groups_section_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_groups
    ADD CONSTRAINT hr_job_form_groups_section_id_foreign FOREIGN KEY (section_id) REFERENCES public.hr_job_form_sections(id) ON DELETE CASCADE;


--
-- Name: hr_job_form_sections hr_job_form_sections_job_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_form_sections
    ADD CONSTRAINT hr_job_form_sections_job_id_foreign FOREIGN KEY (job_id) REFERENCES public.hr_jobs(id) ON DELETE CASCADE;


--
-- Name: hr_job_questions hr_job_questions_job_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_questions
    ADD CONSTRAINT hr_job_questions_job_id_foreign FOREIGN KEY (job_id) REFERENCES public.hr_jobs(id) ON DELETE CASCADE;


--
-- Name: hr_job_questions hr_job_questions_question_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_questions
    ADD CONSTRAINT hr_job_questions_question_id_foreign FOREIGN KEY (question_id) REFERENCES public.hr_questions(id) ON DELETE RESTRICT;


--
-- Name: hr_job_rules hr_job_rules_job_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_rules
    ADD CONSTRAINT hr_job_rules_job_id_foreign FOREIGN KEY (job_id) REFERENCES public.hr_jobs(id) ON DELETE CASCADE;


--
-- Name: hr_job_skill_requirements hr_job_skill_requirements_job_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_skill_requirements
    ADD CONSTRAINT hr_job_skill_requirements_job_id_foreign FOREIGN KEY (job_id) REFERENCES public.hr_jobs(id) ON DELETE CASCADE;


--
-- Name: hr_job_skill_requirements hr_job_skill_requirements_skill_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_job_skill_requirements
    ADD CONSTRAINT hr_job_skill_requirements_skill_id_foreign FOREIGN KEY (skill_id) REFERENCES public.hr_skills(id) ON DELETE RESTRICT;


--
-- Name: hr_question_options hr_question_options_question_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_question_options
    ADD CONSTRAINT hr_question_options_question_id_foreign FOREIGN KEY (question_id) REFERENCES public.hr_questions(id) ON DELETE CASCADE;


--
-- Name: hr_skill_scale_options hr_skill_scale_options_skill_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.hr_skill_scale_options
    ADD CONSTRAINT hr_skill_scale_options_skill_id_foreign FOREIGN KEY (skill_id) REFERENCES public.hr_skills(id) ON DELETE CASCADE;


--
-- Name: level_upgrade_rules level_upgrade_rules_for_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.level_upgrade_rules
    ADD CONSTRAINT level_upgrade_rules_for_role_id_foreign FOREIGN KEY (for_role_id) REFERENCES public.profile_roles(id) ON DELETE CASCADE;


--
-- Name: level_upgrade_rules level_upgrade_rules_from_level_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.level_upgrade_rules
    ADD CONSTRAINT level_upgrade_rules_from_level_id_foreign FOREIGN KEY (from_level_id) REFERENCES public.profile_levels(id) ON DELETE CASCADE;


--
-- Name: level_upgrade_rules level_upgrade_rules_to_level_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.level_upgrade_rules
    ADD CONSTRAINT level_upgrade_rules_to_level_id_foreign FOREIGN KEY (to_level_id) REFERENCES public.profile_levels(id) ON DELETE CASCADE;


--
-- Name: model_has_permissions model_has_permissions_permission_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.model_has_permissions
    ADD CONSTRAINT model_has_permissions_permission_id_foreign FOREIGN KEY (permission_id) REFERENCES public.permissions(id) ON DELETE CASCADE;


--
-- Name: model_has_roles model_has_roles_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.model_has_roles
    ADD CONSTRAINT model_has_roles_role_id_foreign FOREIGN KEY (role_id) REFERENCES public.roles(id) ON DELETE CASCADE;


--
-- Name: node_permissions node_permissions_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.node_permissions
    ADD CONSTRAINT node_permissions_node_id_foreign FOREIGN KEY (node_id) REFERENCES public.system_nodes(id) ON DELETE CASCADE;


--
-- Name: node_permissions node_permissions_permission_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.node_permissions
    ADD CONSTRAINT node_permissions_permission_id_foreign FOREIGN KEY (permission_id) REFERENCES public.permissions(id) ON DELETE CASCADE;


--
-- Name: opportunity_contacts opportunity_contacts_opportunity_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_contacts
    ADD CONSTRAINT opportunity_contacts_opportunity_id_foreign FOREIGN KEY (opportunity_id) REFERENCES public.opportunities(id) ON DELETE CASCADE;


--
-- Name: opportunity_properties opportunity_properties_opportunity_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.opportunity_properties
    ADD CONSTRAINT opportunity_properties_opportunity_id_foreign FOREIGN KEY (opportunity_id) REFERENCES public.opportunities(id) ON DELETE CASCADE;


--
-- Name: org_contracts org_contracts_employee_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_contracts
    ADD CONSTRAINT org_contracts_employee_id_foreign FOREIGN KEY (employee_id) REFERENCES public.org_employees(id) ON DELETE CASCADE;


--
-- Name: org_employees org_employees_manager_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_employees
    ADD CONSTRAINT org_employees_manager_id_foreign FOREIGN KEY (manager_id) REFERENCES public.org_employees(id) ON DELETE SET NULL;


--
-- Name: org_job_histories org_job_histories_contract_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_job_histories
    ADD CONSTRAINT org_job_histories_contract_id_foreign FOREIGN KEY (contract_id) REFERENCES public.org_contracts(id) ON DELETE SET NULL;


--
-- Name: org_job_histories org_job_histories_employee_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_job_histories
    ADD CONSTRAINT org_job_histories_employee_id_foreign FOREIGN KEY (employee_id) REFERENCES public.org_employees(id) ON DELETE CASCADE;


--
-- Name: org_job_histories org_job_histories_position_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_job_histories
    ADD CONSTRAINT org_job_histories_position_id_foreign FOREIGN KEY (position_id) REFERENCES public.org_positions(id) ON DELETE CASCADE;


--
-- Name: org_positions org_positions_department_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_positions
    ADD CONSTRAINT org_positions_department_id_foreign FOREIGN KEY (department_id) REFERENCES public.departments(id) ON DELETE SET NULL;


--
-- Name: org_positions org_positions_job_title_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_positions
    ADD CONSTRAINT org_positions_job_title_id_foreign FOREIGN KEY (job_title_id) REFERENCES public.org_job_titles(id) ON DELETE SET NULL;


--
-- Name: org_positions org_positions_parent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.org_positions
    ADD CONSTRAINT org_positions_parent_id_foreign FOREIGN KEY (parent_id) REFERENCES public.org_positions(id) ON DELETE SET NULL;


--
-- Name: profile_completion_weights profile_completion_weights_for_level_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profile_completion_weights
    ADD CONSTRAINT profile_completion_weights_for_level_id_foreign FOREIGN KEY (for_level_id) REFERENCES public.profile_levels(id) ON DELETE CASCADE;


--
-- Name: profile_completion_weights profile_completion_weights_for_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profile_completion_weights
    ADD CONSTRAINT profile_completion_weights_for_role_id_foreign FOREIGN KEY (for_role_id) REFERENCES public.profile_roles(id) ON DELETE CASCADE;


--
-- Name: profiles profiles_owner_user_uuid_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profiles
    ADD CONSTRAINT profiles_owner_user_uuid_foreign FOREIGN KEY (owner_user_uuid) REFERENCES public.users(uuid) ON DELETE CASCADE;


--
-- Name: profiles profiles_profile_cover_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profiles
    ADD CONSTRAINT profiles_profile_cover_foreign FOREIGN KEY (profile_cover) REFERENCES public.media(uuid) ON DELETE SET NULL;


--
-- Name: profiles profiles_profile_level_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profiles
    ADD CONSTRAINT profiles_profile_level_id_foreign FOREIGN KEY (profile_level_id) REFERENCES public.profile_levels(id) ON DELETE RESTRICT;


--
-- Name: profiles profiles_profile_logo_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profiles
    ADD CONSTRAINT profiles_profile_logo_foreign FOREIGN KEY (profile_logo) REFERENCES public.media(uuid) ON DELETE SET NULL;


--
-- Name: profiles profiles_profile_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.profiles
    ADD CONSTRAINT profiles_profile_role_id_foreign FOREIGN KEY (profile_role_id) REFERENCES public.profile_roles(id) ON DELETE RESTRICT;


--
-- Name: role_has_permissions role_has_permissions_permission_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.role_has_permissions
    ADD CONSTRAINT role_has_permissions_permission_id_foreign FOREIGN KEY (permission_id) REFERENCES public.permissions(id) ON DELETE CASCADE;


--
-- Name: role_has_permissions role_has_permissions_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.role_has_permissions
    ADD CONSTRAINT role_has_permissions_role_id_foreign FOREIGN KEY (role_id) REFERENCES public.roles(id) ON DELETE CASCADE;


--
-- Name: system_nodes system_nodes_parent_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.system_nodes
    ADD CONSTRAINT system_nodes_parent_id_foreign FOREIGN KEY (parent_id) REFERENCES public.system_nodes(id) ON DELETE CASCADE;


--
-- Name: workflow_approvals workflow_approvals_workflow_instance_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_approvals
    ADD CONSTRAINT workflow_approvals_workflow_instance_id_foreign FOREIGN KEY (workflow_instance_id) REFERENCES public.workflow_instances(id) ON DELETE CASCADE;


--
-- Name: workflow_approvals workflow_approvals_workflow_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_approvals
    ADD CONSTRAINT workflow_approvals_workflow_node_id_foreign FOREIGN KEY (workflow_node_id) REFERENCES public.workflow_nodes(id);


--
-- Name: workflow_events workflow_events_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_events
    ADD CONSTRAINT workflow_events_node_id_foreign FOREIGN KEY (node_id) REFERENCES public.workflow_nodes(id) ON DELETE SET NULL;


--
-- Name: workflow_events workflow_events_transition_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_events
    ADD CONSTRAINT workflow_events_transition_id_foreign FOREIGN KEY (transition_id) REFERENCES public.workflow_transitions(id) ON DELETE SET NULL;


--
-- Name: workflow_events workflow_events_workflow_instance_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_events
    ADD CONSTRAINT workflow_events_workflow_instance_id_foreign FOREIGN KEY (workflow_instance_id) REFERENCES public.workflow_instances(id) ON DELETE CASCADE;


--
-- Name: workflow_instance_history workflow_instance_history_from_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instance_history
    ADD CONSTRAINT workflow_instance_history_from_node_id_foreign FOREIGN KEY (from_node_id) REFERENCES public.workflow_nodes(id);


--
-- Name: workflow_instance_history workflow_instance_history_to_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instance_history
    ADD CONSTRAINT workflow_instance_history_to_node_id_foreign FOREIGN KEY (to_node_id) REFERENCES public.workflow_nodes(id);


--
-- Name: workflow_instance_history workflow_instance_history_transition_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instance_history
    ADD CONSTRAINT workflow_instance_history_transition_id_foreign FOREIGN KEY (transition_id) REFERENCES public.workflow_transitions(id) ON DELETE SET NULL;


--
-- Name: workflow_instance_history workflow_instance_history_workflow_instance_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instance_history
    ADD CONSTRAINT workflow_instance_history_workflow_instance_id_foreign FOREIGN KEY (workflow_instance_id) REFERENCES public.workflow_instances(id) ON DELETE CASCADE;


--
-- Name: workflow_instances workflow_instances_current_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instances
    ADD CONSTRAINT workflow_instances_current_node_id_foreign FOREIGN KEY (current_node_id) REFERENCES public.workflow_nodes(id);


--
-- Name: workflow_instances workflow_instances_previous_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instances
    ADD CONSTRAINT workflow_instances_previous_node_id_foreign FOREIGN KEY (previous_node_id) REFERENCES public.workflow_nodes(id);


--
-- Name: workflow_instances workflow_instances_workflow_definition_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_instances
    ADD CONSTRAINT workflow_instances_workflow_definition_id_foreign FOREIGN KEY (workflow_definition_id) REFERENCES public.workflow_definitions(id);


--
-- Name: workflow_nodes workflow_nodes_workflow_definition_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_nodes
    ADD CONSTRAINT workflow_nodes_workflow_definition_id_foreign FOREIGN KEY (workflow_definition_id) REFERENCES public.workflow_definitions(id) ON DELETE CASCADE;


--
-- Name: workflow_schedules workflow_schedules_workflow_definition_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_schedules
    ADD CONSTRAINT workflow_schedules_workflow_definition_id_foreign FOREIGN KEY (workflow_definition_id) REFERENCES public.workflow_definitions(id) ON DELETE CASCADE;


--
-- Name: workflow_transitions workflow_transitions_from_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_transitions
    ADD CONSTRAINT workflow_transitions_from_node_id_foreign FOREIGN KEY (from_node_id) REFERENCES public.workflow_nodes(id) ON DELETE CASCADE;


--
-- Name: workflow_transitions workflow_transitions_to_node_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_transitions
    ADD CONSTRAINT workflow_transitions_to_node_id_foreign FOREIGN KEY (to_node_id) REFERENCES public.workflow_nodes(id) ON DELETE CASCADE;


--
-- Name: workflow_transitions workflow_transitions_workflow_definition_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.workflow_transitions
    ADD CONSTRAINT workflow_transitions_workflow_definition_id_foreign FOREIGN KEY (workflow_definition_id) REFERENCES public.workflow_definitions(id) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--

--
-- PostgreSQL database dump
--

-- Dumped from database version 16.6 (Homebrew)
-- Dumped by pg_dump version 16.6 (Homebrew)

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Data for Name: migrations; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.migrations (id, migration, batch) FROM stdin;
1	0001_01_01_000000_create_users_table	1
2	0001_01_01_000001_create_cache_table	1
3	0001_01_01_000002_create_jobs_table	1
4	0001_01_01_000004_create_users_table	1
5	2025_01_01_000100_create_hr_config_tables	1
6	2025_01_01_000200_create_hr_applications_tables	1
7	2025_05_26_092528_create_devices_table	1
8	2025_05_26_100001_create_approval_flows_table	1
9	2025_05_26_100002_create_approval_steps_table	1
10	2025_05_26_100003_create_approvals_table	1
11	2025_05_26_100004_create_approval_instances_table	1
12	2025_05_26_100005_create_approval_instance_steps_table	1
13	2025_05_26_100006_add_approval_instance_relation_to_approvals_table	1
14	2025_05_26_151951_create_otps_table	1
15	2025_05_26_182409_create_audit_logs_table	1
16	2025_05_27_204137_create_personal_access_tokens_table	1
17	2025_05_27_210231_create_device_users_table	1
18	2025_06_23_050036_create_media_table	1
19	2025_06_29_060000_create_profile_roles_table	1
20	2025_06_29_060001_create_profile_levels_table	1
21	2025_06_29_062917_create_profiles_table	1
22	2025_06_30_054912_create_level_upgrade_rules_table	1
23	2025_06_30_060911_create_features_table	1
24	2025_06_30_060915_create_configurable_features_table	1
25	2025_06_30_061137_create_profile_completion_weights_table	1
26	2025_12_30_160212_add_value_json_to_application_field_values	1
27	2025_12_30_160335_add_meta_to_builder_fields_table	1
28	2026_01_01_102312_update_job_table	1
29	2026_01_01_151721_create_job_form_groups_table	1
30	2026_01_01_152039_add_group_id_to_job_form_fields	1
31	2026_01_01_155501_add_section_id_to_job_form_fields	1
32	2026_01_02_213430_add_is_template_to_jobs	1
33	2026_01_02_220545_add_is_draft_to_jobs	1
34	2026_01_04_223036_create_application_statuses_table	1
35	2026_01_04_231055_create_filter_groups_table	1
36	2026_01_04_231206_create_filter_options_table	1
37	2026_01_15_000943_create_opportunities_table	1
38	2026_01_15_002626_create_stages_table	1
39	2026_01_15_003847_create_department_stage_assignments_table	1
40	2026_01_15_003847_create_departments_table	1
41	2026_01_15_004057_create_opportunity_comments_table	1
42	2026_01_15_004057_create_opportunity_stage_data_table	1
43	2026_01_15_005434_add_postgresql_optimizations_to_all_tables	1
44	2026_01_16_040825_create_opportunity_properties_table	1
45	2026_01_16_040826_create_opportunity_contacts_table	1
46	2026_01_16_045318_move_source_to_opportunities_table	1
47	2026_01_18_000000_create_access_control_tables	1
48	2026_01_25_195937_create_system_nodes_table	1
49	2026_01_26_215708_create_node_permissions_table	1
50	2026_01_26_215708_update_permissions_table_add_fields	1
51	2026_01_26_215709_update_roles_table_display_name	1
52	2026_01_28_005412_add_uuid_to_users_table	1
53	2026_01_28_010215_add_uuid_to_roles_and_permissions_tables	1
54	2026_01_28_174359_modify_phone_nullable_in_opportunity_contacts_table	1
55	2026_01_28_215000_add_stage_tracking_to_opportunities_table	1
56	2026_01_28_215100_add_metadata_to_opportunity_stage_data_table	1
57	2026_02_04_000001_create_form_blueprints_table	1
58	2026_02_04_000001_create_org_tables	1
59	2026_02_04_000002_add_hierarchy_to_departments	1
60	2026_02_04_000002_create_form_instances_table	1
61	2026_02_04_000003_create_form_audit_trails_table	1
62	2026_02_04_000004_add_schema_override_to_form_instances	1
63	2026_02_04_075711_add_deleted_at_to_approval_steps_table	1
64	2026_02_04_084500_add_deleted_at_to_approvals_table	1
65	2026_02_05_000001_update_org_tables_for_localization	1
66	2026_02_05_000002_add_uuid_to_org_tables	1
67	2026_02_05_140645_create_activity_log_table	1
68	2026_02_05_140646_add_event_column_to_activity_log_table	1
69	2026_02_05_140647_add_batch_uuid_column_to_activity_log_table	1
70	2026_02_06_001_create_workflow_definitions_table	1
71	2026_02_06_002_create_workflow_nodes_table	1
72	2026_02_06_003_create_workflow_transitions_table	1
73	2026_02_06_004_create_workflow_instances_table	1
74	2026_02_06_005_create_workflow_instance_history_table	1
75	2026_02_06_006_create_workflow_approvals_table	1
76	2026_02_06_007_create_workflow_events_table	1
77	2026_02_06_008_create_workflow_schedules_table	1
78	2026_02_07_000001_add_stage_tracking_to_opportunities	2
82	2026_02_08_173116_add_price_per_sqm_to_opportunity_properties	3
83	2026_02_07_000002_rename_org_position_parent_column	4
84	2026_02_08_000003_add_columns_to_org_employees_table	4
85	2026_02_08_000004_add_columns_to_org_job_titles_table	4
86	2026_02_08_000005_add_columns_to_org_position_table	4
87	2026_02_08_000006_add_meta_column_to_org_employees_table	4
88	2026_02_08_000007_add_status_column_to_org_employees_table	4
\.


--
-- Name: migrations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('public.migrations_id_seq', 88, true);


--
-- PostgreSQL database dump complete
--

