CREATE TABLE public.payment_types (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    description text,
    tenant_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.payment_types OWNER TO taf;

--
-- Name: payment_types_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.payment_types_id_seq OWNER TO taf;

--
-- Name: payment_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.payment_types_id_seq OWNED BY public.payment_types.id;


--
-- Name: payment_webhooks; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.payment_webhooks (
    webhook_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    provider_name text NOT NULL,
    event_type text NOT NULL,
    payload jsonb NOT NULL,
    headers jsonb,
    processed boolean DEFAULT false,
    transaction_id uuid,
    error_message text,
    retry_count integer DEFAULT 0,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    processed_at timestamp with time zone
);


ALTER TABLE public.payment_webhooks OWNER TO taf;

--
-- Name: payroll_anomalies; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.payroll_anomalies (
    id integer NOT NULL,
    payroll_run_id integer NOT NULL,
    employee_id integer NOT NULL,
    message character varying(255) NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.payroll_anomalies OWNER TO taf;

--
-- Name: payroll_anomalies_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.payroll_anomalies_id_seq OWNER TO taf;

--
-- Name: payroll_anomalies_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.payroll_anomalies_id_seq OWNED BY public.payroll_anomalies.id;


--
-- Name: payslip_deductions; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.payslip_deductions (
    payslip_deduction_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    payslip_id uuid NOT NULL,
    deduction_type_id uuid NOT NULL,
    amount numeric(10,2) NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.payslip_deductions OWNER TO taf;

--
-- Name: payslips; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.payslips (
    payslip_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    time_clock_aggregate_id uuid NOT NULL,
    gross_pay numeric(8,2) DEFAULT NULL::numeric,
    net_pay numeric(8,2) DEFAULT NULL::numeric,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    org_id uuid
);


ALTER TABLE public.payslips OWNER TO taf;

--
-- Name: performance_goals; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.performance_goals (
    id integer NOT NULL,
    employee_id integer NOT NULL,
    description text NOT NULL,
    kpi_id integer,
    due_date date,
    status character varying(50) DEFAULT 'pending'::character varying,
    progress_pct numeric(5,2) DEFAULT 0.00,
    score_type character varying(20) DEFAULT 'numeric'::character varying,
    milestone character varying(255) DEFAULT NULL::character varying,
    completed_at timestamp without time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.performance_goals OWNER TO taf;

--
-- Name: performance_goals_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.performance_goals_id_seq OWNER TO taf;

--
-- Name: performance_goals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.performance_goals_id_seq OWNED BY public.performance_goals.id;


--
-- Name: performance_reviews; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.performance_reviews (
    id integer NOT NULL,
    employee_id integer NOT NULL,
    cycle_id integer NOT NULL,
    self_rating numeric(3,2) DEFAULT NULL::numeric,
    manager_rating numeric(3,2) DEFAULT NULL::numeric,
    comments text,
    status character varying(50) DEFAULT 'draft'::character varying,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.performance_reviews OWNER TO taf;

--
-- Name: performance_reviews_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.performance_reviews_id_seq OWNER TO taf;

--
-- Name: performance_reviews_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.performance_reviews_id_seq OWNED BY public.performance_reviews.id;


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

CREATE TABLE public.permissions (
    id integer NOT NULL,
    resource_id integer,
    resource_type_id integer,
    resource_name character varying(50) DEFAULT NULL::character varying,
    subject_type character varying(50) DEFAULT NULL::character varying,
    subject_id integer,
    tenant_id integer,
    branch_id integer,
    department_id integer,
    district_id integer,
    can_view boolean,
    can_edit boolean,
    can_create boolean,
    can_delete boolean,
    can_delegate boolean DEFAULT false,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.permissions OWNER TO taf;

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

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


ALTER SEQUENCE public.permissions_id_seq OWNER TO taf;

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

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


--
-- Name: permit_applications; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.permit_applications (
    id integer NOT NULL,
    permit_type_id integer NOT NULL,
    applicant_id integer NOT NULL,
    tenant_id integer,
    branch_id integer,
    status character varying(50) DEFAULT 'Initiated'::character varying,
    start_date date,
    end_date date,
    fee_amount numeric(10,2) DEFAULT 0.00,
    description text,
    work_location character varying(255) DEFAULT NULL::character varying,
    equipment character varying(255) DEFAULT NULL::character varying,
    hazard_assessment text,
    control_measures text,
    ppe_required text,
    control_items json,
    ppe_items json,
    loto_instructions text,
    emergency_response text,
    issuer_id integer,
    supervisor_id integer,
    issuer_signed_at timestamp without time zone,
    supervisor_signed_at timestamp without time zone,
    holder_signed_at timestamp without time zone,
    signed_off_at timestamp without time zone,
    expires_at date,
    archived_at timestamp without time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.permit_applications OWNER TO taf;

--
-- Name: permit_applications_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.permit_applications_id_seq OWNER TO taf;

--
-- Name: permit_applications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.permit_applications_id_seq OWNED BY public.permit_applications.id;


--
-- Name: permit_documents; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.permit_documents (
    id integer NOT NULL,
    permit_application_id integer NOT NULL,
    tenant_id integer,
    branch_id integer,
    file_name character varying(255) NOT NULL,
    file_type character varying(50) NOT NULL,
    file_path text NOT NULL,
    uploaded_by integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.permit_documents OWNER TO taf;

--
-- Name: permit_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.permit_documents_id_seq OWNER TO taf;

--
-- Name: permit_documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.permit_documents_id_seq OWNED BY public.permit_documents.id;


--
-- Name: permit_inspections; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.permit_inspections (
    id integer NOT NULL,
    permit_application_id integer NOT NULL,
    tenant_id integer,
    branch_id integer,
    inspector_id integer NOT NULL,
    scheduled_for timestamp without time zone,
    result character varying(255) DEFAULT NULL::character varying,
    notes text,
    hours_logged numeric(5,2) DEFAULT NULL::numeric,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.permit_inspections OWNER TO taf;

--
-- Name: permit_inspections_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.permit_inspections_id_seq OWNER TO taf;

--
-- Name: permit_inspections_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.permit_inspections_id_seq OWNED BY public.permit_inspections.id;


--
-- Name: permit_signatures; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.permit_signatures (
    id integer NOT NULL,
    permit_application_id integer NOT NULL,
    tenant_id integer,
    branch_id integer,
    role character varying(20) NOT NULL,
    user_id integer,
    file_path text NOT NULL,
    signed_at timestamp without time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.permit_signatures OWNER TO taf;

--
-- Name: permit_signatures_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.permit_signatures_id_seq OWNER TO taf;

--
-- Name: permit_signatures_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.permit_signatures_id_seq OWNED BY public.permit_signatures.id;


--
-- Name: permit_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.permit_types (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    description text,
    control_options json,
    ppe_options json,
    required_training_ids json,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.permit_types OWNER TO taf;

--
-- Name: permit_types_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.permit_types_id_seq OWNER TO taf;

--
-- Name: permit_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.permit_types_id_seq OWNED BY public.permit_types.id;


--
-- Name: policies; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.policies (
    policy_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    title character varying(255) NOT NULL,
    content text,
    content_type character varying(100) DEFAULT 'html'::character varying NOT NULL,
    policy_type character varying(50) DEFAULT NULL::character varying,
    pdf_url text,
    language_code character varying(10) DEFAULT 'en'::character varying,
    expiry_date date,
    renewal_status character varying(50) DEFAULT NULL::character varying,
    visible_to_roles character varying(255) DEFAULT NULL::character varying,
    visible_to_group character varying(255) DEFAULT NULL::character varying,
    visible_to_all boolean DEFAULT false,
    created_by integer,
    updated_by integer,
    version integer DEFAULT 1 NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.policies OWNER TO taf;

--
-- Name: policy_acknowledgments; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.policy_acknowledgments (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    user_id integer NOT NULL,
    policy_version integer DEFAULT 1,
    acknowledged_at timestamp without time zone NOT NULL,
    ip_address character varying(45) DEFAULT NULL::character varying,
    browser character varying(100) DEFAULT NULL::character varying,
    user_agent text,
    duration_seconds integer,
    scrolled_to_bottom boolean DEFAULT false,
    checkbox_confirmed boolean DEFAULT false,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.policy_acknowledgments OWNER TO taf;

--
-- Name: policy_acknowledgments_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.policy_acknowledgments_id_seq OWNER TO taf;

--
-- Name: policy_acknowledgments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.policy_acknowledgments_id_seq OWNED BY public.policy_acknowledgments.id;


--
-- Name: policy_approvals; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.policy_approvals (
    id integer NOT NULL,
    document_id uuid NOT NULL,
    step_order integer NOT NULL,
    approver_role character varying(100) NOT NULL,
    status character varying(50) DEFAULT 'pending'::character varying,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.policy_approvals OWNER TO taf;

--
-- Name: policy_approvals_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.policy_approvals_id_seq OWNER TO taf;

--
-- Name: policy_approvals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.policy_approvals_id_seq OWNED BY public.policy_approvals.id;


--
-- Name: policy_targets; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.policy_targets (
    id integer NOT NULL,
    policy_id integer NOT NULL,
    group_id integer,
    location_id integer,
    job_id integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.policy_targets OWNER TO taf;

--
-- Name: policy_targets_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.policy_targets_id_seq OWNER TO taf;

--
-- Name: policy_targets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.policy_targets_id_seq OWNED BY public.policy_targets.id;


--
-- Name: policy_templates; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.policy_templates (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    description text,
    content text,
    content_type character varying(20) DEFAULT 'html'::character varying,
    pdf_url text,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.policy_templates OWNER TO taf;

--
-- Name: policy_templates_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.policy_templates_id_seq OWNER TO taf;

--
-- Name: policy_templates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.policy_templates_id_seq OWNED BY public.policy_templates.id;


--
-- Name: pos_settings; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.pos_settings (
    pos_settings_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid,
    branch_id uuid,
    password text NOT NULL,
    pin text NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    createdat timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    sdc_endpoint text,
    sdc_pin_url text
);


ALTER TABLE public.pos_settings OWNER TO taf;

--
-- Name: procurement_requests; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.procurement_requests (
    procurement_request_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid,
    description text NOT NULL,
    justification text,
    estimated_cost numeric(12,2),
    quantity integer,
    preferred_vendor character varying(100),
    needed_by date,
    project_id integer,
    inventory_item_id integer,
    location_id integer,
    status character varying(50) DEFAULT 'Pending'::character varying,
    requester_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.procurement_requests OWNER TO taf;

--
-- Name: procurements; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.procurements (
    procurement_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendor_id uuid,
    quotation_number text,
    invoice_number text,
    requested_by_date timestamp with time zone,
    product_barcode text,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.procurements OWNER TO taf;

--
-- Name: product_batch_number; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.product_batch_number (
    product_batch_number_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    product_id uuid,
    expiry_date date,
    batch_number text,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.product_batch_number OWNER TO taf;

--
-- Name: product_categories; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.product_categories (
    category_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    name text NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.product_categories OWNER TO taf;

--
-- Name: product_daily_rec; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.product_daily_rec (
    product_daily_rec_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    date timestamp with time zone,
    change integer NOT NULL,
    branch_id uuid,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.product_daily_rec OWNER TO taf;

--
-- Name: product_discounts; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.product_discounts (
    discount_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    product_id uuid,
    discount_amount numeric(10,2) DEFAULT NULL::numeric,
    start_date date,
    end_date date,
    org_id uuid,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.product_discounts OWNER TO taf;

--
-- Name: products_2_categories; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.products_2_categories (
    product_category_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    product_id uuid NOT NULL,
    category_id uuid NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.products_2_categories OWNER TO taf;

--
-- Name: products_2_taxcodes; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.products_2_taxcodes (
    product_tax_code_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    product_id uuid,
    taxcode_id uuid,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.products_2_taxcodes OWNER TO taf;

--
-- Name: products_to_vendors; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.products_to_vendors (
    products_to_vendor_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    product_id uuid,
    vendor_id uuid NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.products_to_vendors OWNER TO taf;

--
-- Name: program_default_group_permissions; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.program_default_group_permissions (
    program_default_permission_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    program_default_group_id uuid NOT NULL,
    module_id uuid,
    permission_type character varying(50) DEFAULT 'module'::character varying NOT NULL,
    action text DEFAULT 'allow'::text NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.program_default_group_permissions OWNER TO taf;

--
-- Name: program_default_groups; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.program_default_groups (
    program_default_group_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    program_id uuid NOT NULL,
    group_name character varying(255) NOT NULL,
    group_description text,
    is_auto_create boolean DEFAULT true NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.program_default_groups OWNER TO taf;

--
-- Name: program_enrollments; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.program_enrollments (
    program_enrollment_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    program_id uuid NOT NULL,
    org_id uuid NOT NULL,
    status text DEFAULT 'active'::text NOT NULL,
    enrolled_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL
);


ALTER TABLE public.program_enrollments OWNER TO taf;

--
-- Name: program_modules; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.program_modules (
    program_module_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    program_id uuid NOT NULL,
    module_id uuid,
    config_json jsonb,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.program_modules OWNER TO taf;

--
-- Name: programs; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.programs (
    program_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    name text NOT NULL,
    owner_root_org_id uuid,
    is_private boolean DEFAULT true NOT NULL,
    owner_access public.owner_access_mode DEFAULT 'none'::public.owner_access_mode NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.programs OWNER TO taf;

--
-- Name: projects; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.projects (
    id integer NOT NULL,
    tenant_id integer,
    branch_id integer,
    name character varying(255) NOT NULL,
    description text,
    start_date date,
    end_date date,
    status character varying(50) DEFAULT 'active'::character varying,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.projects OWNER TO taf;

--
-- Name: projects_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.projects_id_seq OWNER TO taf;

--
-- Name: projects_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.projects_id_seq OWNED BY public.projects.id;


--
-- Name: properties; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.properties (
    id integer NOT NULL,
    counselid integer,
    propertyid integer NOT NULL,
    assessmentnumber integer NOT NULL,
    ratepayerid integer,
    zone character varying(100) DEFAULT NULL::character varying,
    address text,
    street character varying(255) DEFAULT NULL::character varying,
    ward character varying(100) DEFAULT NULL::character varying,
    legaldescription text,
    noofflats integer,
    isactive boolean DEFAULT true,
    createdby integer,
    propertyholdersname character varying(255) DEFAULT NULL::character varying,
    ucv numeric(10,2) NOT NULL,
    ratesstrick numeric(3,2) NOT NULL,
    arrears numeric(10,2) NOT NULL,
    advancepayment numeric(10,2) NOT NULL,
    garbagefee numeric(10,2) NOT NULL,
    garbagearrears numeric(10,2) NOT NULL,
    advancepay numeric(10,2) NOT NULL,
    legalfee numeric(10,2) NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL
);


ALTER TABLE public.properties OWNER TO taf;

--
-- Name: properties_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.properties_id_seq OWNER TO taf;

--
-- Name: properties_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.properties_id_seq OWNED BY public.properties.id;


--
-- Name: property_rates; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.property_rates (
    id integer NOT NULL,
    zone character varying(100) DEFAULT NULL::character varying,
    subzone character varying(100) DEFAULT NULL::character varying,
    category character varying(100) DEFAULT NULL::character varying,
    baserate numeric(10,2) DEFAULT NULL::numeric,
    rateper100 numeric(10,2) DEFAULT NULL::numeric,
    ratetype character varying(50) DEFAULT NULL::character varying,
    ratestrick2024 numeric(10,2) DEFAULT NULL::numeric,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.property_rates OWNER TO taf;

--
-- Name: property_rates_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.property_rates_id_seq OWNER TO taf;

--
-- Name: property_rates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.property_rates_id_seq OWNED BY public.property_rates.id;


--
-- Name: purchase_order_lines; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.purchase_order_lines (
    purchase_order_line_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    purchase_order_id uuid NOT NULL,
    product_id uuid NOT NULL,
    org_id uuid,
    line_number integer NOT NULL,
    description text,
    quantity_ordered numeric(12,3) NOT NULL,
    unit_type character varying(50) DEFAULT 'PIECE'::character varying NOT NULL,
    unit_price numeric(12,2) DEFAULT 0.00,
    line_total numeric(12,2) GENERATED ALWAYS AS ((quantity_ordered * unit_price)) STORED,
    quantity_received numeric(12,3) DEFAULT 0.00,
    quantity_remaining numeric(12,3) GENERATED ALWAYS AS ((quantity_ordered - quantity_received)) STORED,
    notes text,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT chk_po_line_quantities CHECK (((quantity_ordered >= (0)::numeric) AND (quantity_received >= (0)::numeric)))
);


ALTER TABLE public.purchase_order_lines OWNER TO taf;

--
-- Name: TABLE purchase_order_lines; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON TABLE public.purchase_order_lines IS 'Line items for purchase orders with expected quantities';


--
-- Name: COLUMN purchase_order_lines.unit_type; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON COLUMN public.purchase_order_lines.unit_type IS 'PIECE, CARTON, PALLET, etc. - matches product unit definitions';


--
-- Name: COLUMN purchase_order_lines.quantity_received; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON COLUMN public.purchase_order_lines.quantity_received IS 'Cumulative quantity received across all deliveries';


--
-- Name: push_subscriptions; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.push_subscriptions (
    id integer NOT NULL,
    user_id integer,
    endpoint text NOT NULL,
    p256dh character varying(255) NOT NULL,
    auth character varying(255) NOT NULL,
    browser character varying(100) DEFAULT NULL::character varying,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.push_subscriptions OWNER TO taf;

--
-- Name: push_subscriptions_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.push_subscriptions_id_seq OWNER TO taf;

--
-- Name: push_subscriptions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.push_subscriptions_id_seq OWNED BY public.push_subscriptions.id;


--
-- Name: quotation_actions; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.quotation_actions (
    action_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    quotation_id uuid NOT NULL,
    user_id uuid,
    org_id uuid NOT NULL,
    action_type text NOT NULL,
    notes text,
    metadata jsonb,
    ip_address inet,
    user_agent text,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.quotation_actions OWNER TO taf;

--
-- Name: quotation_pipeline; Type: VIEW; Schema: public; Owner: taf
--

CREATE VIEW public.quotation_pipeline AS
 SELECT q.quotation_id,
    q.quotation_number,
    q.org_id,
    o.name AS org_name,
    c.name AS client_name,
    q.date AS quotation_date,
    q.total_amount,
    q.status,
    q.validity_days,
    q.expires_at,
        CASE
            WHEN (q.status = 'converted'::text) THEN 'Converted to Invoice'::text
            WHEN (q.status = 'expired'::text) THEN 'Expired'::text
            WHEN (q.expires_at < now()) THEN 'Expired (Not Updated)'::text
            WHEN (q.status = 'sent'::text) THEN 'Awaiting Response'::text
            ELSE initcap(q.status)
        END AS pipeline_stage,
    (EXTRACT(day FROM (now() - (q.date)::timestamp with time zone)))::integer AS days_since_created,
        CASE
            WHEN (q.sent_at IS NOT NULL) THEN (EXTRACT(day FROM (now() - q.sent_at)))::integer
            ELSE NULL::integer
        END AS days_since_sent,
    q.converted_invoice_id
   FROM ((public.quotations q
     LEFT JOIN public.orgs o ON ((q.org_id = o.org_id)))
     LEFT JOIN public.clients c ON ((q.client_id = c.client_id)))
  WHERE (q.isdeleted = false);


ALTER VIEW public.quotation_pipeline OWNER TO taf;

--
-- Name: VIEW quotation_pipeline; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON VIEW public.quotation_pipeline IS 'Quotation pipeline analysis with status and aging';


--
-- Name: quotation_settings; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.quotation_settings (
    quotation_setting_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid NOT NULL,
    template_id uuid,
    logo_document_id uuid,
    number_format character varying(50) DEFAULT 'Q-{YYYY}-{0000}'::character varying,
    starting_number integer DEFAULT 1,
    current_number integer DEFAULT 1,
    validity_days integer DEFAULT 30,
    terms text,
    footer_text text,
    auto_convert_to_invoice boolean DEFAULT false,
    send_as_proforma boolean DEFAULT false,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.quotation_settings OWNER TO taf;

--
-- Name: rate_invoices; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rate_invoices (
    id integer NOT NULL,
    counselid integer,
    rateid integer NOT NULL,
    propertyid integer,
    period date,
    arrears numeric(10,2) DEFAULT NULL::numeric,
    currentcharges numeric(10,2) DEFAULT NULL::numeric,
    penalty numeric(10,2) DEFAULT NULL::numeric,
    totaldue numeric(10,2) DEFAULT NULL::numeric,
    receiptstotal numeric(10,2) DEFAULT NULL::numeric,
    balance numeric(10,2) DEFAULT NULL::numeric,
    createdby integer,
    customerid integer,
    gl_transaction_id integer,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL
);


ALTER TABLE public.rate_invoices OWNER TO taf;

--
-- Name: rate_invoices_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.rate_invoices_id_seq OWNER TO taf;

--
-- Name: rate_invoices_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.rate_invoices_id_seq OWNED BY public.rate_invoices.id;


--
-- Name: rate_limits; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rate_limits (
    key text NOT NULL,
    window_start timestamp with time zone NOT NULL,
    count integer NOT NULL
);


ALTER TABLE public.rate_limits OWNER TO taf;

--
-- Name: rate_payments; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rate_payments (
    id integer NOT NULL,
    counselid integer,
    receiptid integer NOT NULL,
    propertyid integer,
    rateid integer,
    referenceno character varying(100) DEFAULT NULL::character varying,
    amount numeric(10,2) DEFAULT NULL::numeric,
    receiptdate date,
    method character varying(50) DEFAULT NULL::character varying,
    uploadedby character varying(100) DEFAULT NULL::character varying,
    screenshotpath text,
    createdby integer,
    gl_transaction_id integer,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL
);


ALTER TABLE public.rate_payments OWNER TO taf;

--
-- Name: rate_payments_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.rate_payments_id_seq OWNER TO taf;

--
-- Name: rate_payments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.rate_payments_id_seq OWNED BY public.rate_payments.id;


--
-- Name: ratepayers; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.ratepayers (
    id integer NOT NULL,
    counselid integer,
    ratepayerid integer NOT NULL,
    fullname character varying(255) DEFAULT NULL::character varying,
    previousowner character varying(255) DEFAULT NULL::character varying,
    tinnumber character varying(100) DEFAULT NULL::character varying,
    notes text,
    isdeceased boolean DEFAULT false,
    isoverseasowner boolean DEFAULT false,
    workplace character varying(255) DEFAULT NULL::character varying,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL
);


ALTER TABLE public.ratepayers OWNER TO taf;

--
-- Name: ratepayers_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.ratepayers_id_seq OWNER TO taf;

--
-- Name: ratepayers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.ratepayers_id_seq OWNED BY public.ratepayers.id;


--
-- Name: receipts; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.receipts (
    id integer NOT NULL,
    invoice_id integer,
    receipt_number character varying(100) NOT NULL,
    amount numeric(10,2) NOT NULL,
    payment_method character varying(50) DEFAULT NULL::character varying,
    cashier_id integer,
    session_id integer,
    payer_name character varying(255) DEFAULT NULL::character varying,
    receipt_date timestamp without time zone,
    reference character varying(255) DEFAULT NULL::character varying,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.receipts OWNER TO taf;

--
-- Name: receipts_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.receipts_id_seq OWNER TO taf;

--
-- Name: receipts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.receipts_id_seq OWNED BY public.receipts.id;


--
-- Name: refresh_tokens; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.refresh_tokens (
    token_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    session_id uuid NOT NULL,
    token_hash text NOT NULL,
    issued_at timestamp with time zone DEFAULT now() NOT NULL,
    expires_at timestamp with time zone NOT NULL,
    rotated_from uuid,
    revoked_at timestamp with time zone,
    revoke_reason text
);


ALTER TABLE public.refresh_tokens OWNER TO taf;

--
-- Name: reimbursement_claims; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.reimbursement_claims (
    id integer NOT NULL,
    employee_id integer NOT NULL,
    claim_date date NOT NULL,
    description text,
    amount numeric(10,2) NOT NULL,
    status character varying(100) DEFAULT 'Pending'::character varying,
    approved_at timestamp without time zone,
    approved_by integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.reimbursement_claims OWNER TO taf;

--
-- Name: reimbursement_claims_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.reimbursement_claims_id_seq OWNER TO taf;

--
-- Name: reimbursement_claims_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.reimbursement_claims_id_seq OWNED BY public.reimbursement_claims.id;


--
-- Name: reminder_statistics; Type: VIEW; Schema: public; Owner: taf
--

CREATE VIEW public.reminder_statistics AS
 SELECT org_id,
    count(*) AS total_reminders_sent,
    count(*) FILTER (WHERE (sent_at >= CURRENT_DATE)) AS sent_today,
    count(*) FILTER (WHERE (sent_at >= (CURRENT_DATE - '7 days'::interval))) AS sent_last_7_days,
    count(*) FILTER (WHERE (sent_at >= (CURRENT_DATE - '30 days'::interval))) AS sent_last_30_days,
    count(*) FILTER (WHERE (channel = 'email'::text)) AS email_count,
    count(*) FILTER (WHERE (channel = 'sms'::text)) AS sms_count,
    count(*) FILTER (WHERE (channel = 'portal'::text)) AS portal_count,
    count(*) FILTER (WHERE (status = 'delivered'::text)) AS delivered_count,
    count(*) FILTER (WHERE (status = 'opened'::text)) AS opened_count,
    count(*) FILTER (WHERE (status = 'clicked'::text)) AS clicked_count,
    count(*) FILTER (WHERE (status = 'failed'::text)) AS failed_count,
    count(*) FILTER (WHERE (status = 'bounced'::text)) AS bounced_count,
    round(((100.0 * (count(*) FILTER (WHERE (opened_at IS NOT NULL)))::numeric) / (NULLIF(count(*), 0))::numeric), 2) AS open_rate_pct,
    round(((100.0 * (count(*) FILTER (WHERE (clicked_at IS NOT NULL)))::numeric) / (NULLIF(count(*), 0))::numeric), 2) AS click_rate_pct,
    round(((100.0 * (count(*) FILTER (WHERE (status = 'delivered'::text)))::numeric) / (NULLIF(count(*), 0))::numeric), 2) AS delivery_rate_pct,
    count(*) FILTER (WHERE (reminder_stage = '7_days_before'::text)) AS stage_7_before,
    count(*) FILTER (WHERE (reminder_stage = 'due_date'::text)) AS stage_due_date,
    count(*) FILTER (WHERE (reminder_stage = '3_days_after'::text)) AS stage_3_after,
    count(*) FILTER (WHERE (reminder_stage = '7_days_after'::text)) AS stage_7_after,
    count(*) FILTER (WHERE (reminder_stage = '30_days_after'::text)) AS stage_30_after,
    max(sent_at) AS last_reminder_sent,
    min(sent_at) AS first_reminder_sent
   FROM public.payment_reminders
  WHERE (isdeleted = false)
  GROUP BY org_id;


ALTER VIEW public.reminder_statistics OWNER TO taf;

--
-- Name: VIEW reminder_statistics; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON VIEW public.reminder_statistics IS 'Aggregated payment reminder statistics and engagement metrics';


--
-- Name: resource_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.resource_types (
    id integer NOT NULL,
    code character varying(50) DEFAULT NULL::character varying,
    tenant_id integer,
    branch_id integer,
    description character varying(100) DEFAULT NULL::character varying,
    name character varying(100) NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.resource_types OWNER TO taf;

--
-- Name: resource_types_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.resource_types_id_seq OWNER TO taf;

--
-- Name: resource_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.resource_types_id_seq OWNED BY public.resource_types.id;


--
-- Name: resources; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.resources (
    id integer NOT NULL,
    resource_type_id integer NOT NULL,
    resource_id integer,
    tenant_id integer,
    branch_id integer,
    name character varying(255) DEFAULT NULL::character varying,
    description character varying(100) DEFAULT NULL::character varying,
    reference_table character varying(100) DEFAULT NULL::character varying,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.resources OWNER TO taf;

--
-- Name: resources_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.resources_id_seq OWNER TO taf;

--
-- Name: resources_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.resources_id_seq OWNED BY public.resources.id;


--
-- Name: revenue_by_customer; Type: VIEW; Schema: public; Owner: taf
--

CREATE VIEW public.revenue_by_customer AS
 SELECT c.customer_id,
    c.org_id,
    c.name AS customer_name,
    c.email,
    c.phone_number AS phone,
    count(DISTINCT i.invoice_id) AS total_invoices,
    count(DISTINCT
        CASE
            WHEN (i.status = 'paid'::text) THEN i.invoice_id
            ELSE NULL::uuid
        END) AS paid_invoices,
    COALESCE(sum(
        CASE
            WHEN (i.status = 'paid'::text) THEN i.amount
            ELSE NULL::numeric
        END), (0)::numeric) AS total_revenue,
    COALESCE(avg(
        CASE
            WHEN (i.status = 'paid'::text) THEN i.amount
            ELSE NULL::numeric
        END), (0)::numeric) AS avg_invoice_amount,
    COALESCE(sum(
        CASE
            WHEN ((i.status = 'paid'::text) AND (i.invoice_date >= (CURRENT_DATE - '30 days'::interval))) THEN i.amount
            ELSE NULL::numeric
        END), (0)::numeric) AS revenue_last_30_days,
    COALESCE(sum(
        CASE
            WHEN ((i.status = 'paid'::text) AND (i.invoice_date >= (CURRENT_DATE - '90 days'::interval))) THEN i.amount
            ELSE NULL::numeric
        END), (0)::numeric) AS revenue_last_90_days,
    COALESCE(sum(
        CASE
            WHEN ((i.status = 'paid'::text) AND (EXTRACT(year FROM i.invoice_date) = EXTRACT(year FROM CURRENT_DATE))) THEN i.amount
            ELSE NULL::numeric
        END), (0)::numeric) AS revenue_ytd,
    min(i.invoice_date) AS first_invoice_date,
    max(i.invoice_date) AS last_invoice_date,
        CASE
            WHEN (max(i.invoice_date) >= (CURRENT_DATE - '30 days'::interval)) THEN 'active'::text
            WHEN (max(i.invoice_date) >= (CURRENT_DATE - '90 days'::interval)) THEN 'recent'::text
            WHEN (max(i.invoice_date) >= (CURRENT_DATE - '180 days'::interval)) THEN 'inactive'::text
            ELSE 'dormant'::text
        END AS customer_status,
    c.updatedat AS customer_since
   FROM ((public.customers c
     LEFT JOIN public.quotations q ON (((c.customer_id = q.customer_id) AND (q.isdeleted = false))))
     LEFT JOIN public.invoices i ON (((q.quotation_id = i.reference_id) AND (i.reference_table = 'quotations'::text) AND (i.isdeleted = false))))
  WHERE (c.isdeleted = false)
  GROUP BY c.customer_id, c.org_id, c.name, c.email, c.phone_number, c.updatedat;


ALTER VIEW public.revenue_by_customer OWNER TO taf;

--
-- Name: VIEW revenue_by_customer; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON VIEW public.revenue_by_customer IS 'Customer revenue analysis with trends and status';


--
-- Name: revenue_by_product; Type: VIEW; Schema: public; Owner: taf
--

CREATE VIEW public.revenue_by_product AS
 SELECT product_id,
    org_id,
    name AS product_name,
    barcode AS sku,
    NULL::text AS category,
    price AS unit_price,
    (COALESCE(( SELECT count(DISTINCT li.invoice_id) AS count
           FROM (public.line_items li
             JOIN public.invoices i ON ((li.invoice_id = i.invoice_id)))
          WHERE ((li.product_id = p.product_id) AND (i.status = 'paid'::text) AND (i.isdeleted = false) AND (li.isdeleted = false))), (0)::bigint) + COALESCE(( SELECT count(DISTINCT lp.sales_receipt_id) AS count
           FROM public.lineitems_payments lp,
            LATERAL jsonb_array_elements(lp.line_items) item(value)
          WHERE ((((item.value ->> 'product_id'::text))::uuid = p.product_id) AND (lp.isdeleted = false))), (0)::bigint)) AS times_sold,
    (COALESCE(( SELECT sum(li.quantity) AS sum
           FROM (public.line_items li
             JOIN public.invoices i ON ((li.invoice_id = i.invoice_id)))
          WHERE ((li.product_id = p.product_id) AND (i.status = 'paid'::text) AND (i.isdeleted = false) AND (li.isdeleted = false))), (0)::bigint) + COALESCE(( SELECT sum(((item.value ->> 'quantity'::text))::integer) AS sum
           FROM public.lineitems_payments lp,
            LATERAL jsonb_array_elements(lp.line_items) item(value)
          WHERE ((((item.value ->> 'product_id'::text))::uuid = p.product_id) AND (lp.isdeleted = false))), (0)::bigint)) AS total_quantity_sold,
    ((COALESCE(( SELECT sum(li.totalamount) AS sum
           FROM (public.line_items li
             JOIN public.invoices i ON ((li.invoice_id = i.invoice_id)))
          WHERE ((li.product_id = p.product_id) AND (i.status = 'paid'::text) AND (i.isdeleted = false) AND (li.isdeleted = false))), (0)::bigint))::numeric + COALESCE(( SELECT sum(((item.value ->> 'total'::text))::numeric) AS sum
           FROM public.lineitems_payments lp,
            LATERAL jsonb_array_elements(lp.line_items) item(value)
          WHERE ((((item.value ->> 'product_id'::text))::uuid = p.product_id) AND (lp.isdeleted = false))), (0)::numeric)) AS total_revenue,
    price AS avg_selling_price,
    0 AS total_tax_collected,
    0 AS revenue_last_30_days,
    0 AS revenue_last_90_days,
    0 AS revenue_ytd,
    NULL::date AS first_sale_date,
    NULL::date AS last_sale_date,
    0 AS unique_customers,
    (quantity > 0) AS is_active,
    now() AS created_at
   FROM public.products p
  WHERE (isdeleted = false)
  GROUP BY product_id, org_id, name, barcode, price, quantity;


ALTER VIEW public.revenue_by_product OWNER TO taf;

--
-- Name: VIEW revenue_by_product; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON VIEW public.revenue_by_product IS 'Product/service revenue analysis combining invoice line items and POS sales receipts';


--
-- Name: revenue_trends_monthly; Type: VIEW; Schema: public; Owner: taf
--

CREATE VIEW public.revenue_trends_monthly AS
 SELECT i.org_id,
    date_trunc('month'::text, (i.invoice_date)::timestamp with time zone) AS month,
    EXTRACT(year FROM i.invoice_date) AS year,
    EXTRACT(month FROM i.invoice_date) AS month_num,
    count(DISTINCT i.invoice_id) AS invoice_count,
    count(DISTINCT q.customer_id) AS unique_customers,
    COALESCE(sum(i.amount), (0)::numeric) AS subtotal,
    COALESCE(sum(0), (0)::bigint) AS tax,
    COALESCE(sum(i.amount), (0)::numeric) AS total_revenue,
    COALESCE(sum(
        CASE
            WHEN (i.status = 'paid'::text) THEN i.amount
            ELSE NULL::numeric
        END), (0)::numeric) AS paid_revenue,
    COALESCE(sum(
        CASE
            WHEN (i.status = ANY (ARRAY['draft'::text, 'finalized'::text])) THEN i.amount
            ELSE NULL::numeric
        END), (0)::numeric) AS pending_revenue,
    COALESCE(avg(i.amount), (0)::numeric) AS avg_invoice_amount
   FROM (public.invoices i
     LEFT JOIN public.quotations q ON (((i.reference_table = 'quotations'::text) AND (i.reference_id = q.quotation_id))))
  WHERE ((i.isdeleted = false) AND (i.invoice_date >= (CURRENT_DATE - '2 years'::interval)))
  GROUP BY i.org_id, (date_trunc('month'::text, (i.invoice_date)::timestamp with time zone)), (EXTRACT(year FROM i.invoice_date)), (EXTRACT(month FROM i.invoice_date))
  ORDER BY (date_trunc('month'::text, (i.invoice_date)::timestamp with time zone)) DESC;


ALTER VIEW public.revenue_trends_monthly OWNER TO taf;

--
-- Name: VIEW revenue_trends_monthly; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON VIEW public.revenue_trends_monthly IS 'Monthly revenue trends for last 24 months';


--
-- Name: review_calibrations; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.review_calibrations (
    id integer NOT NULL,
    review_id integer NOT NULL,
    department character varying(255) NOT NULL,
    country_code character varying(5) DEFAULT NULL::character varying,
    original_rating numeric(3,2) DEFAULT NULL::numeric,
    adjusted_rating numeric(3,2) DEFAULT NULL::numeric,
    status character varying(20) DEFAULT 'pending'::character varying,
    moderator_id integer,
    approved_at timestamp without time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.review_calibrations OWNER TO taf;

--
-- Name: review_calibrations_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.review_calibrations_id_seq OWNER TO taf;

--
-- Name: review_calibrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.review_calibrations_id_seq OWNED BY public.review_calibrations.id;


--
-- Name: review_cycles; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.review_cycles (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    start_date date NOT NULL,
    end_date date NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.review_cycles OWNER TO taf;

--
-- Name: review_cycles_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.review_cycles_id_seq OWNER TO taf;

--
-- Name: review_cycles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.review_cycles_id_seq OWNED BY public.review_cycles.id;


--
-- Name: review_documents; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.review_documents (
    id integer NOT NULL,
    review_id integer NOT NULL,
    document_id uuid NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.review_documents OWNER TO taf;

--
-- Name: review_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.review_documents_id_seq OWNER TO taf;

--
-- Name: review_documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.review_documents_id_seq OWNED BY public.review_documents.id;


--
-- Name: review_schedules; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.review_schedules (
    id integer NOT NULL,
    tenant_id integer,
    country_code character varying(5) DEFAULT NULL::character varying,
    role_id integer,
    review_type character varying(50) NOT NULL,
    interval_days integer NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.review_schedules OWNER TO taf;

--
-- Name: review_schedules_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.review_schedules_id_seq OWNER TO taf;

--
-- Name: review_schedules_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.review_schedules_id_seq OWNED BY public.review_schedules.id;


--
-- Name: rfq_approval_instances; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_approval_instances (
    approval_instance_id uuid DEFAULT gen_random_uuid() NOT NULL,
    rfq_id uuid NOT NULL,
    stage_no integer DEFAULT 1 NOT NULL,
    approver_user_id uuid,
    approver_group_id uuid,
    status text DEFAULT 'pending'::text NOT NULL,
    decided_at timestamp with time zone,
    comments text,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rfq_approval_instances OWNER TO taf;

--
-- Name: rfq_approval_levels; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_approval_levels (
    rfq_approval_levels_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    branch_id uuid,
    department_id uuid,
    approver_user_id uuid NOT NULL,
    level_name text,
    min_amount numeric(12,2) DEFAULT 0.00,
    max_amount numeric(12,2) NOT NULL,
    currency text,
    notes text,
    is_active text DEFAULT 1 NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rfq_approval_levels OWNER TO taf;

--
-- Name: rfq_attachments; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_attachments (
    rfq_attachment_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    rfq_id uuid NOT NULL,
    label text,
    filetype text,
    file_url text,
    include_when text DEFAULT 'always'::text NOT NULL,
    sort_order integer DEFAULT 0 NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rfq_attachments OWNER TO taf;

--
-- Name: rfq_awards; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_awards (
    award_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    rfq_id uuid NOT NULL,
    scope text NOT NULL,
    rfq_item_id bigint,
    vendor_id uuid NOT NULL,
    notes text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT rfq_awards_scope_check CHECK ((scope = ANY (ARRAY['header'::text, 'item'::text])))
);


ALTER TABLE public.rfq_awards OWNER TO taf;

--
-- Name: rfq_contracts; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_contracts (
    contract_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    rfq_id uuid NOT NULL,
    vendor_id uuid NOT NULL,
    vendor_name text NOT NULL,
    contract_number text NOT NULL,
    title text NOT NULL,
    status text DEFAULT 'draft'::text NOT NULL,
    currency text,
    total_value numeric(18,2) DEFAULT 0,
    effective_date date,
    expiry_date date,
    contract_payload jsonb NOT NULL,
    created_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rfq_contracts OWNER TO taf;

--
-- Name: rfq_conversations; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_conversations (
    conversation_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    rfq_id uuid NOT NULL,
    audience text NOT NULL,
    vendor_id uuid,
    subject text,
    locked_at timestamp with time zone,
    created_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT rfq_conversations_audience_check CHECK ((audience = ANY (ARRAY['internal'::text, 'vendor'::text, 'all_vendors'::text])))
);


ALTER TABLE public.rfq_conversations OWNER TO taf;

--
-- Name: rfq_events; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_events (
    event_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    rfq_id uuid NOT NULL,
    actor_id uuid,
    actor_type text DEFAULT 'internal'::text NOT NULL,
    type text NOT NULL,
    payload jsonb DEFAULT '{}'::jsonb NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rfq_events OWNER TO taf;

--
-- Name: rfq_headers; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_headers (
    rfq_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid,
    department_id uuid,
    type text NOT NULL,
    rfq_number text,
    numbering_format text,
    title text NOT NULL,
    category text,
    currency text,
    incoterms text,
    summary_markdown text,
    summary_html text,
    publish_at timestamp with time zone,
    due_at timestamp with time zone NOT NULL,
    qa_cutoff_at timestamp with time zone,
    status text DEFAULT 'draft'::text NOT NULL,
    created_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    tender_box_opened_at timestamp with time zone,
    tender_box_opened_by uuid,
    scoring_config jsonb,
    requested_by uuid,
    approval_status text DEFAULT 'draft'::text NOT NULL,
    approval_started_at timestamp with time zone,
    approval_completed_at timestamp with time zone,
    CONSTRAINT rfq_headers_status_check CHECK ((status = ANY (ARRAY['draft'::text, 'open'::text, 'paused'::text, 'closed'::text, 'awarded'::text, 'archived'::text]))),
    CONSTRAINT rfq_headers_type_check CHECK ((type = ANY (ARRAY['RFQ'::text, 'EOI'::text])))
);


ALTER TABLE public.rfq_headers OWNER TO taf;

--
-- Name: rfq_invites; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_invites (
    invite_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    rfq_id uuid NOT NULL,
    vendor_id uuid NOT NULL,
    contact_id uuid,
    vendor_user_id uuid,
    channel text,
    status text DEFAULT 'invited'::text NOT NULL,
    sent_at timestamp with time zone,
    delivered_at timestamp with time zone,
    opened_at timestamp with time zone,
    responded_at timestamp with time zone,
    declined_reason text,
    reminder_count integer DEFAULT 0 NOT NULL,
    last_reminder_at timestamp with time zone,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT rfq_invites_status_check CHECK ((status = ANY (ARRAY['invited'::text, 'delivered'::text, 'opened'::text, 'responded'::text, 'declined'::text])))
);


ALTER TABLE public.rfq_invites OWNER TO taf;

--
-- Name: rfq_items; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_items (
    id bigint NOT NULL,
    rfq_id uuid NOT NULL,
    description text NOT NULL,
    quantity numeric(14,4),
    uom text,
    required_specs jsonb,
    delivery_terms text,
    delivery_location text,
    is_optional boolean DEFAULT false NOT NULL,
    item_attachments jsonb,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rfq_items OWNER TO taf;

--
-- Name: rfq_items_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.rfq_items_id_seq OWNER TO taf;

--
-- Name: rfq_items_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.rfq_items_id_seq OWNED BY public.rfq_items.id;


--
-- Name: rfq_message_attachments; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_message_attachments (
    message_attachment_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    message_id uuid NOT NULL,
    filetype text,
    file_url text,
    label text,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rfq_message_attachments OWNER TO taf;

--
-- Name: rfq_messages; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_messages (
    message_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    conversation_id uuid NOT NULL,
    rfq_id uuid NOT NULL,
    parent_message_id uuid,
    origin_message_id uuid,
    author_type text NOT NULL,
    author_user_id uuid,
    vendor_id uuid,
    category text DEFAULT 'note'::text NOT NULL,
    status text DEFAULT 'approved'::text NOT NULL,
    is_anonymous boolean DEFAULT false NOT NULL,
    body_markdown text NOT NULL,
    body_html text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT rfq_messages_author_type_check CHECK ((author_type = ANY (ARRAY['internal'::text, 'vendor'::text]))),
    CONSTRAINT rfq_messages_category_check CHECK ((category = ANY (ARRAY['note'::text, 'question'::text, 'answer'::text, 'announcement'::text, 'addendum'::text, 'clarification'::text, 'reply'::text]))),
    CONSTRAINT rfq_messages_status_check CHECK ((status = ANY (ARRAY['pending'::text, 'approved'::text, 'rejected'::text])))
);


ALTER TABLE public.rfq_messages OWNER TO taf;

--
-- Name: rfq_scoring_notes; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_scoring_notes (
    note_id uuid DEFAULT gen_random_uuid() NOT NULL,
    rfq_id uuid NOT NULL,
    vendor_id uuid NOT NULL,
    org_id uuid,
    criterion_key text NOT NULL,
    note_text text,
    created_by uuid,
    updated_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rfq_scoring_notes OWNER TO taf;

--
-- Name: rfq_sections; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_sections (
    rfq_section_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    rfq_id uuid NOT NULL,
    section_key text,
    heading text,
    body_markdown text,
    body_html text,
    sort_order integer DEFAULT 0 NOT NULL,
    include_in_print boolean DEFAULT true NOT NULL,
    include_in_email boolean DEFAULT true NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    content_type text DEFAULT 'text'::text,
    form_id integer,
    elements jsonb
);


ALTER TABLE public.rfq_sections OWNER TO taf;

--
-- Name: rfq_shortlists; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_shortlists (
    shortlist_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    rfq_id uuid NOT NULL,
    vendor_id uuid NOT NULL,
    org_id uuid,
    notes text,
    created_by uuid,
    updated_by uuid,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rfq_shortlists OWNER TO taf;

--
-- Name: rfq_template_attachments; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_template_attachments (
    rfq_template_attachment_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    rfq_template_id uuid NOT NULL,
    filetype character varying(50) NOT NULL,
    file_url text NOT NULL,
    label character varying(150) DEFAULT NULL::character varying,
    include_when character varying(50) DEFAULT 'always'::character varying,
    sort_order integer DEFAULT 0 NOT NULL,
    is_deleted boolean DEFAULT false NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rfq_template_attachments OWNER TO taf;

--
-- Name: rfq_template_sections; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_template_sections (
    rfq_template_section_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    rfq_template_id uuid NOT NULL,
    section_key character varying(50) NOT NULL,
    heading character varying(150) NOT NULL,
    body_markdown text,
    body_html text,
    sort_order integer DEFAULT 0 NOT NULL,
    is_required boolean DEFAULT false NOT NULL,
    include_in_print boolean DEFAULT true NOT NULL,
    include_in_email boolean DEFAULT true NOT NULL,
    is_deleted boolean DEFAULT false NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    content_type text DEFAULT 'text'::text,
    form_id integer,
    elements jsonb
);


ALTER TABLE public.rfq_template_sections OWNER TO taf;

--
-- Name: rfq_templates; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfq_templates (
    rfq_template_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid,
    name character varying(150) NOT NULL,
    code character varying(50),
    description text,
    category character varying(100) DEFAULT NULL::character varying,
    is_default boolean DEFAULT false NOT NULL,
    valid_from date,
    valid_until date,
    distribution_channels text[] DEFAULT '{}'::text[],
    created_by uuid,
    is_deleted boolean DEFAULT false NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.rfq_templates OWNER TO taf;

--
-- Name: rfqs; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.rfqs (
    id uuid NOT NULL,
    procurement_request_id uuid,
    vendor_id uuid,
    sent_at timestamp with time zone
);


ALTER TABLE public.rfqs OWNER TO taf;

--
-- Name: risk_assessment_files; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.risk_assessment_files (
    id integer NOT NULL,
    risk_assessment_id integer NOT NULL,
    file_path character varying(255) DEFAULT NULL::character varying,
    uploaded_by integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.risk_assessment_files OWNER TO taf;

--
-- Name: risk_assessment_files_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.risk_assessment_files_id_seq OWNER TO taf;

--
-- Name: risk_assessment_files_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.risk_assessment_files_id_seq OWNED BY public.risk_assessment_files.id;


--
-- Name: risk_assessment_hazards; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.risk_assessment_hazards (
    id integer NOT NULL,
    risk_assessment_id integer NOT NULL,
    hazard_description text,
    who_might_be_harmed text,
    existing_control_measures text,
    risk_rating_before integer,
    additional_controls text,
    residual_risk_rating integer,
    responsible_person character varying(255) DEFAULT NULL::character varying,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.risk_assessment_hazards OWNER TO taf;

--
-- Name: risk_assessment_hazards_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.risk_assessment_hazards_id_seq OWNER TO taf;

--
-- Name: risk_assessment_hazards_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.risk_assessment_hazards_id_seq OWNED BY public.risk_assessment_hazards.id;


--
-- Name: risk_assessment_ppe; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.risk_assessment_ppe (
    id integer NOT NULL,
    risk_assessment_id integer NOT NULL,
    checklist_item character varying(255) DEFAULT NULL::character varying,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.risk_assessment_ppe OWNER TO taf;

--
-- Name: risk_assessment_ppe_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.risk_assessment_ppe_id_seq OWNER TO taf;

--
-- Name: risk_assessment_ppe_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.risk_assessment_ppe_id_seq OWNED BY public.risk_assessment_ppe.id;


--
-- Name: risk_assessment_signoffs; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.risk_assessment_signoffs (
    id integer NOT NULL,
    risk_assessment_id integer NOT NULL,
    name character varying(255) DEFAULT NULL::character varying,
    "position" character varying(255) DEFAULT NULL::character varying,
    signature character varying(255) DEFAULT NULL::character varying,
    signed_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.risk_assessment_signoffs OWNER TO taf;

--
-- Name: risk_assessment_signoffs_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.risk_assessment_signoffs_id_seq OWNER TO taf;

--
-- Name: risk_assessment_signoffs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.risk_assessment_signoffs_id_seq OWNED BY public.risk_assessment_signoffs.id;


--
-- Name: risk_assessment_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.risk_assessment_types (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    description text,
    form_id integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.risk_assessment_types OWNER TO taf;

--
-- Name: risk_assessment_types_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.risk_assessment_types_id_seq OWNER TO taf;

--
-- Name: risk_assessment_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.risk_assessment_types_id_seq OWNED BY public.risk_assessment_types.id;


--
-- Name: risk_assessments; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.risk_assessments (
    id integer NOT NULL,
    risk_assessment_type_id integer,
    incident_id integer,
    title character varying(255) NOT NULL,
    department_id integer,
    location character varying(255) DEFAULT NULL::character varying,
    assessment_date date,
    review_date date,
    form_data jsonb,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.risk_assessments OWNER TO taf;

--
-- Name: risk_assessments_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.risk_assessments_id_seq OWNER TO taf;

--
-- Name: risk_assessments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.risk_assessments_id_seq OWNED BY public.risk_assessments.id;


--
-- Name: risk_categories; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.risk_categories (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    description text,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.risk_categories OWNER TO taf;

--
-- Name: risk_categories_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.risk_categories_id_seq OWNER TO taf;

--
-- Name: risk_categories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.risk_categories_id_seq OWNED BY public.risk_categories.id;


--
-- Name: risk_identifications; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.risk_identifications (
    id integer NOT NULL,
    risk_description text,
    risk_category_id integer,
    root_cause text,
    likelihood integer,
    impact integer,
    risk_rating character varying(255) DEFAULT NULL::character varying,
    current_controls text,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.risk_identifications OWNER TO taf;

--
-- Name: risk_identifications_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.risk_identifications_id_seq OWNER TO taf;

--
-- Name: risk_identifications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.risk_identifications_id_seq OWNED BY public.risk_identifications.id;


--
-- Name: role_competencies; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.role_competencies (
    id integer NOT NULL,
    role_id integer NOT NULL,
    competency_id integer NOT NULL,
    required_level integer NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL
);


ALTER TABLE public.role_competencies OWNER TO taf;

--
-- Name: role_competencies_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.role_competencies_id_seq OWNER TO taf;

--
-- Name: role_competencies_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.role_competencies_id_seq OWNED BY public.role_competencies.id;


--
-- Name: safety_alert_files; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.safety_alert_files (
    id integer NOT NULL,
    alert_id integer NOT NULL,
    file_path character varying(255) DEFAULT NULL::character varying,
    uploaded_by integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.safety_alert_files OWNER TO taf;

--
-- Name: safety_alert_files_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.safety_alert_files_id_seq OWNER TO taf;

--
-- Name: safety_alert_files_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.safety_alert_files_id_seq OWNED BY public.safety_alert_files.id;


--
-- Name: safety_alert_logs; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.safety_alert_logs (
    id integer NOT NULL,
    alert_id integer NOT NULL,
    action character varying(50) NOT NULL,
    details text,
    user_id integer,
    logged_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.safety_alert_logs OWNER TO taf;

--
-- Name: safety_alert_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.safety_alert_logs_id_seq OWNER TO taf;

--
-- Name: safety_alert_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.safety_alert_logs_id_seq OWNED BY public.safety_alert_logs.id;


--
-- Name: safety_alerts; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.safety_alerts (
    id integer NOT NULL,
    date date,
    "time" character varying(255) DEFAULT NULL::character varying,
    location character varying(255) DEFAULT NULL::character varying,
    classification character varying(100) DEFAULT 'general'::character varying NOT NULL,
    description text,
    status character varying(50) DEFAULT 'open'::character varying,
    investigator_id integer,
    submitted_by integer,
    form_data jsonb,
    tenant_id integer,
    branch_id integer,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL
);


ALTER TABLE public.safety_alerts OWNER TO taf;

--
-- Name: safety_alerts_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.safety_alerts_id_seq OWNER TO taf;

--
-- Name: safety_alerts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.safety_alerts_id_seq OWNED BY public.safety_alerts.id;


--
-- Name: safety_document_versions; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.safety_document_versions (
    id integer NOT NULL,
    document_id uuid NOT NULL,
    storage_key character varying(255) NOT NULL,
    version_number integer NOT NULL,
    version_hash character varying(64) DEFAULT NULL::character varying,
    created_at timestamp without time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.safety_document_versions OWNER TO taf;

--
-- Name: safety_document_versions_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.safety_document_versions_id_seq OWNER TO taf;

--
-- Name: safety_document_versions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.safety_document_versions_id_seq OWNED BY public.safety_document_versions.id;


--
-- Name: safety_documents; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.safety_documents (
    id integer NOT NULL,
    folder_id integer,
    title character varying(255) NOT NULL,
    description text,
    owner_id integer NOT NULL,
    connector_id integer,
    created_at timestamp without time zone,
    visible_to_roles character varying(255) DEFAULT NULL::character varying,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.safety_documents OWNER TO taf;

--
-- Name: safety_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.safety_documents_id_seq OWNER TO taf;

--
-- Name: safety_documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.safety_documents_id_seq OWNED BY public.safety_documents.id;


--
-- Name: safety_field_incidents; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.safety_field_incidents (
    id integer NOT NULL,
    incident_type character varying(100) DEFAULT NULL::character varying,
    location character varying(255) DEFAULT NULL::character varying,
    description text,
    document_ids character varying(255) DEFAULT NULL::character varying,
    gps character varying(255) DEFAULT NULL::character varying,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.safety_field_incidents OWNER TO taf;

--
-- Name: safety_field_incidents_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.safety_field_incidents_id_seq OWNER TO taf;

--
-- Name: safety_field_incidents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.safety_field_incidents_id_seq OWNED BY public.safety_field_incidents.id;


--
-- Name: safety_incident_files; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.safety_incident_files (
    id integer NOT NULL,
    incident_id integer NOT NULL,
    file_path character varying(255) DEFAULT NULL::character varying,
    uploaded_by integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.safety_incident_files OWNER TO taf;

--
-- Name: safety_incident_files_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.safety_incident_files_id_seq OWNER TO taf;

--
-- Name: safety_incident_files_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.safety_incident_files_id_seq OWNED BY public.safety_incident_files.id;


--
-- Name: safety_incident_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.safety_incident_types (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    form_id integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.safety_incident_types OWNER TO taf;

--
-- Name: safety_incident_types_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.safety_incident_types_id_seq OWNER TO taf;

--
-- Name: safety_incident_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.safety_incident_types_id_seq OWNED BY public.safety_incident_types.id;


--
-- Name: safety_incidents; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.safety_incidents (
    id integer NOT NULL,
    incident_type character varying(100) DEFAULT NULL::character varying,
    location character varying(255) DEFAULT NULL::character varying,
    description text,
    gps character varying(255) DEFAULT NULL::character varying,
    document_ids character varying(255) DEFAULT NULL::character varying,
    tenant_id integer,
    branch_id integer,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL
);


ALTER TABLE public.safety_incidents OWNER TO taf;

--
-- Name: safety_incidents_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.safety_incidents_id_seq OWNER TO taf;

--
-- Name: safety_incidents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.safety_incidents_id_seq OWNED BY public.safety_incidents.id;


--
-- Name: salaries; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.salaries (
    salary_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    org_id uuid NOT NULL,
    salary_type text NOT NULL,
    rate numeric NOT NULL,
    currency text DEFAULT 'FJD'::text,
    effective_date timestamp with time zone DEFAULT now() NOT NULL,
    end_date timestamp with time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT salaries_salary_type_check CHECK ((salary_type = ANY (ARRAY['hourly'::text, 'monthly'::text, 'contract'::text])))
);


ALTER TABLE public.salaries OWNER TO taf;

--
-- Name: sales_receipts; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.sales_receipts (
    sales_receipt_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid,
    type text,
    invoicenumber text,
    requestedby text,
    sdcdatetime timestamp with time zone,
    invoicecounter text,
    invoicecounterextension text,
    taxitems jsonb,
    verificationurl text,
    verificationqrcode text,
    journal text,
    messages text,
    signedby text,
    encryptedinternaldata text,
    signature text,
    totalcounter integer,
    transactiontypecounter integer,
    totalamount numeric(10,2) DEFAULT NULL::numeric,
    taxgrouprevision integer,
    businessname text,
    tin text,
    locationname text,
    address text,
    district text,
    mrc text,
    transactiontype text,
    data jsonb,
    "timestamp" bigint,
    taxcore_submission_id uuid,
    case_id uuid,
    invoice_id integer,
    buyer_id text,
    cashier_name text,
    cashier_id uuid,
    createdat timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.sales_receipts OWNER TO taf;

--
-- Name: COLUMN sales_receipts.case_id; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON COLUMN public.sales_receipts.case_id IS 'Links TaxCore transaction to a case in Case Management';


--
-- Name: COLUMN sales_receipts.invoice_id; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON COLUMN public.sales_receipts.invoice_id IS 'Links TaxCore transaction to an invoice';


--
-- Name: COLUMN sales_receipts.buyer_id; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON COLUMN public.sales_receipts.buyer_id IS 'Customer TIN for TaxCore transactions';


--
-- Name: COLUMN sales_receipts.cashier_name; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON COLUMN public.sales_receipts.cashier_name IS 'Name of cashier who processed the transaction';


--
-- Name: COLUMN sales_receipts.cashier_id; Type: COMMENT; Schema: public; Owner: taf
--

COMMENT ON COLUMN public.sales_receipts.cashier_id IS 'User ID of cashier who processed the transaction';


--
-- Name: sales_tax_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.sales_tax_types (
    salestax_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    country public.citext NOT NULL,
    name text NOT NULL,
    rate integer NOT NULL,
    code text NOT NULL,
    start_date timestamp with time zone,
    end_date timestamp with time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.sales_tax_types OWNER TO taf;

--
-- Name: scheduled_reports; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.scheduled_reports (
    id integer NOT NULL,
    tenant_id integer,
    branch_id integer,
    report_id integer NOT NULL,
    format character varying(10) DEFAULT 'csv'::character varying NOT NULL,
    recipients text,
    next_run timestamp without time zone NOT NULL,
    interval_days integer DEFAULT 1 NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.scheduled_reports OWNER TO taf;

--
-- Name: scheduled_reports_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.scheduled_reports_id_seq OWNER TO taf;

--
-- Name: scheduled_reports_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.scheduled_reports_id_seq OWNED BY public.scheduled_reports.id;


--
-- Name: service_connections; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.service_connections (
    id integer NOT NULL,
    tenant_id integer,
    user_id integer,
    branch_id integer,
    name character varying(100) NOT NULL,
    type character varying(50) NOT NULL,
    credentials text NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.service_connections OWNER TO taf;

--
-- Name: service_connections_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.service_connections_id_seq OWNER TO taf;

--
-- Name: service_connections_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.service_connections_id_seq OWNED BY public.service_connections.id;


--
-- Name: service_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.service_types (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    description text,
    make character varying(100) DEFAULT NULL::character varying,
    model character varying(100) DEFAULT NULL::character varying,
    type character varying(100) DEFAULT NULL::character varying,
    km_interval integer,
    month_interval integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.service_types OWNER TO taf;

--
-- Name: service_types_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.service_types_id_seq OWNER TO taf;

--
-- Name: service_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.service_types_id_seq OWNED BY public.service_types.id;


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

CREATE TABLE public.sessions (
    session_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    auth_level public.auth_level DEFAULT 'aal1'::public.auth_level NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    last_seen_at timestamp with time zone DEFAULT now() NOT NULL,
    expires_at timestamp with time zone NOT NULL,
    ip inet,
    user_agent text,
    mfa_completed_at timestamp with time zone
);


ALTER TABLE public.sessions OWNER TO taf;

--
-- Name: settings; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.settings (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    value text NOT NULL,
    category character varying(50) DEFAULT NULL::character varying,
    user_id integer,
    group_id integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.settings OWNER TO taf;

--
-- Name: settings_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.settings_id_seq OWNER TO taf;

--
-- Name: settings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.settings_id_seq OWNED BY public.settings.id;


--
-- Name: shift_swaps; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.shift_swaps (
    id integer NOT NULL,
    requester_id integer NOT NULL,
    target_employee_id integer NOT NULL,
    requester_shift_id integer NOT NULL,
    target_shift_id integer NOT NULL,
    status character varying(20) DEFAULT NULL::character varying,
    approved_by integer,
    approved_at timestamp without time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.shift_swaps OWNER TO taf;

--
-- Name: shift_swaps_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.shift_swaps_id_seq OWNER TO taf;

--
-- Name: shift_swaps_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.shift_swaps_id_seq OWNED BY public.shift_swaps.id;


--
-- Name: shifts; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.shifts (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    start_time time without time zone NOT NULL,
    end_time time without time zone NOT NULL,
    overtime_cap numeric(5,2) DEFAULT 0.00,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.shifts OWNER TO taf;

--
-- Name: shifts_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.shifts_id_seq OWNER TO taf;

--
-- Name: shifts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.shifts_id_seq OWNED BY public.shifts.id;


--
-- Name: software_info; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.software_info (
    software_info_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    manufacturer_name text,
    serial_number text,
    software_version text,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.software_info OWNER TO taf;

--
-- Name: storage_connectors; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.storage_connectors (
    storage_connector_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid,
    category_id uuid,
    name character varying(100) NOT NULL,
    type character varying(50) NOT NULL,
    credentials text NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.storage_connectors OWNER TO taf;

--
-- Name: supervisor_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.supervisor_types (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.supervisor_types OWNER TO taf;

--
-- Name: supervisor_types_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.supervisor_types_id_seq OWNER TO taf;

--
-- Name: supervisor_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.supervisor_types_id_seq OWNED BY public.supervisor_types.id;


--
-- Name: table_column_settings; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.table_column_settings (
    id integer NOT NULL,
    table_name character varying(100) NOT NULL,
    user_id integer,
    tenant_id integer,
    branch_id integer,
    hidden_columns jsonb,
    column_order json,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.table_column_settings OWNER TO taf;

--
-- Name: table_column_settings_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.table_column_settings_id_seq OWNER TO taf;

--
-- Name: table_column_settings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.table_column_settings_id_seq OWNED BY public.table_column_settings.id;


--
-- Name: table_views; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.table_views (
    id integer NOT NULL,
    form_id integer,
    table_name character varying(100) DEFAULT NULL::character varying,
    tenant_id integer,
    branch_id integer,
    category_id integer,
    name character varying(100) NOT NULL,
    columns json,
    sort_by character varying(100) DEFAULT NULL::character varying,
    sort_dir character varying(4) DEFAULT NULL::character varying,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.table_views OWNER TO taf;

--
-- Name: table_views_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.table_views_id_seq OWNER TO taf;

--
-- Name: table_views_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.table_views_id_seq OWNED BY public.table_views.id;


--
-- Name: tasks; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.tasks (
    id integer NOT NULL,
    employee_id integer NOT NULL,
    item_name character varying(100) DEFAULT NULL::character varying,
    manager_id integer,
    status character varying(100) DEFAULT 'pending'::character varying,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.tasks OWNER TO taf;

--
-- Name: tasks_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.tasks_id_seq OWNER TO taf;

--
-- Name: tasks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.tasks_id_seq OWNED BY public.tasks.id;


--
-- Name: tax_core_request; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.tax_core_request (
    id integer NOT NULL,
    buyer_id integer,
    buyer_cost_center_id integer,
    cashier character varying(100) DEFAULT NULL::character varying,
    invoice_number integer,
    date_and_time_of_issue character varying(100) DEFAULT NULL::character varying,
    invoice_type character varying(100) DEFAULT NULL::character varying,
    transaction_type character varying(100) DEFAULT NULL::character varying,
    referent_document_number integer,
    payment jsonb,
    options character varying(100) DEFAULT NULL::character varying,
    items character varying(250) DEFAULT NULL::character varying,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.tax_core_request OWNER TO taf;

--
-- Name: tax_core_request_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.tax_core_request_id_seq OWNER TO taf;

--
-- Name: tax_core_request_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.tax_core_request_id_seq OWNED BY public.tax_core_request.id;


--
-- Name: tax_core_response; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.tax_core_response (
    id integer NOT NULL,
    invoicenumber text,
    requestedby text,
    sdcdatetime timestamp with time zone,
    invoicecounter text,
    invoicecounterextension text,
    taxitems jsonb,
    verificationurl text,
    verificationqrcode text,
    journal text,
    messages text,
    signedby text,
    encryptedinternaldata text,
    signature text,
    totalcounter integer,
    transactiontypecounter integer,
    totalamount integer,
    taxgrouprevision integer,
    businessname text,
    tin text,
    locationname text,
    address text,
    district text,
    mrc text,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.tax_core_response OWNER TO taf;

--
-- Name: tax_core_response_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.tax_core_response_id_seq OWNER TO taf;

--
-- Name: tax_core_response_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.tax_core_response_id_seq OWNED BY public.tax_core_response.id;


--
-- Name: tax_ledger; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.tax_ledger (
    id integer NOT NULL,
    payroll_run_id integer NOT NULL,
    employee_id integer NOT NULL,
    tax_type character varying(50) NOT NULL,
    amount numeric(10,2) NOT NULL,
    ytd_total numeric(10,2) NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.tax_ledger OWNER TO taf;

--
-- Name: tax_ledger_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.tax_ledger_id_seq OWNER TO taf;

--
-- Name: tax_ledger_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.tax_ledger_id_seq OWNED BY public.tax_ledger.id;


--
-- Name: taxcore_configurations; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.taxcore_configurations (
    taxcore_config_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid NOT NULL,
    certificate_path text NOT NULL,
    certificate_password text NOT NULL,
    api_base_url text DEFAULT 'https://vsdc-uat.frcs.org.fj'::text NOT NULL,
    api_timeout_seconds integer DEFAULT 30 NOT NULL,
    tin text NOT NULL,
    business_name text NOT NULL,
    location_name text,
    mrc text,
    pos_number text DEFAULT 'POS-01'::text,
    is_active boolean DEFAULT true NOT NULL,
    auto_submit boolean DEFAULT true NOT NULL,
    submit_delay_seconds integer DEFAULT 0,
    last_submission_at timestamp with time zone,
    certificate_expires_at date,
    certificate_last_validated_at timestamp with time zone,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    created_by uuid
);


ALTER TABLE public.taxcore_configurations OWNER TO taf;

--
-- Name: taxcore_queue; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.taxcore_queue (
    queue_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    submission_id uuid NOT NULL,
    org_id uuid NOT NULL,
    retry_count integer DEFAULT 0 NOT NULL,
    max_retries integer DEFAULT 5 NOT NULL,
    next_retry_at timestamp with time zone NOT NULL,
    backoff_multiplier numeric(3,1) DEFAULT 2.0 NOT NULL,
    base_delay_minutes integer DEFAULT 5 NOT NULL,
    priority integer DEFAULT 5 NOT NULL,
    status text DEFAULT 'queued'::text NOT NULL,
    locked_by text,
    locked_at timestamp with time zone,
    last_error text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    processed_at timestamp with time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    CONSTRAINT taxcore_queue_status_check CHECK ((status = ANY (ARRAY['queued'::text, 'processing'::text, 'completed'::text, 'failed'::text, 'cancelled'::text])))
);


ALTER TABLE public.taxcore_queue OWNER TO taf;

--
-- Name: taxcore_submissions; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.taxcore_submissions (
    submission_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid NOT NULL,
    reference_table text NOT NULL,
    reference_id uuid NOT NULL,
    submission_type text NOT NULL,
    invoice_number text,
    total_amount numeric(10,2) NOT NULL,
    request_payload jsonb NOT NULL,
    response_payload jsonb,
    taxcore_invoice_number text,
    taxcore_qr_code text,
    taxcore_verification_url text,
    taxcore_journal text,
    taxcore_signature text,
    status text DEFAULT 'pending'::text NOT NULL,
    attempts integer DEFAULT 0 NOT NULL,
    last_attempt_at timestamp with time zone,
    error_message text,
    http_status_code integer,
    submitted_by uuid,
    submission_source text DEFAULT 'system'::text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    completed_at timestamp with time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT taxcore_submissions_status_check CHECK ((status = ANY (ARRAY['pending'::text, 'submitted'::text, 'success'::text, 'failed'::text, 'retrying'::text])))
);


ALTER TABLE public.taxcore_submissions OWNER TO taf;

--
-- Name: tenant_admins; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.tenant_admins (
    id integer NOT NULL,
    tenant_id integer NOT NULL,
    admin_user_id integer NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.tenant_admins OWNER TO taf;

--
-- Name: tenant_admins_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.tenant_admins_id_seq OWNER TO taf;

--
-- Name: tenant_admins_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.tenant_admins_id_seq OWNED BY public.tenant_admins.id;


--
-- Name: tenant_idp_configs; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.tenant_idp_configs (
    root_org_id uuid NOT NULL,
    provider_code text NOT NULL,
    enabled boolean DEFAULT true NOT NULL,
    config_json jsonb NOT NULL,
    mapping_json jsonb
);


ALTER TABLE public.tenant_idp_configs OWNER TO taf;

--
-- Name: tenant_module_settings; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.tenant_module_settings (
    id integer NOT NULL,
    tenant_id integer NOT NULL,
    branch_id integer,
    module_id integer NOT NULL,
    name character varying(100) NOT NULL,
    value text NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.tenant_module_settings OWNER TO taf;

--
-- Name: tenant_module_settings_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.tenant_module_settings_id_seq OWNER TO taf;

--
-- Name: tenant_module_settings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.tenant_module_settings_id_seq OWNED BY public.tenant_module_settings.id;


--
-- Name: tenant_modules; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.tenant_modules (
    id integer NOT NULL,
    tenant_id integer NOT NULL,
    branch_id integer,
    module_id integer NOT NULL,
    enabled boolean DEFAULT true NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.tenant_modules OWNER TO taf;

--
-- Name: tenant_modules_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.tenant_modules_id_seq OWNER TO taf;

--
-- Name: tenant_modules_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.tenant_modules_id_seq OWNED BY public.tenant_modules.id;


--
-- Name: tenant_tables; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.tenant_tables (
    id integer NOT NULL,
    tenant_id integer,
    user_id integer,
    table_name character varying(100) NOT NULL,
    definition jsonb NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.tenant_tables OWNER TO taf;

--
-- Name: tenant_tables_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.tenant_tables_id_seq OWNER TO taf;

--
-- Name: tenant_tables_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.tenant_tables_id_seq OWNED BY public.tenant_tables.id;


--
-- Name: tenants; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.tenants (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    subdomain character varying(100) DEFAULT NULL::character varying,
    custom_domain character varying(255) DEFAULT NULL::character varying,
    logo character varying(255) DEFAULT NULL::character varying,
    product_name character varying(255) DEFAULT NULL::character varying,
    dashboard_name character varying(255) DEFAULT NULL::character varying,
    settings json,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.tenants OWNER TO taf;

--
-- Name: tenants_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.tenants_id_seq OWNER TO taf;

--
-- Name: tenants_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.tenants_id_seq OWNED BY public.tenants.id;


--
-- Name: time_clock_aggregates; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.time_clock_aggregates (
    time_clock_aggregate_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid,
    user_id uuid NOT NULL,
    start_date date NOT NULL,
    end_date date NOT NULL,
    total_duration_minutes integer DEFAULT 0,
    total_net_minutes integer DEFAULT 0,
    total_overtime_minutes integer DEFAULT 0,
    total_regular_minutes integer DEFAULT 0,
    total_payable_minutes integer DEFAULT 0,
    total_days_worked integer DEFAULT 0,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.time_clock_aggregates OWNER TO taf;

--
-- Name: time_clocks; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.time_clocks (
    time_clocks_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid,
    user_id uuid NOT NULL,
    clock_type character varying(50) NOT NULL,
    valid_gps boolean DEFAULT false NOT NULL,
    location_id integer,
    locationapproved boolean DEFAULT false NOT NULL,
    security_type character varying(50) NOT NULL,
    clocked_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.time_clocks OWNER TO taf;

--
-- Name: time_entries; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.time_entries (
    time_entry_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    reference_id uuid,
    reference_table text,
    approved boolean DEFAULT false NOT NULL,
    user_id uuid NOT NULL,
    instructions text,
    hours numeric(8,2) DEFAULT 0 NOT NULL,
    date date,
    rate numeric(10,2) DEFAULT 0 NOT NULL,
    vat_rate numeric(5,4) DEFAULT 0.125 NOT NULL,
    description text,
    billed_to_client boolean DEFAULT false NOT NULL,
    added_to_cost_schedule boolean DEFAULT false NOT NULL,
    billable boolean DEFAULT false NOT NULL,
    status text DEFAULT 'Pending'::text NOT NULL,
    work_type_id uuid,
    title text,
    approval_comment text,
    comments text,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.time_entries OWNER TO taf;

--
-- Name: timesheets; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.timesheets (
    id integer NOT NULL,
    tenant_id integer,
    branch_id integer,
    user_id integer NOT NULL,
    date date NOT NULL,
    standard_hours numeric(5,2) DEFAULT 0.00 NOT NULL,
    overtime_hours numeric(5,2) DEFAULT 0.00 NOT NULL,
    break_hours numeric(5,2) DEFAULT 0.00 NOT NULL,
    supervisor_id integer,
    supervisor_type character varying(50) DEFAULT NULL::character varying,
    work_id integer,
    approval_comment text,
    approved boolean DEFAULT false NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.timesheets OWNER TO taf;

--
-- Name: timesheets_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.timesheets_id_seq OWNER TO taf;

--
-- Name: timesheets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.timesheets_id_seq OWNED BY public.timesheets.id;


--
-- Name: training_answers; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_answers (
    id integer NOT NULL,
    question_id integer NOT NULL,
    answer text NOT NULL,
    tenant_id integer,
    branch_id integer,
    is_correct boolean DEFAULT false NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_answers OWNER TO taf;

--
-- Name: training_answers_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_answers_id_seq OWNER TO taf;

--
-- Name: training_answers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_answers_id_seq OWNED BY public.training_answers.id;


--
-- Name: training_badges; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_badges (
    id integer NOT NULL,
    employee_id integer NOT NULL,
    course_id integer NOT NULL,
    badge_name character varying(255) NOT NULL,
    issued_at date NOT NULL,
    expires_at date,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_badges OWNER TO taf;

--
-- Name: training_badges_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_badges_id_seq OWNER TO taf;

--
-- Name: training_badges_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_badges_id_seq OWNED BY public.training_badges.id;


--
-- Name: training_bookmarks; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_bookmarks (
    id integer NOT NULL,
    employee_id integer NOT NULL,
    content_id integer NOT NULL,
    "position" character varying(255) DEFAULT NULL::character varying,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_bookmarks OWNER TO taf;

--
-- Name: training_bookmarks_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_bookmarks_id_seq OWNER TO taf;

--
-- Name: training_bookmarks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_bookmarks_id_seq OWNED BY public.training_bookmarks.id;


--
-- Name: training_categories; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_categories (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    description text,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_categories OWNER TO taf;

--
-- Name: training_categories_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_categories_id_seq OWNER TO taf;

--
-- Name: training_categories_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_categories_id_seq OWNED BY public.training_categories.id;


--
-- Name: training_certificates; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_certificates (
    id integer NOT NULL,
    user_id integer,
    certificate_name character varying(255) DEFAULT NULL::character varying,
    category character varying(255) DEFAULT NULL::character varying,
    issued_at date NOT NULL,
    expires_at date,
    expiry_date date,
    renewal_required boolean DEFAULT false NOT NULL,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_certificates OWNER TO taf;

--
-- Name: training_certificates_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_certificates_id_seq OWNER TO taf;

--
-- Name: training_certificates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_certificates_id_seq OWNED BY public.training_certificates.id;


--
-- Name: training_contents; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_contents (
    id integer NOT NULL,
    course_id integer NOT NULL,
    title character varying(255) DEFAULT NULL::character varying,
    file_path character varying(255) DEFAULT NULL::character varying,
    caption_path character varying(255) DEFAULT NULL::character varying,
    language_code character varying(10) DEFAULT NULL::character varying,
    url character varying(255) DEFAULT NULL::character varying,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_contents OWNER TO taf;

--
-- Name: training_contents_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_contents_id_seq OWNER TO taf;

--
-- Name: training_contents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_contents_id_seq OWNED BY public.training_contents.id;


--
-- Name: training_courses; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_courses (
    id integer NOT NULL,
    title character varying(255) NOT NULL,
    description text,
    duration integer,
    recertification_interval integer,
    category_id integer,
    prerequisites text,
    target_audience text,
    language_code character varying(10) DEFAULT NULL::character varying,
    country_id integer,
    content_host character varying(50) DEFAULT NULL::character varying,
    external_lms_url character varying(255) DEFAULT NULL::character varying,
    lms_host character varying(255) DEFAULT NULL::character varying,
    lms_api_key character varying(255) DEFAULT NULL::character varying,
    archived boolean DEFAULT false NOT NULL,
    mandatory boolean DEFAULT false NOT NULL,
    createdby integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_courses OWNER TO taf;

--
-- Name: training_courses_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_courses_id_seq OWNER TO taf;

--
-- Name: training_courses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_courses_id_seq OWNED BY public.training_courses.id;


--
-- Name: training_enrollments; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_enrollments (
    id integer NOT NULL,
    employee_id integer NOT NULL,
    session_id integer NOT NULL,
    status character varying(100) DEFAULT 'Enrolled'::character varying,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_enrollments OWNER TO taf;

--
-- Name: training_enrollments_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_enrollments_id_seq OWNER TO taf;

--
-- Name: training_enrollments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_enrollments_id_seq OWNED BY public.training_enrollments.id;


--
-- Name: training_feedback; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_feedback (
    id integer NOT NULL,
    enrollment_id integer NOT NULL,
    rating integer,
    comments text,
    signature_path character varying(255) DEFAULT NULL::character varying,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_feedback OWNER TO taf;

--
-- Name: training_feedback_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_feedback_id_seq OWNER TO taf;

--
-- Name: training_feedback_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_feedback_id_seq OWNED BY public.training_feedback.id;


--
-- Name: training_path_courses; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_path_courses (
    id integer NOT NULL,
    path_id integer NOT NULL,
    course_id integer NOT NULL,
    sequence integer NOT NULL,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_path_courses OWNER TO taf;

--
-- Name: training_path_courses_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_path_courses_id_seq OWNER TO taf;

--
-- Name: training_path_courses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_path_courses_id_seq OWNED BY public.training_path_courses.id;


--
-- Name: training_paths; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_paths (
    id integer NOT NULL,
    tenant_id integer,
    branch_id integer,
    country_id integer,
    department_id integer,
    role_id integer,
    name character varying(255) NOT NULL,
    description text,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_paths OWNER TO taf;

--
-- Name: training_paths_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_paths_id_seq OWNER TO taf;

--
-- Name: training_paths_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_paths_id_seq OWNED BY public.training_paths.id;


--
-- Name: training_questions; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_questions (
    id integer NOT NULL,
    quiz_id integer NOT NULL,
    question text NOT NULL,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_questions OWNER TO taf;

--
-- Name: training_questions_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_questions_id_seq OWNER TO taf;

--
-- Name: training_questions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_questions_id_seq OWNED BY public.training_questions.id;


--
-- Name: training_quizzes; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_quizzes (
    id integer NOT NULL,
    course_id integer NOT NULL,
    passing_score numeric(5,2) DEFAULT 0.00,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_quizzes OWNER TO taf;

--
-- Name: training_quizzes_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_quizzes_id_seq OWNER TO taf;

--
-- Name: training_quizzes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_quizzes_id_seq OWNED BY public.training_quizzes.id;


--
-- Name: training_results; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_results (
    id integer NOT NULL,
    enrollment_id integer NOT NULL,
    score numeric(5,2) DEFAULT NULL::numeric,
    completed boolean DEFAULT false,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_results OWNER TO taf;

--
-- Name: training_results_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_results_id_seq OWNER TO taf;

--
-- Name: training_results_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_results_id_seq OWNED BY public.training_results.id;


--
-- Name: training_sessions; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.training_sessions (
    id integer NOT NULL,
    course_id integer NOT NULL,
    start_date timestamp without time zone NOT NULL,
    end_date timestamp without time zone,
    location character varying(255) DEFAULT NULL::character varying,
    createdby integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.training_sessions OWNER TO taf;

--
-- Name: training_sessions_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.training_sessions_id_seq OWNER TO taf;

--
-- Name: training_sessions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.training_sessions_id_seq OWNED BY public.training_sessions.id;


--
-- Name: user_2fa; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_2fa (
    id integer NOT NULL,
    provider character varying(100) DEFAULT NULL::character varying,
    provider_user_id character varying(255) DEFAULT NULL::character varying,
    email character varying(255) DEFAULT NULL::character varying,
    name character varying(255) DEFAULT NULL::character varying,
    profile_pic text,
    linked_at timestamp without time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_2fa OWNER TO taf;

--
-- Name: user_2fa_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.user_2fa_id_seq OWNER TO taf;

--
-- Name: user_2fa_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.user_2fa_id_seq OWNED BY public.user_2fa.id;


--
-- Name: user_board_settings; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_board_settings (
    id integer NOT NULL,
    user_id integer NOT NULL,
    board_id integer NOT NULL,
    column_order json,
    hidden_columns json,
    selected boolean DEFAULT false NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_board_settings OWNER TO taf;

--
-- Name: user_board_settings_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.user_board_settings_id_seq OWNER TO taf;

--
-- Name: user_board_settings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.user_board_settings_id_seq OWNED BY public.user_board_settings.id;


--
-- Name: user_branch_memberships; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_branch_memberships (
    membership_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    branch_id uuid NOT NULL,
    role text,
    options jsonb,
    joined_at timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_branch_memberships OWNER TO taf;

--
-- Name: user_column_permissions; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_column_permissions (
    user_column_permission_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    table_name text NOT NULL,
    column_name text NOT NULL,
    access_mode text NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT user_column_permissions_access_mode_check CHECK ((access_mode = ANY (ARRAY['hidden'::text, 'readonly'::text, 'readwrite'::text])))
);


ALTER TABLE public.user_column_permissions OWNER TO taf;

--
-- Name: user_emails; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_emails (
    user_email_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    email public.citext NOT NULL,
    is_primary boolean DEFAULT false NOT NULL,
    verified_at timestamp with time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_emails OWNER TO taf;

--
-- Name: user_faces; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_faces (
    id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    image_path text NOT NULL,
    embedding text NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_faces OWNER TO taf;

--
-- Name: user_group_memberships; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_group_memberships (
    membership_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    group_id uuid NOT NULL,
    role character varying(100) DEFAULT NULL::character varying,
    joined_at timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_group_memberships OWNER TO taf;

--
-- Name: user_identities; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_identities (
    provider_code text NOT NULL,
    subject text NOT NULL,
    user_id uuid NOT NULL,
    email_at_auth public.citext,
    claims_json jsonb,
    linked_at timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_identities OWNER TO taf;

--
-- Name: user_mfa_factors; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_mfa_factors (
    factor_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    type public.mfa_type NOT NULL,
    label text,
    is_primary boolean DEFAULT false NOT NULL,
    enabled boolean DEFAULT true NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    last_used_at timestamp with time zone,
    isdeleted boolean DEFAULT false NOT NULL
);


ALTER TABLE public.user_mfa_factors OWNER TO taf;

--
-- Name: user_mfa_totp; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_mfa_totp (
    factor_id uuid NOT NULL,
    secret_b32 text NOT NULL,
    iv text NOT NULL,
    tag text NOT NULL,
    issuer text DEFAULT 'Cybex'::text NOT NULL,
    period smallint DEFAULT 30 NOT NULL,
    digits smallint DEFAULT 6 NOT NULL,
    algo text DEFAULT 'SHA1'::text NOT NULL
);


ALTER TABLE public.user_mfa_totp OWNER TO taf;

--
-- Name: user_mfa_webauthn; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_mfa_webauthn (
    factor_id uuid NOT NULL,
    credential_id text NOT NULL,
    public_key text NOT NULL,
    sign_count bigint DEFAULT 0 NOT NULL,
    transports jsonb,
    last_counter bigint,
    aaguid uuid
);


ALTER TABLE public.user_mfa_webauthn OWNER TO taf;

--
-- Name: user_module_permissions; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_module_permissions (
    user_module_permission_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    module_id uuid NOT NULL,
    action text DEFAULT 'deny'::text NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_module_permissions OWNER TO taf;

--
-- Name: user_org_memberships; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_org_memberships (
    membership_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    org_id uuid NOT NULL,
    role text,
    options jsonb,
    joined_at timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_org_memberships OWNER TO taf;

--
-- Name: user_passkeys; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_passkeys (
    id integer NOT NULL,
    user_id integer NOT NULL,
    credential_id character varying(255) DEFAULT NULL::character varying,
    public_key text,
    created_at timestamp without time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_passkeys OWNER TO taf;

--
-- Name: user_passkeys_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.user_passkeys_id_seq OWNER TO taf;

--
-- Name: user_passkeys_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.user_passkeys_id_seq OWNED BY public.user_passkeys.id;


--
-- Name: user_passwords; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_passwords (
    user_id uuid NOT NULL,
    password_hash text NOT NULL,
    algo text NOT NULL,
    expires timestamp with time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    must_rotate boolean DEFAULT false NOT NULL
);


ALTER TABLE public.user_passwords OWNER TO taf;

--
-- Name: user_phones; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_phones (
    phone_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    phone_number text NOT NULL,
    is_primary boolean DEFAULT false NOT NULL,
    verified_at timestamp with time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_phones OWNER TO taf;

--
-- Name: user_recovery_codes; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_recovery_codes (
    user_id uuid NOT NULL,
    code_hash text NOT NULL,
    used_at timestamp with time zone
);


ALTER TABLE public.user_recovery_codes OWNER TO taf;

--
-- Name: user_settings; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_settings (
    id integer NOT NULL,
    user_id integer NOT NULL,
    name character varying(100) NOT NULL,
    value text NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_settings OWNER TO taf;

--
-- Name: user_settings_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.user_settings_id_seq OWNER TO taf;

--
-- Name: user_settings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.user_settings_id_seq OWNED BY public.user_settings.id;


--
-- Name: user_table_permissions; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_table_permissions (
    user_table_permission_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    table_name text NOT NULL,
    access_mode text NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT user_table_permissions_access_mode_check CHECK ((access_mode = ANY (ARRAY['hidden'::text, 'readonly'::text, 'readwrite'::text])))
);


ALTER TABLE public.user_table_permissions OWNER TO taf;

--
-- Name: user_tokens; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.user_tokens (
    id integer NOT NULL,
    user_id integer NOT NULL,
    refresh_token character varying(255) NOT NULL,
    expires_at timestamp without time zone NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.user_tokens OWNER TO taf;

--
-- Name: user_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.user_tokens_id_seq OWNER TO taf;

--
-- Name: user_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.user_tokens_id_seq OWNED BY public.user_tokens.id;


--
-- Name: users_profiles; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.users_profiles (
    user_profile_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    user_id uuid NOT NULL,
    title text,
    address text,
    phone_number text,
    email text,
    date_of_birth date,
    profile_pic text,
    notes text,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.users_profiles OWNER TO taf;

--
-- Name: vehicle_makes; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vehicle_makes (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vehicle_makes OWNER TO taf;

--
-- Name: vehicle_makes_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.vehicle_makes_id_seq OWNER TO taf;

--
-- Name: vehicle_makes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.vehicle_makes_id_seq OWNED BY public.vehicle_makes.id;


--
-- Name: vehicle_models; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vehicle_models (
    id integer NOT NULL,
    make_id integer,
    name character varying(100) NOT NULL,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vehicle_models OWNER TO taf;

--
-- Name: vehicle_models_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.vehicle_models_id_seq OWNER TO taf;

--
-- Name: vehicle_models_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.vehicle_models_id_seq OWNED BY public.vehicle_models.id;


--
-- Name: vehicle_report_comments; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vehicle_report_comments (
    id integer NOT NULL,
    report_id integer NOT NULL,
    user_id integer NOT NULL,
    comment text NOT NULL,
    tenant_id integer,
    branch_id integer,
    created_at timestamp without time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vehicle_report_comments OWNER TO taf;

--
-- Name: vehicle_report_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.vehicle_report_comments_id_seq OWNER TO taf;

--
-- Name: vehicle_report_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.vehicle_report_comments_id_seq OWNED BY public.vehicle_report_comments.id;


--
-- Name: vehicle_report_parts; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vehicle_report_parts (
    id integer NOT NULL,
    report_id integer NOT NULL,
    part_name character varying(255) NOT NULL,
    quantity integer,
    repair_cost numeric(10,2) DEFAULT NULL::numeric,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vehicle_report_parts OWNER TO taf;

--
-- Name: vehicle_report_parts_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.vehicle_report_parts_id_seq OWNER TO taf;

--
-- Name: vehicle_report_parts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.vehicle_report_parts_id_seq OWNED BY public.vehicle_report_parts.id;


--
-- Name: vehicle_reports; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vehicle_reports (
    id integer NOT NULL,
    vehicle_id integer NOT NULL,
    driver_id integer,
    report_type character varying(100) DEFAULT NULL::character varying,
    description text,
    status character varying(50) DEFAULT NULL::character varying,
    assigned_to integer,
    tenant_id integer,
    branch_id integer,
    created_at timestamp without time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vehicle_reports OWNER TO taf;

--
-- Name: vehicle_reports_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.vehicle_reports_id_seq OWNER TO taf;

--
-- Name: vehicle_reports_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.vehicle_reports_id_seq OWNED BY public.vehicle_reports.id;


--
-- Name: vehicle_services; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vehicle_services (
    id integer NOT NULL,
    vehicle_id integer NOT NULL,
    service_type_id integer NOT NULL,
    service_date date,
    odometer integer,
    notes text,
    cost numeric(10,2) DEFAULT NULL::numeric,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vehicle_services OWNER TO taf;

--
-- Name: vehicle_services_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.vehicle_services_id_seq OWNER TO taf;

--
-- Name: vehicle_services_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.vehicle_services_id_seq OWNED BY public.vehicle_services.id;


--
-- Name: vehicle_trip_points; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vehicle_trip_points (
    id integer NOT NULL,
    trip_id integer NOT NULL,
    latitude numeric(10,6) NOT NULL,
    longitude numeric(10,6) NOT NULL,
    recorded_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vehicle_trip_points OWNER TO taf;

--
-- Name: vehicle_trip_points_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.vehicle_trip_points_id_seq OWNER TO taf;

--
-- Name: vehicle_trip_points_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.vehicle_trip_points_id_seq OWNED BY public.vehicle_trip_points.id;


--
-- Name: vehicle_trips; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vehicle_trips (
    id integer NOT NULL,
    vehicle_id integer NOT NULL,
    driver_id integer,
    trip_date date,
    start_time timestamp without time zone,
    end_time timestamp without time zone,
    start_location character varying(255) DEFAULT NULL::character varying,
    start_latitude numeric(10,6) DEFAULT NULL::numeric,
    start_longitude numeric(10,6) DEFAULT NULL::numeric,
    end_location character varying(255) DEFAULT NULL::character varying,
    end_latitude numeric(10,6) DEFAULT NULL::numeric,
    end_longitude numeric(10,6) DEFAULT NULL::numeric,
    distance_km integer,
    status character varying(20) DEFAULT 'Draft'::character varying,
    start_mileage integer,
    end_mileage integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vehicle_trips OWNER TO taf;

--
-- Name: vehicle_trips_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.vehicle_trips_id_seq OWNER TO taf;

--
-- Name: vehicle_trips_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.vehicle_trips_id_seq OWNED BY public.vehicle_trips.id;


--
-- Name: vehicle_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vehicle_types (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vehicle_types OWNER TO taf;

--
-- Name: vehicle_types_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.vehicle_types_id_seq OWNER TO taf;

--
-- Name: vehicle_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.vehicle_types_id_seq OWNED BY public.vehicle_types.id;


--
-- Name: vehicles; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vehicles (
    id integer NOT NULL,
    make character varying(100) DEFAULT NULL::character varying,
    model character varying(100) DEFAULT NULL::character varying,
    vehicle_number character varying(100) DEFAULT NULL::character varying,
    vin character varying(100) DEFAULT NULL::character varying,
    engine_number character varying(100) DEFAULT NULL::character varying,
    mileage integer,
    year integer,
    type character varying(100) DEFAULT NULL::character varying,
    fitness_expires date,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vehicles OWNER TO taf;

--
-- Name: vehicles_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.vehicles_id_seq OWNER TO taf;

--
-- Name: vehicles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.vehicles_id_seq OWNED BY public.vehicles.id;


--
-- Name: vendor_addresses; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_addresses (
    vendor_address_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendor_id uuid NOT NULL,
    address_type character varying(50) DEFAULT 'office'::character varying NOT NULL,
    line1 text NOT NULL,
    line2 text,
    city character varying(150) DEFAULT NULL::character varying,
    state_region character varying(150) DEFAULT NULL::character varying,
    postal_code character varying(25) DEFAULT NULL::character varying,
    country_code character varying(2) DEFAULT NULL::character varying,
    is_primary boolean DEFAULT false NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vendor_addresses OWNER TO taf;

--
-- Name: vendor_bank_accounts; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_bank_accounts (
    vendor_bank_account_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendor_id uuid NOT NULL,
    bank_name character varying(255) NOT NULL,
    account_number character varying(100) NOT NULL,
    account_name character varying(255) DEFAULT NULL::character varying,
    branch_name character varying(255) DEFAULT NULL::character varying,
    swift_code character varying(50) DEFAULT NULL::character varying,
    currency character varying(10) DEFAULT NULL::character varying,
    is_primary boolean DEFAULT false NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vendor_bank_accounts OWNER TO taf;

--
-- Name: vendor_capabilities; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_capabilities (
    vendor_capability_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendor_id uuid NOT NULL,
    capability_category text,
    capability_description text,
    experience_years integer,
    certifications text,
    capacity_notes text,
    competency_score numeric(5,2) DEFAULT NULL::numeric,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vendor_capabilities OWNER TO taf;

--
-- Name: vendor_certificates; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_certificates (
    vendor_certificate_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendor_id uuid NOT NULL,
    certificate_name text,
    description text,
    expiry_date date,
    issued_at date,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vendor_certificates OWNER TO taf;

--
-- Name: vendor_contacts; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_contacts (
    vendor_contact_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendor_id uuid NOT NULL,
    contact_name character varying(255) NOT NULL,
    contact_role character varying(150) DEFAULT NULL::character varying,
    email public.citext,
    phone_number text,
    is_primary boolean DEFAULT false NOT NULL,
    notes text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vendor_contacts OWNER TO taf;

--
-- Name: vendor_documents; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_documents (
    vendor_document_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendor_id uuid NOT NULL,
    filetype character varying(50) DEFAULT NULL::character varying,
    doc_type character varying(100) DEFAULT NULL::character varying,
    file_url text,
    validity date,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vendor_documents OWNER TO taf;

--
-- Name: vendor_emails; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_emails (
    vendor_email_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendor_id uuid NOT NULL,
    email public.citext NOT NULL,
    is_primary boolean DEFAULT false NOT NULL,
    verified_at timestamp with time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vendor_emails OWNER TO taf;

--
-- Name: vendor_invoices; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_invoices (
    vendor_invoice_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    org_id uuid,
    purchase_order_id uuid NOT NULL,
    invoice_number character varying(100) NOT NULL,
    invoice_date date NOT NULL,
    amount numeric(12,2) NOT NULL,
    status character varying(50) DEFAULT 'unpaid'::character varying,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vendor_invoices OWNER TO taf;

--
-- Name: vendor_performance_metrics; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_performance_metrics (
    vendor_performance_metric_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendor_id uuid NOT NULL,
    period_start date,
    period_end date,
    kpi_name character varying(150) NOT NULL,
    kpi_value numeric(12,4) DEFAULT NULL::numeric,
    rating numeric(5,2) DEFAULT NULL::numeric,
    reviewer_id uuid,
    comments text,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vendor_performance_metrics OWNER TO taf;

--
-- Name: vendor_phone_numbers; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_phone_numbers (
    vendor_phone_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendor_id uuid NOT NULL,
    phone_number text NOT NULL,
    is_primary boolean DEFAULT false NOT NULL,
    verified_at timestamp with time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vendor_phone_numbers OWNER TO taf;

--
-- Name: vendor_quote_items; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_quote_items (
    quote_item_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    quote_id uuid NOT NULL,
    rfq_item_id bigint,
    is_alternate boolean DEFAULT false NOT NULL,
    alt_label text,
    unit_price numeric(14,4),
    tax numeric(14,4),
    lead_time_days integer,
    notes text
);


ALTER TABLE public.vendor_quote_items OWNER TO taf;

--
-- Name: vendor_quotes; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_quotes (
    quote_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    rfq_id uuid NOT NULL,
    invite_id uuid,
    vendor_id uuid NOT NULL,
    currency text,
    total_amount numeric(14,2),
    tax_total numeric(14,2),
    delivery_days integer,
    valid_thru date,
    notes text,
    attachments jsonb,
    revision_no integer DEFAULT 1 NOT NULL,
    submitted_at timestamp with time zone,
    status text DEFAULT 'draft'::text NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT vendor_quotes_status_check CHECK ((status = ANY (ARRAY['draft'::text, 'submitted'::text, 'revised'::text, 'withdrawn'::text, 'final'::text])))
);


ALTER TABLE public.vendor_quotes OWNER TO taf;

--
-- Name: vendor_supporting_docs; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendor_supporting_docs (
    vendor_supporting_doc_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendor_id uuid NOT NULL,
    filetype character varying(50) NOT NULL,
    type character varying(100) NOT NULL,
    file_url text NOT NULL,
    validity date,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.vendor_supporting_docs OWNER TO taf;

--
-- Name: vendors; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.vendors (
    vendor_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    vendorname character varying(255) NOT NULL,
    businessregnumber character varying(255) DEFAULT NULL::character varying,
    tin character varying(255) DEFAULT NULL::character varying,
    num_employees integer,
    company_size character varying(50) DEFAULT NULL::character varying,
    org_id uuid,
    lifecycle_status character varying(50) DEFAULT 'pending'::character varying NOT NULL,
    last_reviewed_at timestamp with time zone,
    avg_rating numeric(5,2) DEFAULT NULL::numeric,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT vendors_lifecycle_status_check CHECK (((lifecycle_status)::text = ANY ((ARRAY['pending'::character varying, 'onboarding'::character varying, 'active'::character varying, 'suspended'::character varying, 'offboarded'::character varying])::text[])))
);


ALTER TABLE public.vendors OWNER TO taf;

--
-- Name: view_filters; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.view_filters (
    id integer NOT NULL,
    view_id integer NOT NULL,
    tenant_id integer,
    branch_id integer,
    field_name character varying(100) NOT NULL,
    operator character varying(10) NOT NULL,
    value character varying(255) DEFAULT NULL::character varying,
    order_index integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.view_filters OWNER TO taf;

--
-- Name: view_filters_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.view_filters_id_seq OWNER TO taf;

--
-- Name: view_filters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.view_filters_id_seq OWNED BY public.view_filters.id;


--
-- Name: violation_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.violation_types (
    id integer NOT NULL,
    name character varying(255) NOT NULL,
    handbook_ref character varying(255) DEFAULT NULL::character varying,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.violation_types OWNER TO taf;

--
-- Name: violation_types_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.violation_types_id_seq OWNER TO taf;

--
-- Name: violation_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.violation_types_id_seq OWNED BY public.violation_types.id;


--
-- Name: work_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.work_types (
    work_type_id uuid DEFAULT public.uuid_generate_v7() NOT NULL,
    name text,
    org_id uuid,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.work_types OWNER TO taf;

--
-- Name: workcom_inspection_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.workcom_inspection_types (
    id integer NOT NULL,
    name character varying(100) NOT NULL,
    form_id integer,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workcom_inspection_types OWNER TO taf;

--
-- Name: workcom_inspection_types_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.workcom_inspection_types_id_seq OWNER TO taf;

--
-- Name: workcom_inspection_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.workcom_inspection_types_id_seq OWNED BY public.workcom_inspection_types.id;


--
-- Name: workcom_inspections; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.workcom_inspections (
    id integer NOT NULL,
    date date NOT NULL,
    location character varying(255) DEFAULT NULL::character varying,
    short_description character varying(255) DEFAULT NULL::character varying,
    inspector_id integer,
    inspection_type_id integer,
    workplace_id integer,
    inspection_request_id integer,
    form_data jsonb,
    tenant_id integer,
    branch_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workcom_inspections OWNER TO taf;

--
-- Name: workcom_inspections_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.workcom_inspections_id_seq OWNER TO taf;

--
-- Name: workcom_inspections_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.workcom_inspections_id_seq OWNED BY public.workcom_inspections.id;


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

CREATE TABLE public.workflow_approvals (
    id integer NOT NULL,
    workflow_id integer NOT NULL,
    step_order integer NOT NULL,
    approver_role character varying(100) NOT NULL,
    status character varying(50) DEFAULT 'pending'::character varying,
    record_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workflow_approvals OWNER TO taf;

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

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


ALTER SEQUENCE public.workflow_approvals_id_seq OWNER TO taf;

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

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


--
-- Name: workflow_event_triggers; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.workflow_event_triggers (
    id integer NOT NULL,
    event_name character varying(100) NOT NULL,
    table_name character varying(100) NOT NULL,
    trigger_type character varying(10) NOT NULL,
    form_id integer,
    operations json,
    field_map json,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workflow_event_triggers OWNER TO taf;

--
-- Name: workflow_event_triggers_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.workflow_event_triggers_id_seq OWNER TO taf;

--
-- Name: workflow_event_triggers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.workflow_event_triggers_id_seq OWNED BY public.workflow_event_triggers.id;


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

CREATE TABLE public.workflow_instances (
    id integer NOT NULL,
    workflow_id integer NOT NULL,
    record_id integer NOT NULL,
    current_state_id integer,
    started_by integer,
    status character varying(50) DEFAULT 'pending'::character varying,
    started_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workflow_instances OWNER TO taf;

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

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


ALTER SEQUENCE public.workflow_instances_id_seq OWNER TO taf;

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

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


--
-- Name: workflow_states; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.workflow_states (
    id integer NOT NULL,
    workflow_id integer NOT NULL,
    name character varying(100) NOT NULL,
    state_order integer NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workflow_states OWNER TO taf;

--
-- Name: workflow_states_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.workflow_states_id_seq OWNER TO taf;

--
-- Name: workflow_states_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.workflow_states_id_seq OWNED BY public.workflow_states.id;


--
-- Name: workflow_step_types; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.workflow_step_types (
    id integer NOT NULL,
    type character varying(100) NOT NULL,
    description text,
    metadata json,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workflow_step_types OWNER TO taf;

--
-- Name: workflow_step_types_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.workflow_step_types_id_seq OWNER TO taf;

--
-- Name: workflow_step_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.workflow_step_types_id_seq OWNED BY public.workflow_step_types.id;


--
-- Name: workflow_steps; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.workflow_steps (
    id integer NOT NULL,
    workflow_id integer NOT NULL,
    step_order integer NOT NULL,
    step_type character varying(50) NOT NULL,
    config json,
    tenant_id integer,
    department_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workflow_steps OWNER TO taf;

--
-- Name: workflow_steps_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.workflow_steps_id_seq OWNER TO taf;

--
-- Name: workflow_steps_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.workflow_steps_id_seq OWNED BY public.workflow_steps.id;


--
-- Name: workflow_tasks; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.workflow_tasks (
    id integer NOT NULL,
    instance_id integer NOT NULL,
    state_id integer NOT NULL,
    assignee_user_id integer,
    assignee_role character varying(100) DEFAULT NULL::character varying,
    status character varying(50) DEFAULT 'pending'::character varying,
    due_at timestamp without time zone,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workflow_tasks OWNER TO taf;

--
-- Name: workflow_tasks_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.workflow_tasks_id_seq OWNER TO taf;

--
-- Name: workflow_tasks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.workflow_tasks_id_seq OWNED BY public.workflow_tasks.id;


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

CREATE TABLE public.workflow_transitions (
    id integer NOT NULL,
    workflow_id integer NOT NULL,
    from_state_id integer NOT NULL,
    to_state_id integer NOT NULL,
    action character varying(100) DEFAULT NULL::character varying,
    conditions json,
    transition_order integer NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workflow_transitions OWNER TO taf;

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

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


ALTER SEQUENCE public.workflow_transitions_id_seq OWNER TO taf;

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

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


--
-- Name: workflow_triggers; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.workflow_triggers (
    id integer NOT NULL,
    workflow_id integer NOT NULL,
    event_name character varying(100) NOT NULL,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workflow_triggers OWNER TO taf;

--
-- Name: workflow_triggers_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.workflow_triggers_id_seq OWNER TO taf;

--
-- Name: workflow_triggers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.workflow_triggers_id_seq OWNED BY public.workflow_triggers.id;


--
-- Name: workflows; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.workflows (
    id integer NOT NULL,
    tenant_id integer,
    department_id integer,
    name character varying(255) NOT NULL,
    trigger_event character varying(100) NOT NULL,
    definition json NOT NULL,
    is_active boolean DEFAULT true,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workflows OWNER TO taf;

--
-- Name: workflows_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.workflows_id_seq OWNER TO taf;

--
-- Name: workflows_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.workflows_id_seq OWNED BY public.workflows.id;


--
-- Name: workplace_registrations; Type: TABLE; Schema: public; Owner: taf
--

CREATE TABLE public.workplace_registrations (
    id integer NOT NULL,
    company_name character varying(255) DEFAULT NULL::character varying,
    address text,
    name_of_owners_of_business json,
    trading_name character varying(100) DEFAULT NULL::character varying,
    address_of_workplace text,
    postal_address text,
    date_of_business_commenced_operations_at_these_premises date,
    details_of_ownership_of_premises text,
    name_and_address_of_owner_of_the_building text,
    details_of_business_activiy text,
    main_activity_conducted_by_business text,
    principal_articles_to_be_manufactured_repaired_or_sold text,
    sales_type character varying(100) DEFAULT NULL::character varying,
    goods_sold character varying(100) DEFAULT NULL::character varying,
    has_site_previously_been_used_as_a_workplace text,
    name_of_previous_occupier character varying(100) DEFAULT NULL::character varying,
    contact_telephone_number character varying(50) DEFAULT NULL::character varying,
    maximum_number_of_employees character varying(50) DEFAULT NULL::character varying,
    committee_members text,
    training_undergone character varying(100) DEFAULT NULL::character varying,
    district character varying(100) DEFAULT NULL::character varying,
    ohs_policy character varying(100) DEFAULT NULL::character varying,
    minutes character varying(100) DEFAULT NULL::character varying,
    tin character varying(50) DEFAULT NULL::character varying,
    contact_person character varying(255) DEFAULT NULL::character varying,
    contact_email character varying(255) DEFAULT NULL::character varying,
    contact_phone character varying(50) DEFAULT NULL::character varying,
    invoice_id integer,
    status character varying(50) DEFAULT 'pending'::character varying,
    branch_id integer,
    assigned_reviewer_id integer,
    tenant_id integer,
    isdeleted boolean DEFAULT false NOT NULL,
    updatedat timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public.workplace_registrations OWNER TO taf;

--
-- Name: workplace_registrations_id_seq; Type: SEQUENCE; Schema: public; Owner: taf
--

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


ALTER SEQUENCE public.workplace_registrations_id_seq OWNER TO taf;

--
-- Name: workplace_registrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: taf
--

ALTER SEQUENCE public.workplace_registrations_id_seq OWNED BY public.workplace_registrations.id;


--
-- Name: account_ai_feedback id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: appeals id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: appraisal_templates id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: attendance id; Type: DEFAULT; Schema: public; Owner: taf
--

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


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

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


--
-- Name: bank_detail_changes id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: calendar_accounts id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: calendar_availability id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: calendar_categories id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: calendar_event_documents id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: calendar_event_permissions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: calendar_events id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: career_paths id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: career_steps id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: case_evidence id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: case_notes id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: case_participants id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: case_tasks id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: cash_sessions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: certificate_templates id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: check_ins id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: companies id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: competencies id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: competency_assessments id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: contract_approvals id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: contract_versions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: contracts id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: corrective_actions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: countries id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: country_holidays id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: custom_field_values id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: custom_fields id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: customer_history id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: customer_settings id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: dashboard_card_permissions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: demo_graph_data id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: detail_view_elements id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: detail_views id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: disciplinary_actions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: disciplinary_cases id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: districts id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: document_categories id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: document_folders id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: element_options id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: element_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employee_authorized_locations id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employee_certificates id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employee_competencies id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employee_custom_fields id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employee_custom_values id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employee_documents id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employee_exits id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employee_items id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employee_location_changes id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employee_shifts id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employee_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employees2locations id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: employees2users id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: event_categories id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: exit_approvals id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: exit_clearances id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: exit_feedback id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: exit_interviews id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: expense_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: feedback_notes id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: feedback_requests id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: field_definitions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: final_settlements id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: fishbone_diagrams id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: form_buttons id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: form_categories id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: form_certificates id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: form_definitions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: form_submission_reviews id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: form_submission_values id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: form_submissions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: form_wizard_steps id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: form_wizards id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: forms id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: goal_alignment id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: goal_documents id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: goal_milestones id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: goal_score_labels id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: goal_templates id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: graphs id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: incident_alert_rules id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: inspection_assignment_rules id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: inspection_requests id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: interview_logs id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: invoice_payments id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: invoice_settings id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: job_opening_templates id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: kanban_boards id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: kanban_columns id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: kanban_comments id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: kanban_tasks id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: legacy_resources id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: line_items id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: locations id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: meeting_links id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: notification_log id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_action_signoffs id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_actions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_assignment_rules id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_compliance_logs id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_compliance_tasks id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_emergency_contacts id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_emergency_drills id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_fault_trees id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_field_incidents id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_five_whys id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_hazard_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_hazards id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_health_checks id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_incident_custom_fields id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_incident_files id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_incident_logs id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_incident_signoffs id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_incident_statuses id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_incident_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_incidents id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_inspection_audits id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_inspection_items id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_inspection_templates id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_inspection_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_inspections id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_issues id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_jsa_reviewers id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_jsa_signoffs id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_jsa_step_files id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_jsa_steps id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_jsa_training id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_jsa_versions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_jsas id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_medicals id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_needs_expectations id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_regulations id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_risk_matrices id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_risk_reviews id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_root_causes id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_severities id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_stakeholders id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ohs_training_requirements id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: overtime_rules id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: payment_request id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: payment_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: payroll_anomalies id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: performance_goals id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: performance_reviews id; Type: DEFAULT; Schema: public; Owner: taf
--

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


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

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


--
-- Name: permit_applications id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: permit_documents id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: permit_inspections id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: permit_signatures id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: permit_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: policy_acknowledgments id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: policy_approvals id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: policy_targets id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: policy_templates id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: projects id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: properties id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: property_rates id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: push_subscriptions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: rate_invoices id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: rate_payments id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: ratepayers id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: receipts id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: reimbursement_claims id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: resource_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: resources id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: review_calibrations id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: review_cycles id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: review_documents id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: review_schedules id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: rfq_items id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: risk_assessment_files id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: risk_assessment_hazards id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: risk_assessment_ppe id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: risk_assessment_signoffs id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: risk_assessment_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: risk_assessments id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: risk_categories id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: risk_identifications id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: role_competencies id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: safety_alert_files id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: safety_alert_logs id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: safety_alerts id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: safety_document_versions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: safety_documents id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: safety_field_incidents id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: safety_incident_files id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: safety_incident_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: safety_incidents id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: scheduled_reports id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: service_connections id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: service_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: settings id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: shift_swaps id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: shifts id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: supervisor_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: table_column_settings id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: table_views id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: tasks id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: tax_core_request id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: tax_core_response id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: tax_ledger id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: tenant_admins id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: tenant_module_settings id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: tenant_modules id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: tenant_tables id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: tenants id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: timesheets id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_answers id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_badges id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_bookmarks id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_categories id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_certificates id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_contents id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_courses id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_enrollments id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_feedback id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_path_courses id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_paths id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_questions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_quizzes id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_results id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: training_sessions id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: user_2fa id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: user_board_settings id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: user_passkeys id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: user_settings id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: user_tokens id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: vehicle_makes id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: vehicle_models id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: vehicle_report_comments id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: vehicle_report_parts id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: vehicle_reports id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: vehicle_services id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: vehicle_trip_points id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: vehicle_trips id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: vehicle_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: vehicles id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: view_filters id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: violation_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: workcom_inspection_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: workcom_inspections id; Type: DEFAULT; Schema: public; Owner: taf
--

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


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

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


--
-- Name: workflow_event_triggers id; Type: DEFAULT; Schema: public; Owner: taf
--

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


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

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


--
-- Name: workflow_states id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: workflow_step_types id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: workflow_steps id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: workflow_tasks id; Type: DEFAULT; Schema: public; Owner: taf
--

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


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

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


--
-- Name: workflow_triggers id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: workflows id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Name: workplace_registrations id; Type: DEFAULT; Schema: public; Owner: taf
--

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


--
-- Data for Name: account_ai_feedback; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.account_ai_feedback (id, transaction_id, suggested_code, chosen_code, rationale, accepted, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: appeals; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.appeals (id, case_id, employee_id, reason, status, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: applications; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.applications (application_id, org_id, branch_id, open_position_id, first_name, last_name, email, phone, address, date_of_birth, application_date, status, notes, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: appraisal_templates; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.appraisal_templates (id, tenant_id, role_id, language_code, template_json, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: attendance; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.attendance (id, employee, date, restricted_start, restricted_end, hours_worked, overtime, injury_flag, restricted_duty, pay_code, approval_status, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: audit_logs; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.audit_logs (id, user_id, tenant_id, branch_id, action, entity, description, created_at, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: auth_events; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.auth_events (event_id, user_id, event_type, provider, ip, user_agent, metadata, created_at) FROM stdin;
\.


--
-- Data for Name: auto_orders; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.auto_orders (auto_order_id, product_id, minimum_stock_qty, order_qty, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: bank_detail_changes; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.bank_detail_changes (id, employee_id, bankname, accountname, accountnumber, status, approved_at, approved_by, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: branches; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.branches (branch_id, org_id, name, latitude, longitude, settings, isdeleted, updatedat) FROM stdin;
019a03bf-dfd7-7c39-b795-39f73700015f	0194a8b2-1234-7123-8123-123456789abc	Main Branch	\N	\N	\N	f	2025-10-20 22:31:37.679021+00
019a03bf-dfd7-75f7-98c9-247bd8124265	0194a8b2-1234-7123-8123-123456789abc	Warehouse	\N	\N	\N	f	2025-10-20 22:31:37.679021+00
019a03bf-dfd8-76dc-b7de-c32f6a8405ef	0194a8b2-1234-7123-8123-123456789abc	Retail Store	\N	\N	\N	f	2025-10-20 22:31:37.679021+00
\.


--
-- Data for Name: budgets; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.budgets (budget_id, org_id, department, project, costcenter, accountcode, timeperiod, budgettype, category, budgetedamount, actualamount, isdeleted, updatedat) FROM stdin;
019a03bf-e7c5-7133-b5e8-fc25652ead15	\N	IT	Infrastructure Upgrade	CC-001	ACC-IT-001	Quarterly	Initial	Hardware	50000.00	36000.00	f	2025-10-20 22:31:39.716812+00
019a03bf-e7c6-754b-b34f-cf0ed1ca79c5	\N	IT	Software Licensing	CC-001	ACC-IT-002	Annual	Initial	Software	25000.00	18300.00	f	2025-10-20 22:31:39.716812+00
019a03bf-e7c6-7d15-aa0b-5975820d6986	\N	Operations	Facility Maintenance	CC-002	ACC-OPS-001	Monthly	Initial	Maintenance	8000.00	6850.00	f	2025-10-20 22:31:39.716812+00
019a03bf-e7c6-770b-953a-a5d2a1465544	\N	HR	Training and Development	CC-003	ACC-HR-001	Quarterly	Initial	Training	15000.00	9500.00	f	2025-10-20 22:31:39.716812+00
019a03bf-e7c6-7d27-9247-04c6a9c94eb5	\N	Finance	Professional Services	CC-004	ACC-FIN-001	Quarterly	Initial	Consulting	12000.00	5000.00	f	2025-10-20 22:31:39.716812+00
019a03bf-e7c6-7b1e-b384-6b5ba817865d	\N	Operations	Office Supplies	CC-002	ACC-OPS-002	Monthly	Initial	Supplies	3000.00	2850.00	f	2025-10-20 22:31:39.716812+00
019a03bf-e7c6-7730-beb5-9ead61c0eb34	\N	IT	Cloud Services	CC-001	ACC-IT-003	Monthly	Revised	Services	4000.00	3500.00	f	2025-10-20 22:31:39.716812+00
019a03bf-e7c6-78fd-a9c6-ae2e6bb71140	\N	Marketing	Promotional Materials	CC-005	ACC-MKT-001	Quarterly	Initial	Marketing	6000.00	4200.00	f	2025-10-20 22:31:39.716812+00
019a03bf-e7c6-73d3-8042-fda1c1b66bd4	\N	Operations	Vehicle Maintenance	CC-002	ACC-OPS-003	Quarterly	Initial	Fleet	18000.00	12350.00	f	2025-10-20 22:31:39.716812+00
019a03bf-e7c6-7d95-80c2-7283915f027c	\N	IT	Data Center Operations	CC-001	ACC-IT-004	Annual	Initial	Infrastructure	60000.00	34500.00	f	2025-10-20 22:31:39.716812+00
\.


--
-- Data for Name: calendar_accounts; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.calendar_accounts (id, user_id, provider, access_token, refresh_token, token_expires, created_at, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: calendar_availability; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.calendar_availability (id, user_id, start_time, end_time, type, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: calendar_categories; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.calendar_categories (id, name, description, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
1	WorkCOM Inspections	\N	\N	\N	f	2025-10-20 22:31:29.594776+00
2	OHS Inspections	\N	\N	\N	f	2025-10-20 22:31:29.594776+00
3	OHS Incidents	\N	\N	\N	f	2025-10-20 22:31:29.594776+00
4	Safety Incidents	\N	\N	\N	f	2025-10-20 22:31:29.594776+00
\.


--
-- Data for Name: calendar_event_documents; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.calendar_event_documents (id, event_id, document_id, uploaded_by, org_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: calendar_event_permissions; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.calendar_event_permissions (id, event_id, user_id, role, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: calendar_events; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.calendar_events (id, title, description, provider, start_time, end_time, location, recurrence_rule, recurrence_end, parent_event_id, kanban_task_id, created_at, tenant_id, branch_id, category_id, isdeleted, updatedat) FROM stdin;
1	Schedule initial inspection	\N	\N	2025-07-01 00:00:00	\N	\N	\N	\N	\N	1	\N	\N	\N	1	f	2025-10-20 22:31:29.725486+00
2	Conduct site inspection	\N	\N	2025-07-10 00:00:00	\N	\N	\N	\N	\N	2	\N	\N	\N	1	f	2025-10-20 22:31:29.725486+00
3	Submit inspection report	\N	\N	2025-07-15 00:00:00	\N	\N	\N	\N	\N	3	\N	\N	\N	1	f	2025-10-20 22:31:29.725486+00
\.


--
-- Data for Name: career_paths; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.career_paths (id, tenant_id, role_id, name, description, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: career_steps; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.career_steps (id, path_id, step_number, title, role_id, requirements, tenant_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: case_evidence; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.case_evidence (id, case_id, file_path, description, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: case_instructions; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.case_instructions (case_instruction_id, case_id, instruction_date, instruction, document_ids, created_by, created_at, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: case_notes; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.case_notes (id, matter_id, note, created_by, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: case_participants; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.case_participants (id, matter_id, person_id, role, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: case_tasks; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.case_tasks (id, matter_id, subject, due_date, assigned_to, status, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: cases; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.cases (case_id, client_id, case_number, title, status, opened_at, closed_at, lead_rep_id, description, initial_instructions, org_id, user_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: cash_sessions; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.cash_sessions (id, cashier_id, opened_at, closed_at, opening_balance, closing_balance, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: certificate_templates; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.certificate_templates (id, name, file_path, tenant_id, isdeleted, updatedat) FROM stdin;
1	Basic Certificate	templates/certificates/basic.php	\N	f	2025-10-20 22:31:30.293024+00
\.


--
-- Data for Name: check_ins; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.check_ins (id, employee_id, manager_id, scheduled_at, completed_at, notes, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: clarification_requests; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.clarification_requests (clarification_id, reference_id, reference_table, org_id, client_user_id, subject, message, status, priority, created_at, resolved_at) FROM stdin;
\.


--
-- Data for Name: clarification_responses; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.clarification_responses (response_id, clarification_id, user_id, message, is_internal_note, created_at) FROM stdin;
\.


--
-- Data for Name: client_payment_restrictions; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.client_payment_restrictions (restriction_id, client_user_id, org_id, allowed_providers, blocked_providers, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: client_portal_tokens; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.client_portal_tokens (token_id, user_id, org_id, token_hash, purpose, reference_id, reference_table, expires_at, used_at, ip_address, user_agent, created_at) FROM stdin;
\.


--
-- Data for Name: clients; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.clients (client_id, user_id, name, phone, email, address, city, country, description, comments, org_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: companies; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.companies (id, country_id, name, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: competencies; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.competencies (id, name, description, updatedat, isdeleted) FROM stdin;
\.


--
-- Data for Name: competency_assessments; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.competency_assessments (id, employee_id, competency_id, assessor_id, rating, notes, assessment_date, updatedat, isdeleted) FROM stdin;
\.


--
-- Data for Name: contract_approvals; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.contract_approvals (id, document_id, step_order, approver_role, status, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: contract_versions; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.contract_versions (id, contract_id, storage_key, version_number, version_hash, created_at, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: contracts; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.contracts (id, employee_id, contract_type, start_date, end_date, expiry_date, renewal_status, status, file_path, created_by, updated_by, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: corrective_actions; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.corrective_actions (id, incident_id, name, description, steps, responsible_user_id, status, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: countries; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.countries (id, name, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: country_holidays; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.country_holidays (id, country_id, holiday_name, holiday_date, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: credit_alerts; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.credit_alerts (alert_id, customer_id, org_id, credit_limit_id, alert_type, severity, credit_limit, utilized_credit, available_credit, utilization_percentage, message, details, notification_sent, notification_sent_at, notification_method, acknowledged, acknowledged_by, acknowledged_at, resolution_notes, created_at) FROM stdin;
\.


--
-- Data for Name: credit_approval_requests; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.credit_approval_requests (request_id, customer_id, org_id, request_type, reference_type, reference_id, current_credit_limit, current_utilized_credit, requested_amount, new_total_utilization, over_limit_amount, reason, justification, priority, status, requested_by, requested_at, approved_by, approved_at, approval_notes, rejected_by, rejected_at, rejection_reason, expires_at, metadata, created_at, updated_at) FROM stdin;
\.


--
-- Data for Name: credit_limit_history; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.credit_limit_history (history_id, credit_limit_id, customer_id, org_id, change_type, previous_limit, new_limit, previous_hold_status, new_hold_status, reason, notes, requested_by, approved_by, approved_at, metadata, created_at, created_by) FROM stdin;
\.


--
-- Data for Name: custom_field_values; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.custom_field_values (id, field_id, record_id, field_value, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: custom_fields; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.custom_fields (id, tenant_id, branch_id, model, field_name, field_type, is_required, options, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: customer_credit_limits; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.customer_credit_limits (credit_limit_id, customer_id, org_id, credit_limit, currency, available_credit, utilized_credit, overdue_amount, payment_terms_days, grace_period_days, is_on_hold, hold_reason, hold_date, hold_by, alert_threshold_80, alert_threshold_90, alert_threshold_100, last_credit_check, last_utilization_update, created_at, updated_at, created_by, updated_by, isdeleted, deleted_at, deleted_by) FROM stdin;
\.


--
-- Data for Name: customer_history; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.customer_history (id, customerid, action, description, performedby, performedat, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: customer_reminder_preferences; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.customer_reminder_preferences (preference_id, customer_id, org_id, opted_out, opted_out_at, opt_out_reason, preferred_channels, preferred_email, preferred_phone, do_not_remind_before_days, notes, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: customer_settings; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.customer_settings (id, customer_id, name, value, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: customers; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.customers (customer_id, customer_type, name, email, phone_number, address, tin, risk_rating, compliance_status, balance, org_id, user_id, isdeleted, updatedat) FROM stdin;
019a03bf-798a-724a-a35c-b0d4c2f3b16e	Individual	John Doe	john.doe@example.com	+1234567890	123 Main St	TIN123	Low	Compliant	0.00	\N	\N	f	2025-10-20 22:31:11.496569+00
019a03bf-798b-7b9b-aa64-e516326cc7db	Business	ABC Corp	contact@abc.com	+0987654321	456 Business Ave	TIN456	Medium	Compliant	0.00	\N	\N	f	2025-10-20 22:31:11.496569+00
019a03bf-798b-7425-86cb-8a82250b7462	Individual	Jane Smith	jane.smith@example.com	+1122334455	789 Elm St	TIN789	Low	Compliant	0.00	\N	\N	f	2025-10-20 22:31:11.496569+00
019a03bf-e60c-7e97-8527-d92d9ec31c33	individual	John Smith	john.smith@email.com	+679 123 4567	123 Main Street, Suva, Fiji	123456789	low	compliant	0.00	0194a8b2-1234-7123-8123-123456789abc	\N	f	2025-10-20 22:31:39.274313+00
019a03bf-e60d-7001-8131-d8ccaeeb1b00	individual	Mary Johnson	mary.johnson@email.com	+679 234 5678	456 Queen Street, Suva, Fiji	234567890	low	compliant	0.00	0194a8b2-1234-7123-8123-123456789abc	\N	f	2025-10-20 22:31:39.274313+00
019a03bf-e60e-7c66-9c4a-d703e2bded1b	corporate	Pacific Traders Ltd	info@pacifictraders.com.fj	+679 345 6789	789 Kings Road, Suva, Fiji	345678901	medium	compliant	0.00	0194a8b2-1234-7123-8123-123456789abc	\N	f	2025-10-20 22:31:39.274313+00
019a03bf-e60e-79d2-8415-a3afba2ad96a	corporate	Fiji Imports Ltd	sales@fijiimports.com.fj	+679 456 7890	321 Victoria Parade, Suva, Fiji	456789012	medium	compliant	0.00	0194a8b2-1234-7123-8123-123456789abc	\N	f	2025-10-20 22:31:39.274313+00
019a03bf-e60e-78ac-b49a-9266f3303418	individual	Raj Kumar	raj.kumar@email.com	+679 567 8901	654 Princes Road, Suva, Fiji	567890123	low	compliant	0.00	0194a8b2-1234-7123-8123-123456789abc	\N	f	2025-10-20 22:31:39.274313+00
019a03bf-e60e-76f5-828d-e510dc80e584	government	Ministry of Health	procurement@health.gov.fj	+679 678 9012	Government Buildings, Suva, Fiji	678901234	low	compliant	0.00	0194a8b2-1234-7123-8123-123456789abc	\N	f	2025-10-20 22:31:39.274313+00
019a03bf-e60e-7018-b2b6-905849a26299	corporate	Suva Supermarket Ltd	manager@suvamarket.com.fj	+679 789 0123	987 Waimanu Road, Suva, Fiji	789012345	medium	compliant	0.00	0194a8b2-1234-7123-8123-123456789abc	\N	f	2025-10-20 22:31:39.274313+00
019a03bf-e60e-7f89-b6be-c77b6ea4feae	individual	Lisa Wong	lisa.wong@email.com	+679 890 1234	147 Gordon Street, Suva, Fiji	890123456	low	compliant	0.00	0194a8b2-1234-7123-8123-123456789abc	\N	f	2025-10-20 22:31:39.274313+00
019a03bf-e60e-77e8-b0cc-068b93710ca1	corporate	Island Hardware Ltd	orders@islandhardware.com.fj	+679 901 2345	258 Thomson Street, Suva, Fiji	901234567	medium	pending	0.00	0194a8b2-1234-7123-8123-123456789abc	\N	f	2025-10-20 22:31:39.274313+00
019a03bf-e60e-77bb-9c00-0184b1dbc190	individual	David Prasad	david.prasad@email.com	+679 012 3456	369 Loftus Street, Suva, Fiji	012345678	low	compliant	0.00	0194a8b2-1234-7123-8123-123456789abc	\N	f	2025-10-20 22:31:39.274313+00
\.


--
-- Data for Name: dashboard_card_permissions; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.dashboard_card_permissions (id, card_slug, group_id, user_id, tenant_id, branch_id, can_view, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: deduction_rates; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.deduction_rates (deduction_rate_id, deduction_type_id, start_salary, end_salary, rate, isdeleted, updatedat) FROM stdin;
019a03bf-e747-779e-9a9e-1c01c7647cf7	019a03bf-e736-783a-8a5b-7461e657448b	0.00	30000.00	0.0000	f	2025-10-20 22:31:39.588949+00
019a03bf-e747-7dd1-bcc2-63f9c7b0dc59	019a03bf-e736-783a-8a5b-7461e657448b	30000.01	50000.00	0.1800	f	2025-10-20 22:31:39.588949+00
019a03bf-e747-700f-9af2-b7cbb175f263	019a03bf-e736-783a-8a5b-7461e657448b	50000.01	270000.00	0.2000	f	2025-10-20 22:31:39.588949+00
019a03bf-e747-76f5-b61e-3ebdfe203277	019a03bf-e736-783a-8a5b-7461e657448b	270000.01	300000.00	0.2000	f	2025-10-20 22:31:39.588949+00
019a03bf-e747-7251-8222-40996aca531c	019a03bf-e736-783a-8a5b-7461e657448b	300000.01	350000.00	0.2000	f	2025-10-20 22:31:39.588949+00
019a03bf-e748-7fe0-b258-974c5c895031	019a03bf-e736-783a-8a5b-7461e657448b	350000.01	400000.00	0.2000	f	2025-10-20 22:31:39.588949+00
019a03bf-e748-7098-a986-08041a1e7ab4	019a03bf-e736-783a-8a5b-7461e657448b	400000.01	450000.00	0.2000	f	2025-10-20 22:31:39.588949+00
019a03bf-e748-7ba1-92b8-6c5ba3285073	019a03bf-e736-783a-8a5b-7461e657448b	450000.01	500000.00	0.2000	f	2025-10-20 22:31:39.588949+00
019a03bf-e748-7a07-a310-c85fedff33e9	019a03bf-e736-783a-8a5b-7461e657448b	500000.01	1000000.00	0.2000	f	2025-10-20 22:31:39.588949+00
019a03bf-e748-70d9-a3bf-d15fda8dc9db	019a03bf-e736-783a-8a5b-7461e657448b	1000000.01	99999999.99	0.2000	f	2025-10-20 22:31:39.588949+00
019a03bf-e748-772b-9c2d-0576b91730b9	019a03bf-e737-7fc4-ace6-cf403b87994e	0.00	99999999.99	0.0800	f	2025-10-20 22:31:39.588949+00
\.


--
-- Data for Name: deduction_types; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.deduction_types (deduction_type_id, name, org_id, isdeleted, updatedat) FROM stdin;
019a03bf-e736-783a-8a5b-7461e657448b	Tax	0194a8b2-1234-7123-8123-123456789abc	f	2025-10-20 22:31:39.573059+00
019a03bf-e737-7fc4-ace6-cf403b87994e	FNPF	0194a8b2-1234-7123-8123-123456789abc	f	2025-10-20 22:31:39.573059+00
\.


--
-- Data for Name: demo_graph_data; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.demo_graph_data (id, tenant_id, x_value, y_value, z_value, updatedat, isdeleted) FROM stdin;
\.


--
-- Data for Name: departments; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.departments (department_id, branch_id, name, description, isdeleted, updatedat) FROM stdin;
019a03bf-cacd-7220-b6c0-df4f3bb5dd1b	\N	Human Resources	\N	f	2025-10-20 22:31:32.299242+00
019a03bf-cace-73d4-a046-cdf8d8f2ea54	\N	Finance	\N	f	2025-10-20 22:31:32.299242+00
019a03bf-cace-7330-b64b-0de7c48c4721	\N	IT	\N	f	2025-10-20 22:31:32.299242+00
019a03bf-cace-7156-b014-de2f8dd58bba	\N	Operations	\N	f	2025-10-20 22:31:32.299242+00
019a03bf-cace-7c11-867c-7b87d5b9529c	\N	Sales	\N	f	2025-10-20 22:31:32.299242+00
019a03bf-cace-783f-8b9e-1c18a30dc8c8	\N	Marketing	\N	f	2025-10-20 22:31:32.299242+00
\.


--
-- Data for Name: detail_view_elements; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.detail_view_elements (id, detail_view_id, config, tenant_id, branch_id, order_index, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: detail_views; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.detail_views (id, name, config, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
2	Case Details	{"name": "Case Details", "rows": [{"classes": "card bg-base-100 shadow card-body grid grid-cols-4 gap-4", "columns": [{"classes": "card bg-base-100 shadow p-4 space-y-1", "elements": [{"tag": "h2", "text": "Client Information", "type": "heading", "classes": "card-title"}, {"type": "paragraph", "label": "Name", "classes": "grid grid-cols-2 gap-2", "data_column": "client.name", "label_classes": "font-semibold"}, {"type": "paragraph", "label": "Phone", "classes": "grid grid-cols-2 gap-2", "data_column": "client.phone", "label_classes": "font-semibold"}, {"type": "paragraph", "label": "Email", "classes": "grid grid-cols-2 gap-2", "data_column": "client.email", "label_classes": "font-semibold"}, {"type": "paragraph", "label": "Address", "classes": "grid grid-cols-2 gap-2", "data_column": "client.address", "label_classes": "font-semibold"}, {"type": "paragraph", "label": "City", "classes": "grid grid-cols-2 gap-2", "data_column": "client.city", "label_classes": "font-semibold"}, {"type": "paragraph", "label": "Country", "classes": "grid grid-cols-2 gap-2", "data_column": "client.country", "label_classes": "font-semibold"}, {"type": "paragraph", "label": "Description", "classes": "grid grid-cols-2 gap-2", "data_column": "client.description", "label_classes": "font-semibold"}]}, {"classes": "card bg-base-100 shadow p-4 space-y-1", "elements": [{"tag": "h2", "text": "Case Information", "type": "heading", "classes": "card-title"}, {"type": "paragraph", "label": "Title", "classes": "grid grid-cols-2 gap-2", "data_column": "title", "label_classes": "font-semibold"}, {"type": "paragraph", "label": "Case Number", "classes": "grid grid-cols-2 gap-2", "data_column": "case_number", "label_classes": "font-semibold"}, {"type": "paragraph", "label": "Status", "classes": "grid grid-cols-2 gap-2", "data_column": "status", "label_classes": "font-semibold"}, {"type": "paragraph", "label": "Lead Rep", "classes": "grid grid-cols-2 gap-2", "data_column": "lead_rep_name", "label_classes": "font-semibold"}, {"type": "paragraph", "label": "Opened", "classes": "grid grid-cols-2 gap-2", "data_column": "opened_at", "label_classes": "font-semibold"}, {"type": "paragraph", "label": "Closed", "classes": "grid grid-cols-2 gap-2", "data_column": "closed_at", "label_classes": "font-semibold"}]}, {"classes": "stats", "elements": [{"type": "div", "classes": "stat", "elements": [{"text": "Hours", "type": "div", "classes": "stat-title"}, {"type": "aggregate", "table": "time_entries", "column": "hours", "classes": "stat-value", "function": "sum", "filterField": "time_entry_id"}]}, {"type": "div", "classes": "stat", "elements": [{"text": "Expenses", "type": "div", "classes": "stat-title"}, {"type": "aggregate", "table": "expenses", "column": "amount", "classes": "stat-value", "function": "sum", "filterField": "case_id"}]}, {"type": "div", "classes": "stat", "elements": [{"text": "Total Hours", "type": "div", "classes": "stat-title"}, {"type": "aggregate", "table": "time_entries", "column": "hours", "classes": "stat-value", "function": "sum", "filterField": "time_entry_id"}]}, {"type": "div", "classes": "stat", "elements": [{"text": "Value", "type": "div", "classes": "stat-title"}, {"type": "aggregate", "table": "time_entries", "column": "total", "classes": "stat-value", "function": "sum", "filterField": "time_entry_id"}]}, {"type": "div", "classes": "stat", "elements": [{"text": "Billed Hours", "type": "div", "classes": "stat-title"}, {"type": "aggregate", "table": "time_entries", "column": "hours", "classes": "stat-value", "filters": {"billed_to_client": 1}, "function": "sum", "filterField": "time_entry_id"}]}, {"type": "div", "classes": "stat", "elements": [{"text": "Billed Amount", "type": "div", "classes": "stat-title"}, {"type": "aggregate", "table": "time_entries", "column": "total", "classes": "stat-value", "filters": {"billed_to_client": 1}, "function": "sum", "filterField": "time_entry_id"}]}]}, {"classes": "card bg-base-100 shadow p-4 space-y-1", "elements": [{"type": "paragraph", "label": "Initial Instructions", "data_column": "initial_instructions"}]}]}], "sources": [{"alias": "client", "table": "clients", "foreignKey": "client_id"}, {"table": "time_entries", "foreignKey": "time_entry_id"}]}	\N	\N	f	2025-10-20 22:31:30.266583+00
\.


--
-- Data for Name: disciplinary_actions; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.disciplinary_actions (id, case_id, action, effective_date, approved_by, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: disciplinary_cases; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.disciplinary_cases (id, employee_id, violation_id, severity, summary, status, assigned_to, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: discount_rules; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.discount_rules (discount_rule_id, org_id, branch_id, name, discount_type, product_id, category_id, percentage_value, amount_value, buy_quantity, free_quantity, bundle_quantity, bundle_price, threshold_quantity, start_date, end_date, notes, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: dispatch_lines; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.dispatch_lines (dispatch_line_id, dispatch_note_id, product_id, org_id, line_number, quantity_dispatched, dispatch_unit, quantity_received, receive_unit, repack_on_dispatch, batch_number, notes, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: dispatch_notes; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.dispatch_notes (dispatch_note_id, dispatch_number, org_id, from_branch_id, to_branch_id, dispatch_date, dispatched_by, vehicle_number, driver_name, reference_id, reference_table, status, received_date, received_by, notes, isdeleted, updatedat) FROM stdin;
\.


--
-- Data for Name: districts; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.districts (id, name, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
1	Central	\N	\N	f	2025-10-20 22:31:29.533572+00
2	Eastern	\N	\N	f	2025-10-20 22:31:29.533572+00
3	Northern	\N	\N	f	2025-10-20 22:31:29.533572+00
4	Western	\N	\N	f	2025-10-20 22:31:29.533572+00
\.


--
-- Data for Name: document_categories; Type: TABLE DATA; Schema: public; Owner: taf
--

COPY public.document_categories (id, name, description, tenant_id, branch_id, isdeleted, updatedat) FROM stdin;
1	Training	\N	\N	\N	f	2025-10-20 22:31:30.005698+00
2	Compliance	\N	\N	\N	f	2025-10-20 22:31:30.005698+00
\.


--
