--
--


SELECT pg_catalog.set_config('search_path', '', false);



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

CREATE TABLE public.activities (
    id bigint NOT NULL,
    activity character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.activities_id_seq OWNED BY public.activities.id;


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

CREATE TABLE public.aid_partner (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    partner_id uuid NOT NULL,
    aid_id bigint NOT NULL,
    deleted_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.aid_partner_id_seq OWNED BY public.aid_partner.id;


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

CREATE TABLE public.aiddables (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    aid_id bigint NOT NULL,
    aiddable_id bigint NOT NULL,
    aiddable_type character varying(100) NOT NULL
);


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

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


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

ALTER SEQUENCE public.aiddables_id_seq OWNED BY public.aiddables.id;


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

CREATE TABLE public.aids (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    name character varying(150) NOT NULL,
    created_by bigint NOT NULL
);


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

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


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

ALTER SEQUENCE public.aids_id_seq OWNED BY public.aids.id;


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

CREATE TABLE public.audits (
    id bigint NOT NULL,
    user_type character varying(255),
    user_id bigint,
    event character varying(255) NOT NULL,
    auditable_type character varying(255) NOT NULL,
    auditable_id bigint NOT NULL,
    old_values text,
    new_values text,
    url text,
    ip_address inet,
    user_agent character varying(1023),
    tags character varying(255),
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.audits_id_seq OWNED BY public.audits.id;


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

CREATE TABLE public.community_roles (
    id bigint NOT NULL,
    community_role character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.community_roles_id_seq OWNED BY public.community_roles.id;


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

CREATE TABLE public.cooperatives (
    id bigint NOT NULL,
    cooperative character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.cooperatives_id_seq OWNED BY public.cooperatives.id;


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

CREATE TABLE public.dairy_products (
    id bigint NOT NULL,
    product character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.dairy_products_id_seq OWNED BY public.dairy_products.id;


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

CREATE TABLE public.dairy_skills (
    id bigint NOT NULL,
    dairy_skill character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.dairy_skills_id_seq OWNED BY public.dairy_skills.id;


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

CREATE TABLE public.districts (
    id bigint NOT NULL,
    district character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.districts_id_seq OWNED BY public.districts.id;


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

CREATE TABLE public.dit_attendances (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    cohort_id bigint NOT NULL,
    user_id bigint NOT NULL,
    participant_id bigint NOT NULL,
    reg_no character varying(50),
    grade character varying(5),
    reported boolean DEFAULT false NOT NULL,
    completed boolean DEFAULT false NOT NULL
);


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

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


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

ALTER SEQUENCE public.dit_attendances_id_seq OWNED BY public.dit_attendances.id;


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

CREATE TABLE public.dit_cohorts (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    course_id bigint NOT NULL,
    user_id bigint NOT NULL,
    start_date date NOT NULL,
    end_date date NOT NULL
);


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

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


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

ALTER SEQUENCE public.dit_cohorts_id_seq OWNED BY public.dit_cohorts.id;


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

CREATE TABLE public.dit_courses (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    partner_id uuid NOT NULL,
    user_id bigint NOT NULL,
    name character varying(50),
    description text
);


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

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


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

ALTER SEQUENCE public.dit_courses_id_seq OWNED BY public.dit_courses.id;


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

CREATE TABLE public.earnings (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    employment_id bigint NOT NULL,
    month character varying(255) NOT NULL,
    year integer NOT NULL,
    investment double precision DEFAULT '0'::double precision NOT NULL,
    amount double precision DEFAULT '0'::double precision NOT NULL,
    created_by bigint NOT NULL,
    deleted_at timestamp(0) without time zone,
    CONSTRAINT earnings_month_check CHECK (((month)::text = ANY ((ARRAY['january'::character varying, 'february'::character varying, 'march'::character varying, 'april'::character varying, 'may'::character varying, 'june'::character varying, 'july'::character varying, 'august'::character varying, 'september'::character varying, 'october'::character varying, 'november'::character varying, 'december'::character varying])::text[])))
);


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

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


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

ALTER SEQUENCE public.earnings_id_seq OWNED BY public.earnings.id;


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

CREATE TABLE public.education_levels (
    id bigint NOT NULL,
    education_level character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.education_levels_id_seq OWNED BY public.education_levels.id;


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

CREATE TABLE public.employment (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    participant_id bigint NOT NULL,
    type character varying(255) NOT NULL,
    enterprise_id bigint,
    employer_name character varying(50),
    support_offered character varying(255),
    employment_date timestamp(0) without time zone,
    payment_mode character varying(255) DEFAULT 'daily'::character varying NOT NULL,
    job_title character varying(50),
    created_by bigint NOT NULL,
    deleted_at timestamp(0) without time zone,
    level character varying(255),
    CONSTRAINT employment_payment_mode_check CHECK (((payment_mode)::text = ANY ((ARRAY['daily'::character varying, 'weekly'::character varying, 'monthly'::character varying])::text[]))),
    CONSTRAINT employment_type_check CHECK (((type)::text = ANY ((ARRAY['self'::character varying, 'employed'::character varying])::text[])))
);


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

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


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

ALTER SEQUENCE public.employment_id_seq OWNED BY public.employment.id;


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

CREATE TABLE public.enterprise_farmer_group (
    id bigint NOT NULL,
    enterprise_id bigint NOT NULL,
    farmer_group_id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.enterprise_farmer_group_id_seq OWNED BY public.enterprise_farmer_group.id;


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

CREATE TABLE public.enterprise_participant (
    id bigint NOT NULL,
    farmer_group_id bigint NOT NULL,
    enterprise_id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.enterprise_participant_id_seq OWNED BY public.enterprise_participant.id;


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

CREATE TABLE public.enterprise_partner (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    enterprise_id bigint NOT NULL,
    partner_id uuid NOT NULL
);


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

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


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

ALTER SEQUENCE public.enterprise_partner_id_seq OWNED BY public.enterprise_partner.id;


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

CREATE TABLE public.enterprises (
    id bigint NOT NULL,
    enterprise character varying(255) NOT NULL,
    activity_id bigint NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.enterprises_id_seq OWNED BY public.enterprises.id;


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

CREATE TABLE public.equipment (
    id bigint NOT NULL,
    equipment character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.equipment_id_seq OWNED BY public.equipment.id;


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

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


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

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


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

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


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

CREATE TABLE public.farmer_group_bds (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    farmer_group_id bigint NOT NULL,
    have_completed_constitution boolean DEFAULT false NOT NULL,
    date_constitution_completed date,
    registration_paid boolean DEFAULT false NOT NULL,
    date_paid_registration date,
    registered_at_district boolean DEFAULT false NOT NULL,
    date_registered_at_district date,
    certificate_number character varying(100),
    have_bank_account boolean DEFAULT false NOT NULL,
    date_opened_bank_account date,
    financial_institution_id bigint,
    accessed_inputs boolean DEFAULT false NOT NULL,
    input_details text,
    received_financial_training boolean DEFAULT false NOT NULL,
    training_details text,
    created_by bigint NOT NULL
);


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

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


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

ALTER SEQUENCE public.farmer_group_bds_id_seq OWNED BY public.farmer_group_bds.id;


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

CREATE TABLE public.farmer_groups (
    id bigint NOT NULL,
    farmer_group character varying(255) NOT NULL,
    farmer_group_code character varying(255) NOT NULL,
    establishment_year character varying(255) NOT NULL,
    email_address character varying(255),
    group_bank_account boolean NOT NULL,
    financial_institution_id bigint,
    account_number character varying(255),
    account_name character varying(255),
    new_group boolean NOT NULL,
    received_other_ngo_support boolean NOT NULL,
    participation_of_collective_marketing boolean NOT NULL,
    is_member_of_dairy_cooperative boolean NOT NULL,
    cooperative_id bigint,
    have_a_market_map boolean NOT NULL,
    have_a_storage_facility boolean NOT NULL,
    have_modern_dairy_equipment boolean NOT NULL,
    type_of_dairy_equipment_ownership character varying(255),
    have_constitution_or_law boolean NOT NULL,
    is_group_involved_in_selling_related_dairy_products boolean NOT NULL,
    does_group_keep_records boolean NOT NULL,
    records_description text,
    last_updated_market_map date,
    have_a_business_plan boolean NOT NULL,
    last_updated_business_plan date,
    involved_in_vsla_services boolean NOT NULL,
    vsla_services_description text,
    enterprise_id bigint NOT NULL,
    loan_received_in_last_year boolean NOT NULL,
    loan_financial_institution_id bigint,
    registration_status character varying(255) NOT NULL,
    registration_number character varying(255),
    village_id bigint NOT NULL,
    group_representative_first_name character varying(255) NOT NULL,
    group_representative_last_name character varying(255) NOT NULL,
    group_position_id bigint NOT NULL,
    group_representative_contact character varying(255),
    group_representative_mobile_money boolean NOT NULL,
    received_mastercard_support boolean NOT NULL,
    mastercard_program_id bigint,
    user_id bigint NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    non_government_organisation_id bigint
);


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

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


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

ALTER SEQUENCE public.farmer_groups_id_seq OWNED BY public.farmer_groups.id;


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

CREATE TABLE public.fcm_tokens (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    user_id bigint NOT NULL,
    device_id character varying(50),
    token character varying(255) NOT NULL
);


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

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


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

ALTER SEQUENCE public.fcm_tokens_id_seq OWNED BY public.fcm_tokens.id;


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

CREATE TABLE public.financial_institutions (
    id bigint NOT NULL,
    financial_institution character varying(255) NOT NULL,
    category character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.financial_institutions_id_seq OWNED BY public.financial_institutions.id;


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

CREATE TABLE public.forgot_passwords (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    otp_code character varying(255) NOT NULL,
    phone_number character varying(255) NOT NULL,
    is_otp_verified boolean DEFAULT false NOT NULL,
    confirmation_string uuid,
    confirmation_string_verified boolean DEFAULT false NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.forgot_passwords_id_seq OWNED BY public.forgot_passwords.id;


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

CREATE TABLE public.government_agencies (
    id bigint NOT NULL,
    government_agency character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.government_agencies_id_seq OWNED BY public.government_agencies.id;


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

CREATE TABLE public.group_positions (
    id bigint NOT NULL,
    "position" character varying(255) NOT NULL,
    description character varying(255),
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.group_positions_id_seq OWNED BY public.group_positions.id;


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

CREATE TABLE public.input_types (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    input character varying(100) NOT NULL
);


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

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


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

ALTER SEQUENCE public.input_types_id_seq OWNED BY public.input_types.id;


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

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


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

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


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

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


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

CREATE TABLE public.jurisdiction_levels (
    id bigint NOT NULL,
    jurisdiction_level character varying(255) NOT NULL,
    description text,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.jurisdiction_levels_id_seq OWNED BY public.jurisdiction_levels.id;


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

CREATE TABLE public.login_logs (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    user_id bigint,
    email character varying(255),
    phone_number character varying(255),
    ip_address character varying(30),
    user_agent character varying(255),
    success boolean DEFAULT false NOT NULL
);


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

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


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

ALTER SEQUENCE public.login_logs_id_seq OWNED BY public.login_logs.id;


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

CREATE TABLE public.mastercard_programs (
    id bigint NOT NULL,
    mastercard_program character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.mastercard_programs_id_seq OWNED BY public.mastercard_programs.id;


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

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


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

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


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

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


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

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


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

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


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

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


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

CREATE TABLE public.milk_collection_centres (
    id bigint NOT NULL,
    milk_collection_centre character varying(255) NOT NULL,
    new_milk_collection_centre boolean NOT NULL,
    registration_status character varying(255) NOT NULL,
    registration_number character varying(255),
    contact_person_first_name character varying(255) NOT NULL,
    contact_person_last_name character varying(255) NOT NULL,
    number_of_employees integer NOT NULL,
    payment_methods character varying(255) NOT NULL,
    milk_collection_centre_bank_account boolean NOT NULL,
    financial_institution_id bigint,
    account_number character varying(255),
    account_name character varying(255),
    time_of_milk_delivery time(0) without time zone NOT NULL,
    time_of_milk_collection time(0) without time zone NOT NULL,
    village_id bigint NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.milk_collection_centres_id_seq OWNED BY public.milk_collection_centres.id;


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

CREATE TABLE public.modules (
    id uuid NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    title character varying(150) NOT NULL,
    description text,
    created_by bigint NOT NULL,
    number_submodules_required integer
);


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

CREATE TABLE public.non_government_organisations (
    id bigint NOT NULL,
    non_government_organisation character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.non_government_organisations_id_seq OWNED BY public.non_government_organisations.id;


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

CREATE TABLE public.notifications (
    id uuid NOT NULL,
    type character varying(255) NOT NULL,
    notifiable_type character varying(255) NOT NULL,
    notifiable_id bigint NOT NULL,
    data text NOT NULL,
    read_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

CREATE TABLE public.organisations (
    id bigint NOT NULL,
    organisation character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.organisations_id_seq OWNED BY public.organisations.id;


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

CREATE TABLE public.parishes (
    id bigint NOT NULL,
    parish character varying(255) NOT NULL,
    subcounty_id bigint NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.parishes_id_seq OWNED BY public.parishes.id;


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

CREATE TABLE public.participant_bds (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    participant_id bigint NOT NULL,
    have_bank_account boolean DEFAULT false NOT NULL,
    date_opened_bank_account date,
    financial_institution_id bigint,
    amount_saved integer,
    got_a_loan boolean DEFAULT false NOT NULL,
    loan_financial_institution_id bigint,
    loan_amount integer,
    loan_purpose character varying(255),
    created_by bigint NOT NULL,
    account_number character varying(50),
    account_name character varying(50)
);


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

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


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

ALTER SEQUENCE public.participant_bds_id_seq OWNED BY public.participant_bds.id;


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

CREATE TABLE public.participant_partner (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    participant_id bigint NOT NULL,
    partner_id uuid NOT NULL
);


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

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


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

ALTER SEQUENCE public.participant_partner_id_seq OWNED BY public.participant_partner.id;


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

CREATE TABLE public.participant_session (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    participant_id bigint NOT NULL,
    session_id bigint NOT NULL,
    reported boolean DEFAULT false NOT NULL,
    completed boolean DEFAULT false NOT NULL,
    reg_no character varying(50),
    grade character varying(5)
);


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

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


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

ALTER SEQUENCE public.participant_session_id_seq OWNED BY public.participant_session.id;


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

CREATE TABLE public.participant_training_session (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    participant_id bigint NOT NULL,
    training_session_id bigint NOT NULL,
    reported boolean DEFAULT false NOT NULL,
    completed boolean DEFAULT false NOT NULL,
    reg_no character varying(50),
    grade character varying(5)
);


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

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


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

ALTER SEQUENCE public.participant_training_session_id_seq OWNED BY public.participant_training_session.id;


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

CREATE TABLE public.participant_types (
    id bigint NOT NULL,
    participant_type character varying(255) NOT NULL,
    system_defined boolean DEFAULT false NOT NULL,
    account_login boolean DEFAULT false NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.participant_types_id_seq OWNED BY public.participant_types.id;


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

CREATE TABLE public.participants (
    id bigint NOT NULL,
    first_name character varying(255) NOT NULL,
    last_name character varying(255) NOT NULL,
    other_name character varying(255),
    participant_code character varying(255) NOT NULL,
    user_id bigint,
    farmer_group_id bigint NOT NULL,
    participant_type_id bigint NOT NULL,
    new_participant boolean NOT NULL,
    village_id bigint NOT NULL,
    is_house_hold_head boolean NOT NULL,
    group_position_id bigint NOT NULL,
    household_head_first_name character varying(255),
    household_head_last_name character varying(255),
    enterprise_id bigint NOT NULL,
    household_size integer NOT NULL,
    participant_mobile_money boolean NOT NULL,
    registered_mobile_money boolean NOT NULL,
    other_names_registered character varying(255),
    participant_bank_account boolean NOT NULL,
    financial_institution_id bigint,
    account_number character varying(255),
    account_name character varying(255),
    number_of_pwd_in_house_hold integer NOT NULL,
    year_of_birth character varying(255) NOT NULL,
    gender character varying(255) NOT NULL,
    pwd_status boolean NOT NULL,
    refugee_status boolean NOT NULL,
    participant_contact character varying(255),
    received_loan_in_last_year boolean NOT NULL,
    loan_financial_institution_id bigint,
    received_other_ngo_support boolean NOT NULL,
    is_participant_involved_in_selling_related_dairy_products boolean NOT NULL,
    level_of_experience_in_dairy_value_chain boolean,
    community_role_id bigint,
    employment_status character varying(255),
    min_income_range integer NOT NULL,
    max_income_range integer NOT NULL,
    own_a_smart_phone boolean,
    created_by bigint NOT NULL,
    gps_latitude character varying(255),
    gps_longitude character varying(255),
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    dairy_skill_id bigint,
    non_government_organisation_id bigint,
    marital_status character varying(255),
    highest_education_level character varying(255),
    main_economic_activity character varying(255),
    number_of_children integer,
    children_live_with_you boolean,
    household_details text,
    disability_type character varying(255),
    household_head_relationship character varying(255),
    household_head_year_of_birth character varying(255),
    household_head_occupation character varying(255),
    mobile_money_names character varying(255),
    status character varying(255) DEFAULT 'pending'::character varying NOT NULL,
    approved_by integer,
    approval_note character varying(255),
    next_of_kin_first_name character varying(50),
    next_of_kin_last_name character varying(50),
    next_of_kin_contact character varying(20),
    referral_source character varying(255),
    household_number character varying(30),
    attestation_number character varying(30),
    employment_date timestamp(0) without time zone,
    approved_at timestamp(0) without time zone
);


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

CREATE TABLE public.subcounties (
    id bigint NOT NULL,
    sub_county character varying(255) NOT NULL,
    district_id bigint NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

CREATE TABLE public.users (
    id bigint NOT NULL,
    name character varying(255) NOT NULL,
    email character varying(255),
    email_verified_at timestamp(0) without time zone,
    password character varying(255) NOT NULL,
    phone_number character varying(255) NOT NULL,
    organisation_id bigint NOT NULL,
    remember_token character varying(100),
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    web_login boolean DEFAULT false NOT NULL,
    partner_id uuid
);


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

CREATE TABLE public.villages (
    id bigint NOT NULL,
    village character varying(255) NOT NULL,
    parish_id bigint NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


--
-- Name: participants_employment_earnings; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.participants_employment_earnings AS
 SELECT en.id AS earning_id,
    part.id AS participants_id,
    part.user_id,
    part.participant_code,
    part.first_name,
    part.last_name,
    part.other_name,
    part.gender,
    part.participant_contact,
        CASE
            WHEN (part.participant_type_id = 2) THEN 'Village Agent'::text
            WHEN (part.participant_type_id = 1) THEN 'Farmer'::text
            ELSE ''::text
        END AS participant_type,
    part.year_of_birth AS participant_year_of_birth,
    ((to_char(((now())::date)::timestamp with time zone, 'yyyy'::text))::integer - (part.year_of_birth)::integer) AS participant_age,
        CASE
            WHEN ((((to_char(((now())::date)::timestamp with time zone, 'yyyy'::text))::integer - (part.year_of_birth)::integer) >= 18) AND (((to_char(((now())::date)::timestamp with time zone, 'yyyy'::text))::integer - (part.year_of_birth)::integer) <= 35)) THEN 'YES'::text
            ELSE 'NO'::text
        END AS is_youth,
        CASE
            WHEN (part.pwd_status = true) THEN 'YES'::text
            ELSE 'NO'::text
        END AS pwd_status,
    part.disability_type,
        CASE
            WHEN (part.refugee_status = true) THEN 'YES'::text
            ELSE 'NO'::text
        END AS refugee_status,
    gp.id AS group_position_id,
    gp."position" AS participant_position_in_group,
    fp.id AS group_id,
    fp.farmer_group AS group_name,
    en.employment_id,
    emp.type AS type_of_employment,
        CASE
            WHEN (emp.enterprise_id IS NULL) THEN (0)::bigint
            ELSE emp.enterprise_id
        END AS enterprise_id,
        CASE
            WHEN (emp.enterprise_id IS NULL) THEN 'Wages Earnings'::character varying
            ELSE ent.enterprise
        END AS enterprise,
    emp.employer_name,
    emp.support_offered,
    emp.employment_date AS employment_start_date,
    emp.payment_mode,
    emp.job_title,
    emp.level,
    en.month AS earning_month,
    en.year AS earning_year,
    (
        CASE
            WHEN ((en.month)::text = 'january'::text) THEN concat(en.year, '-01-25')
            WHEN ((en.month)::text = 'february'::text) THEN concat(en.year, '-02-25')
            WHEN ((en.month)::text = 'march'::text) THEN concat(en.year, '-03-25')
            WHEN ((en.month)::text = 'april'::text) THEN concat(en.year, '-04-25')
            WHEN ((en.month)::text = 'may'::text) THEN concat(en.year, '-05-25')
            WHEN ((en.month)::text = 'june'::text) THEN concat(en.year, '-06-25')
            WHEN ((en.month)::text = 'july'::text) THEN concat(en.year, '-07-25')
            WHEN ((en.month)::text = 'august'::text) THEN concat(en.year, '-08-25')
            WHEN ((en.month)::text = 'september'::text) THEN concat(en.year, '-09-25')
            WHEN ((en.month)::text = 'october'::text) THEN concat(en.year, '-10-25')
            WHEN ((en.month)::text = 'november'::text) THEN concat(en.year, '-11-25')
            WHEN ((en.month)::text = 'december'::text) THEN concat(en.year, '-12-25')
            ELSE (now())::text
        END)::date AS earning_month_year,
    en.investment,
    en.amount,
    vl.village,
    vl.id AS village_id,
    prs.parish,
    prs.id AS parish_id,
    subc.sub_county,
    subc.id AS sub_county_id,
    dist.district,
    dist.id AS district_id,
    ( SELECT usr.name
           FROM public.users usr
          WHERE (usr.id = en.created_by)) AS created_by
   FROM (((((((((public.earnings en
     JOIN public.employment emp ON ((en.employment_id = emp.id)))
     FULL JOIN public.enterprises ent ON ((emp.enterprise_id = ent.id)))
     JOIN public.participants part ON ((emp.participant_id = part.id)))
     JOIN public.farmer_groups fp ON ((part.farmer_group_id = fp.id)))
     JOIN public.group_positions gp ON ((part.group_position_id = gp.id)))
     JOIN public.villages vl ON ((part.village_id = vl.id)))
     JOIN public.parishes prs ON ((vl.parish_id = prs.id)))
     JOIN public.subcounties subc ON ((prs.subcounty_id = subc.id)))
     JOIN public.districts dist ON ((subc.district_id = dist.id)))
  WHERE (en.deleted_at IS NULL);


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

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


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

ALTER SEQUENCE public.participants_id_seq OWNED BY public.participants.id;


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

CREATE TABLE public.partner_types (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    name character varying(50) NOT NULL
);


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

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


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

ALTER SEQUENCE public.partner_types_id_seq OWNED BY public.partner_types.id;


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

CREATE TABLE public.partners (
    id uuid NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    partner_type_id bigint NOT NULL,
    name character varying(100) NOT NULL,
    employee_count integer DEFAULT 0 NOT NULL,
    dairy_value_chain_experience character varying(100),
    registration_number character varying(60),
    contact_person_name character varying(100),
    contact_person_phone character varying(24),
    contact_person_email character varying(50),
    village_id bigint NOT NULL,
    gps_latitude double precision,
    gps_longitude double precision,
    user_id bigint NOT NULL,
    highest_education_level character varying(50),
    have_tin boolean DEFAULT false NOT NULL,
    tin character varying(28),
    have_bank_account boolean DEFAULT false NOT NULL,
    financial_institution_id bigint,
    account_name character varying(50),
    account_number character varying(28),
    contact_person_gender character varying(10),
    contact_person_year_of_birth character varying(10)
);


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

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


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

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


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

CREATE TABLE public.permission_role (
    id bigint NOT NULL,
    permission_id bigint NOT NULL,
    role_id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.permission_role_id_seq OWNED BY public.permission_role.id;


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

CREATE TABLE public.permission_user (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    permission_id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.permission_user_id_seq OWNED BY public.permission_user.id;


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

CREATE TABLE public.permissions (
    id bigint NOT NULL,
    permission character varying(255) NOT NULL,
    slug character varying(255) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

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


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

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


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

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


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

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


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

CREATE TABLE public.reports (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    first_name character varying(20) NOT NULL,
    last_name character varying(20) NOT NULL,
    phone_number character varying(12),
    issue text NOT NULL,
    responsible character varying(255),
    closed_at timestamp(0) without time zone,
    status character varying(255) DEFAULT 'open'::character varying NOT NULL,
    recommendation text,
    user_id bigint,
    action text,
    village_id bigint,
    gps_latitude character varying(255),
    gps_longitude character varying(255),
    CONSTRAINT reports_status_check CHECK (((status)::text = ANY ((ARRAY['open'::character varying, 'closed'::character varying])::text[])))
);


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

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


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

ALTER SEQUENCE public.reports_id_seq OWNED BY public.reports.id;


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

CREATE TABLE public.role_user (
    id bigint NOT NULL,
    role_id bigint NOT NULL,
    user_id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.role_user_id_seq OWNED BY public.role_user.id;


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

CREATE TABLE public.roles (
    id bigint NOT NULL,
    role character varying(255) NOT NULL,
    slug character varying(255) NOT NULL,
    scope character varying(255) NOT NULL,
    system_defined boolean DEFAULT false NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    jurisdiction_level_id bigint,
    deleted_at timestamp(0) without time zone
);


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

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


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

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


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

CREATE TABLE public."session_user" (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    session_id bigint NOT NULL,
    user_id bigint NOT NULL
);


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

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


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

ALTER SEQUENCE public.session_user_id_seq OWNED BY public."session_user".id;


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

CREATE TABLE public.sessions (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    gps_latitude double precision,
    gps_longitude double precision,
    description text,
    topic_id uuid NOT NULL,
    user_id bigint NOT NULL,
    start_time timestamp(0) without time zone,
    end_time timestamp(0) without time zone,
    venue character varying(120),
    village_id bigint NOT NULL,
    approval_one_status character varying(20) DEFAULT 'pending'::character varying NOT NULL,
    approval_one_by bigint,
    approval_two_status character varying(20) DEFAULT 'pending'::character varying NOT NULL,
    approval_two_by bigint,
    approval_three_status character varying(20) DEFAULT 'pending'::character varying NOT NULL,
    approval_three_by bigint,
    approval_note character varying(255),
    objectives text,
    methodology text,
    findings_and_observations text,
    challenges_encountered text,
    recommendations text,
    lessons_learned text,
    next_steps text,
    approval_date timestamp(0) without time zone,
    training_category_id bigint,
    is_cohort boolean DEFAULT false NOT NULL,
    partner_id uuid,
    approved_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.sessions_id_seq OWNED BY public.sessions.id;


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

CREATE TABLE public.silc (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    farmer_group_id bigint NOT NULL,
    created_by bigint NOT NULL,
    meeting_time timestamp(0) without time zone,
    male_members integer DEFAULT 0 NOT NULL,
    female_members integer DEFAULT 0 NOT NULL,
    monthly_savings integer DEFAULT 0 NOT NULL,
    new_female_savers integer DEFAULT 0 NOT NULL,
    new_male_savers integer DEFAULT 0 NOT NULL,
    total_savings integer DEFAULT 0 NOT NULL,
    total_male_savers integer DEFAULT 0 NOT NULL,
    total_female_savers integer DEFAULT 0 NOT NULL,
    month_loan_amount integer DEFAULT 0 NOT NULL,
    new_female_loanees integer DEFAULT 0 NOT NULL,
    new_male_loanees integer DEFAULT 0 NOT NULL,
    outstanding_loan_amount integer DEFAULT 0 NOT NULL,
    total_female_loanees integer DEFAULT 0 NOT NULL,
    total_male_loanees integer DEFAULT 0 NOT NULL,
    total_dairy_loans integer DEFAULT 0 NOT NULL,
    amount_dairy_loans integer DEFAULT 0 NOT NULL,
    dairy_loan_purpose text,
    date_data_collected timestamp(0) without time zone DEFAULT '2024-09-19 12:21:28'::timestamp without time zone NOT NULL,
    yfa_id bigint
);


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

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


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

ALTER SEQUENCE public.silc_id_seq OWNED BY public.silc.id;


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

CREATE TABLE public.skillables (
    id bigint NOT NULL,
    skillable_id integer NOT NULL,
    skillable_type character varying(255) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    dairy_skill_id integer NOT NULL
);


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

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


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

ALTER SEQUENCE public.skillables_id_seq OWNED BY public.skillables.id;


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

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


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

ALTER SEQUENCE public.subcounties_id_seq OWNED BY public.subcounties.id;


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

CREATE TABLE public.submodules (
    id uuid NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    title character varying(150) NOT NULL,
    description text,
    created_by bigint NOT NULL,
    module_id uuid NOT NULL,
    number_topics_required integer
);


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

CREATE TABLE public.supportables (
    id bigint NOT NULL,
    non_government_organisation_id integer NOT NULL,
    supportable_id integer NOT NULL,
    supportable_type character varying(255) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.supportables_id_seq OWNED BY public.supportables.id;


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

CREATE TABLE public.topics (
    id uuid NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    description text,
    user_id bigint NOT NULL,
    module_id uuid,
    submodule_id uuid NOT NULL
);


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

CREATE TABLE public.training_categories (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    name character varying(50) NOT NULL,
    needs_grade boolean DEFAULT false NOT NULL,
    needs_registration_number boolean DEFAULT false NOT NULL,
    attendance_by_session_approval boolean DEFAULT false NOT NULL,
    require_attendee_nomination boolean DEFAULT false NOT NULL,
    follows_selection_criteria boolean DEFAULT false NOT NULL,
    number_of_sessions integer DEFAULT 0 NOT NULL
);


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

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


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

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


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

CREATE TABLE public.training_levels (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    level integer NOT NULL,
    description character varying(255),
    user_id bigint NOT NULL
);


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

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


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

ALTER SEQUENCE public.training_levels_id_seq OWNED BY public.training_levels.id;


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

CREATE TABLE public.training_modules (
    id uuid NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    title character varying(150) NOT NULL,
    description text,
    created_by bigint NOT NULL
);


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

CREATE TABLE public.training_providers (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    name character varying(120) NOT NULL
);


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

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


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

ALTER SEQUENCE public.training_providers_id_seq OWNED BY public.training_providers.id;


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

CREATE TABLE public.training_session_user (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    training_session_id bigint NOT NULL,
    user_id bigint NOT NULL
);


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

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


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

ALTER SEQUENCE public.training_session_user_id_seq OWNED BY public.training_session_user.id;


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

CREATE TABLE public.training_sessions (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    gps_latitude double precision,
    gps_longitude double precision,
    description text,
    training_id uuid NOT NULL,
    user_id bigint NOT NULL,
    start_time timestamp(0) without time zone,
    end_time timestamp(0) without time zone,
    venue character varying(120),
    village_id bigint NOT NULL,
    approval_one_status character varying(20) DEFAULT 'pending'::character varying NOT NULL,
    approval_one_by bigint,
    approval_two_status character varying(20) DEFAULT 'pending'::character varying NOT NULL,
    approval_two_by bigint,
    approval_three_status character varying(20) DEFAULT 'pending'::character varying NOT NULL,
    approval_three_by bigint,
    approval_note character varying(255),
    objectives text,
    methodology text,
    findings_and_observations text,
    challenges_encountered text,
    recommendations text,
    lessons_learned text,
    next_steps text,
    partner_id uuid,
    is_cohort boolean DEFAULT false NOT NULL,
    approved_at timestamp(0) without time zone
);


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

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


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

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


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

CREATE TABLE public.training_submodule_training (
    id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    training_id uuid NOT NULL,
    training_submodule_id uuid NOT NULL
);


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

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


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

ALTER SEQUENCE public.training_submodule_training_id_seq OWNED BY public.training_submodule_training.id;


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

CREATE TABLE public.training_submodules (
    id uuid NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    title character varying(150) NOT NULL,
    description text,
    created_by bigint NOT NULL,
    training_module_id uuid NOT NULL,
    training_level_id bigint DEFAULT '1'::bigint NOT NULL,
    submodule_required boolean DEFAULT false NOT NULL
);


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

CREATE TABLE public.trainings (
    id uuid NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    deleted_at timestamp(0) without time zone,
    description text,
    user_id bigint NOT NULL,
    training_submodule_id uuid
);


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

CREATE TABLE public.user_details (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    first_name character varying(255) NOT NULL,
    last_name character varying(255) NOT NULL,
    other_name character varying(255),
    address character varying(255),
    district_id bigint,
    staff_number character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.user_details_id_seq OWNED BY public.user_details.id;


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

CREATE TABLE public.user_jurisdictions (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    location_type character varying(20) NOT NULL,
    location_ids json NOT NULL,
    created_by bigint NOT NULL
);


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

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


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

ALTER SEQUENCE public.user_jurisdictions_id_seq OWNED BY public.user_jurisdictions.id;


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

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


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

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


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

CREATE TABLE public.value_addition_activities (
    id bigint NOT NULL,
    value_addition_activity character varying(255) NOT NULL,
    deleted_at timestamp(0) without time zone,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


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

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


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

ALTER SEQUENCE public.value_addition_activities_id_seq OWNED BY public.value_addition_activities.id;


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

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


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

ALTER SEQUENCE public.villages_id_seq OWNED BY public.villages.id;


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

ALTER TABLE ONLY public."session_user" ALTER COLUMN id SET DEFAULT nextval('public.session_user_id_seq'::regclass);


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


--
-- Name: activities activities_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.activities
    ADD CONSTRAINT activities_pkey PRIMARY KEY (id);


--
-- Name: aid_partner aid_partner_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aid_partner
    ADD CONSTRAINT aid_partner_pkey PRIMARY KEY (id);


--
-- Name: aiddables aiddables_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aiddables
    ADD CONSTRAINT aiddables_pkey PRIMARY KEY (id);


--
-- Name: aids aids_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.aids
    ADD CONSTRAINT aids_pkey PRIMARY KEY (id);


--
-- Name: audits audits_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.audits
    ADD CONSTRAINT audits_pkey PRIMARY KEY (id);


--
-- Name: community_roles community_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.community_roles
    ADD CONSTRAINT community_roles_pkey PRIMARY KEY (id);


--
-- Name: cooperatives cooperatives_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cooperatives
    ADD CONSTRAINT cooperatives_pkey PRIMARY KEY (id);


--
-- Name: dairy_products dairy_products_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.dairy_products
    ADD CONSTRAINT dairy_products_pkey PRIMARY KEY (id);


--
-- Name: dairy_skills dairy_skills_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.dairy_skills
    ADD CONSTRAINT dairy_skills_pkey PRIMARY KEY (id);


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

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


--
-- Name: dit_attendances dit_attendances_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.dit_attendances
    ADD CONSTRAINT dit_attendances_pkey PRIMARY KEY (id);


--
-- Name: dit_cohorts dit_cohorts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.dit_cohorts
    ADD CONSTRAINT dit_cohorts_pkey PRIMARY KEY (id);


--
-- Name: dit_courses dit_courses_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.dit_courses
    ADD CONSTRAINT dit_courses_pkey PRIMARY KEY (id);


--
-- Name: earnings earnings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.earnings
    ADD CONSTRAINT earnings_pkey PRIMARY KEY (id);


--
-- Name: education_levels education_levels_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.education_levels
    ADD CONSTRAINT education_levels_pkey PRIMARY KEY (id);


--
-- Name: employment employment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.employment
    ADD CONSTRAINT employment_pkey PRIMARY KEY (id);


--
-- Name: enterprise_farmer_group enterprise_farmer_group_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.enterprise_farmer_group
    ADD CONSTRAINT enterprise_farmer_group_pkey PRIMARY KEY (id);


--
-- Name: enterprise_participant enterprise_participant_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.enterprise_participant
    ADD CONSTRAINT enterprise_participant_pkey PRIMARY KEY (id);


--
-- Name: enterprise_partner enterprise_partner_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.enterprise_partner
    ADD CONSTRAINT enterprise_partner_pkey PRIMARY KEY (id);


--
-- Name: enterprises enterprises_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.enterprises
    ADD CONSTRAINT enterprises_pkey PRIMARY KEY (id);


--
-- Name: equipment equipment_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.equipment
    ADD CONSTRAINT equipment_pkey PRIMARY KEY (id);


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

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


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

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


--
-- Name: farmer_group_bds farmer_group_bds_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_group_bds
    ADD CONSTRAINT farmer_group_bds_pkey PRIMARY KEY (id);


--
-- Name: farmer_groups farmer_groups_farmer_group_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_groups
    ADD CONSTRAINT farmer_groups_farmer_group_code_unique UNIQUE (farmer_group_code);


--
-- Name: farmer_groups farmer_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_groups
    ADD CONSTRAINT farmer_groups_pkey PRIMARY KEY (id);


--
-- Name: fcm_tokens fcm_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.fcm_tokens
    ADD CONSTRAINT fcm_tokens_pkey PRIMARY KEY (id);


--
-- Name: fcm_tokens fcm_tokens_token_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.fcm_tokens
    ADD CONSTRAINT fcm_tokens_token_unique UNIQUE (token);


--
-- Name: financial_institutions financial_institutions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.financial_institutions
    ADD CONSTRAINT financial_institutions_pkey PRIMARY KEY (id);


--
-- Name: forgot_passwords forgot_passwords_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.forgot_passwords
    ADD CONSTRAINT forgot_passwords_pkey PRIMARY KEY (id);


--
-- Name: government_agencies government_agencies_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.government_agencies
    ADD CONSTRAINT government_agencies_pkey PRIMARY KEY (id);


--
-- Name: group_positions group_positions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.group_positions
    ADD CONSTRAINT group_positions_pkey PRIMARY KEY (id);


--
-- Name: input_types input_types_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.input_types
    ADD CONSTRAINT input_types_pkey PRIMARY KEY (id);


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

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


--
-- Name: jurisdiction_levels jurisdiction_levels_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jurisdiction_levels
    ADD CONSTRAINT jurisdiction_levels_pkey PRIMARY KEY (id);


--
-- Name: login_logs login_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.login_logs
    ADD CONSTRAINT login_logs_pkey PRIMARY KEY (id);


--
-- Name: mastercard_programs mastercard_programs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.mastercard_programs
    ADD CONSTRAINT mastercard_programs_pkey PRIMARY KEY (id);


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

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


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

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


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

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


--
-- Name: milk_collection_centres milk_collection_centres_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.milk_collection_centres
    ADD CONSTRAINT milk_collection_centres_pkey PRIMARY KEY (id);


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

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


--
-- Name: non_government_organisations non_government_organisations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.non_government_organisations
    ADD CONSTRAINT non_government_organisations_pkey PRIMARY KEY (id);


--
-- Name: notifications notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_pkey PRIMARY KEY (id);


--
-- Name: organisations organisations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.organisations
    ADD CONSTRAINT organisations_pkey PRIMARY KEY (id);


--
-- Name: parishes parishes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.parishes
    ADD CONSTRAINT parishes_pkey PRIMARY KEY (id);


--
-- Name: participant_bds participant_bds_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participant_bds
    ADD CONSTRAINT participant_bds_pkey PRIMARY KEY (id);


--
-- Name: participant_partner participant_partner_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participant_partner
    ADD CONSTRAINT participant_partner_pkey PRIMARY KEY (id);


--
-- Name: participant_session participant_session_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participant_session
    ADD CONSTRAINT participant_session_pkey PRIMARY KEY (id);


--
-- Name: participant_training_session participant_training_session_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participant_training_session
    ADD CONSTRAINT participant_training_session_pkey PRIMARY KEY (id);


--
-- Name: participant_types participant_types_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participant_types
    ADD CONSTRAINT participant_types_pkey PRIMARY KEY (id);


--
-- Name: participants participants_participant_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_participant_code_unique UNIQUE (participant_code);


--
-- Name: participants participants_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_pkey PRIMARY KEY (id);


--
-- Name: partner_types partner_types_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.partner_types
    ADD CONSTRAINT partner_types_pkey PRIMARY KEY (id);


--
-- Name: partners partners_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.partners
    ADD CONSTRAINT partners_pkey PRIMARY KEY (id);


--
-- Name: password_reset_tokens password_reset_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.password_reset_tokens
    ADD CONSTRAINT password_reset_tokens_pkey PRIMARY KEY (email);


--
-- Name: permission_role permission_role_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.permission_role
    ADD CONSTRAINT permission_role_pkey PRIMARY KEY (id);


--
-- Name: permission_user permission_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.permission_user
    ADD CONSTRAINT permission_user_pkey PRIMARY KEY (id);


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

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


--
-- Name: personal_access_tokens personal_access_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.personal_access_tokens
    ADD CONSTRAINT personal_access_tokens_pkey PRIMARY KEY (id);


--
-- Name: personal_access_tokens personal_access_tokens_token_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.personal_access_tokens
    ADD CONSTRAINT personal_access_tokens_token_unique UNIQUE (token);


--
-- Name: reports reports_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reports
    ADD CONSTRAINT reports_pkey PRIMARY KEY (id);


--
-- Name: role_user role_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.role_user
    ADD CONSTRAINT role_user_pkey PRIMARY KEY (id);


--
-- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.roles
    ADD CONSTRAINT roles_pkey PRIMARY KEY (id);


--
-- Name: session_user session_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."session_user"
    ADD CONSTRAINT session_user_pkey PRIMARY KEY (id);


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

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


--
-- Name: silc silc_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.silc
    ADD CONSTRAINT silc_pkey PRIMARY KEY (id);


--
-- Name: skillables skillables_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.skillables
    ADD CONSTRAINT skillables_pkey PRIMARY KEY (id);


--
-- Name: subcounties subcounties_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcounties
    ADD CONSTRAINT subcounties_pkey PRIMARY KEY (id);


--
-- Name: submodules submodules_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.submodules
    ADD CONSTRAINT submodules_pkey PRIMARY KEY (id);


--
-- Name: supportables supportables_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supportables
    ADD CONSTRAINT supportables_pkey PRIMARY KEY (id);


--
-- Name: topics topics_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.topics
    ADD CONSTRAINT topics_pkey PRIMARY KEY (id);


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

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


--
-- Name: training_levels training_levels_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_levels
    ADD CONSTRAINT training_levels_pkey PRIMARY KEY (id);


--
-- Name: training_modules training_modules_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_modules
    ADD CONSTRAINT training_modules_pkey PRIMARY KEY (id);


--
-- Name: training_providers training_providers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_providers
    ADD CONSTRAINT training_providers_pkey PRIMARY KEY (id);


--
-- Name: training_session_user training_session_user_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_session_user
    ADD CONSTRAINT training_session_user_pkey PRIMARY KEY (id);


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

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


--
-- Name: training_submodule_training training_submodule_training_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_submodule_training
    ADD CONSTRAINT training_submodule_training_pkey PRIMARY KEY (id);


--
-- Name: training_submodules training_submodules_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_submodules
    ADD CONSTRAINT training_submodules_pkey PRIMARY KEY (id);


--
-- Name: trainings trainings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.trainings
    ADD CONSTRAINT trainings_pkey PRIMARY KEY (id);


--
-- Name: user_details user_details_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_details
    ADD CONSTRAINT user_details_pkey PRIMARY KEY (id);


--
-- Name: user_jurisdictions user_jurisdictions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_jurisdictions
    ADD CONSTRAINT user_jurisdictions_pkey PRIMARY KEY (id);


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

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


--
-- Name: value_addition_activities value_addition_activities_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.value_addition_activities
    ADD CONSTRAINT value_addition_activities_pkey PRIMARY KEY (id);


--
-- Name: villages villages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.villages
    ADD CONSTRAINT villages_pkey PRIMARY KEY (id);


--
-- Name: audits_auditable_type_auditable_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX audits_auditable_type_auditable_id_index ON public.audits USING btree (auditable_type, auditable_id);


--
-- Name: audits_user_id_user_type_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX audits_user_id_user_type_index ON public.audits USING btree (user_id, user_type);


--
-- Name: jobs_queue_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jobs_queue_index ON public.jobs USING btree (queue);


--
-- Name: media_model_type_model_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX media_model_type_model_id_index ON public.media USING btree (model_type, model_id);


--
-- Name: media_order_column_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX media_order_column_index ON public.media USING btree (order_column);


--
-- Name: notifications_notifiable_type_notifiable_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX notifications_notifiable_type_notifiable_id_index ON public.notifications USING btree (notifiable_type, notifiable_id);


--
-- Name: password_resets_email_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX password_resets_email_index ON public.password_resets USING btree (email);


--
-- Name: personal_access_tokens_tokenable_type_tokenable_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX personal_access_tokens_tokenable_type_tokenable_id_index ON public.personal_access_tokens USING btree (tokenable_type, tokenable_id);


--
-- Name: enterprise_farmer_group enterprise_farmer_group_enterprise_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.enterprise_farmer_group
    ADD CONSTRAINT enterprise_farmer_group_enterprise_id_foreign FOREIGN KEY (enterprise_id) REFERENCES public.enterprises(id);


--
-- Name: enterprise_farmer_group enterprise_farmer_group_farmer_group_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.enterprise_farmer_group
    ADD CONSTRAINT enterprise_farmer_group_farmer_group_id_foreign FOREIGN KEY (farmer_group_id) REFERENCES public.farmer_groups(id);


--
-- Name: enterprise_participant enterprise_participant_enterprise_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.enterprise_participant
    ADD CONSTRAINT enterprise_participant_enterprise_id_foreign FOREIGN KEY (enterprise_id) REFERENCES public.enterprises(id);


--
-- Name: enterprise_participant enterprise_participant_farmer_group_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.enterprise_participant
    ADD CONSTRAINT enterprise_participant_farmer_group_id_foreign FOREIGN KEY (farmer_group_id) REFERENCES public.farmer_groups(id);


--
-- Name: enterprises enterprises_activity_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.enterprises
    ADD CONSTRAINT enterprises_activity_id_foreign FOREIGN KEY (activity_id) REFERENCES public.activities(id);


--
-- Name: farmer_groups farmer_groups_cooperative_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_groups
    ADD CONSTRAINT farmer_groups_cooperative_id_foreign FOREIGN KEY (cooperative_id) REFERENCES public.cooperatives(id);


--
-- Name: farmer_groups farmer_groups_enterprise_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_groups
    ADD CONSTRAINT farmer_groups_enterprise_id_foreign FOREIGN KEY (enterprise_id) REFERENCES public.enterprises(id);


--
-- Name: farmer_groups farmer_groups_financial_institution_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_groups
    ADD CONSTRAINT farmer_groups_financial_institution_id_foreign FOREIGN KEY (financial_institution_id) REFERENCES public.financial_institutions(id);


--
-- Name: farmer_groups farmer_groups_group_position_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_groups
    ADD CONSTRAINT farmer_groups_group_position_id_foreign FOREIGN KEY (group_position_id) REFERENCES public.group_positions(id);


--
-- Name: farmer_groups farmer_groups_loan_financial_institution_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_groups
    ADD CONSTRAINT farmer_groups_loan_financial_institution_id_foreign FOREIGN KEY (loan_financial_institution_id) REFERENCES public.financial_institutions(id);


--
-- Name: farmer_groups farmer_groups_mastercard_program_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_groups
    ADD CONSTRAINT farmer_groups_mastercard_program_id_foreign FOREIGN KEY (mastercard_program_id) REFERENCES public.mastercard_programs(id);


--
-- Name: farmer_groups farmer_groups_non_government_organisation_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_groups
    ADD CONSTRAINT farmer_groups_non_government_organisation_id_foreign FOREIGN KEY (non_government_organisation_id) REFERENCES public.non_government_organisations(id);


--
-- Name: farmer_groups farmer_groups_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_groups
    ADD CONSTRAINT farmer_groups_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: farmer_groups farmer_groups_village_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.farmer_groups
    ADD CONSTRAINT farmer_groups_village_id_foreign FOREIGN KEY (village_id) REFERENCES public.villages(id);


--
-- Name: forgot_passwords forgot_passwords_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.forgot_passwords
    ADD CONSTRAINT forgot_passwords_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: login_logs login_logs_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.login_logs
    ADD CONSTRAINT login_logs_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: milk_collection_centres milk_collection_centres_financial_institution_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.milk_collection_centres
    ADD CONSTRAINT milk_collection_centres_financial_institution_id_foreign FOREIGN KEY (financial_institution_id) REFERENCES public.financial_institutions(id);


--
-- Name: milk_collection_centres milk_collection_centres_village_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.milk_collection_centres
    ADD CONSTRAINT milk_collection_centres_village_id_foreign FOREIGN KEY (village_id) REFERENCES public.villages(id);


--
-- Name: modules modules_created_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.modules
    ADD CONSTRAINT modules_created_by_foreign FOREIGN KEY (created_by) REFERENCES public.users(id);


--
-- Name: parishes parishes_subcounty_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.parishes
    ADD CONSTRAINT parishes_subcounty_id_foreign FOREIGN KEY (subcounty_id) REFERENCES public.subcounties(id);


--
-- Name: participant_session participant_session_participant_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participant_session
    ADD CONSTRAINT participant_session_participant_id_foreign FOREIGN KEY (participant_id) REFERENCES public.participants(id) ON DELETE CASCADE;


--
-- Name: participant_session participant_session_session_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participant_session
    ADD CONSTRAINT participant_session_session_id_foreign FOREIGN KEY (session_id) REFERENCES public.sessions(id) ON DELETE CASCADE;


--
-- Name: participant_training_session participant_training_session_participant_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participant_training_session
    ADD CONSTRAINT participant_training_session_participant_id_foreign FOREIGN KEY (participant_id) REFERENCES public.participants(id) ON DELETE CASCADE;


--
-- Name: participant_training_session participant_training_session_training_session_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participant_training_session
    ADD CONSTRAINT participant_training_session_training_session_id_foreign FOREIGN KEY (training_session_id) REFERENCES public.training_sessions(id) ON DELETE CASCADE;


--
-- Name: participants participants_community_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_community_role_id_foreign FOREIGN KEY (community_role_id) REFERENCES public.community_roles(id);


--
-- Name: participants participants_created_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_created_by_foreign FOREIGN KEY (created_by) REFERENCES public.users(id);


--
-- Name: participants participants_dairy_skill_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_dairy_skill_id_foreign FOREIGN KEY (dairy_skill_id) REFERENCES public.dairy_skills(id);


--
-- Name: participants participants_enterprise_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_enterprise_id_foreign FOREIGN KEY (enterprise_id) REFERENCES public.enterprises(id);


--
-- Name: participants participants_farmer_group_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_farmer_group_id_foreign FOREIGN KEY (farmer_group_id) REFERENCES public.farmer_groups(id);


--
-- Name: participants participants_financial_institution_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_financial_institution_id_foreign FOREIGN KEY (financial_institution_id) REFERENCES public.financial_institutions(id);


--
-- Name: participants participants_group_position_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_group_position_id_foreign FOREIGN KEY (group_position_id) REFERENCES public.group_positions(id);


--
-- Name: participants participants_loan_financial_institution_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_loan_financial_institution_id_foreign FOREIGN KEY (loan_financial_institution_id) REFERENCES public.financial_institutions(id);


--
-- Name: participants participants_non_government_organisation_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_non_government_organisation_id_foreign FOREIGN KEY (non_government_organisation_id) REFERENCES public.non_government_organisations(id);


--
-- Name: participants participants_participant_type_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_participant_type_id_foreign FOREIGN KEY (participant_type_id) REFERENCES public.participant_types(id);


--
-- Name: participants participants_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: participants participants_village_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.participants
    ADD CONSTRAINT participants_village_id_foreign FOREIGN KEY (village_id) REFERENCES public.villages(id);


--
-- Name: permission_role permission_role_permission_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.permission_role
    ADD CONSTRAINT permission_role_permission_id_foreign FOREIGN KEY (permission_id) REFERENCES public.permissions(id);


--
-- Name: permission_role permission_role_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.permission_role
    ADD CONSTRAINT permission_role_role_id_foreign FOREIGN KEY (role_id) REFERENCES public.roles(id);


--
-- Name: permission_user permission_user_permission_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.permission_user
    ADD CONSTRAINT permission_user_permission_id_foreign FOREIGN KEY (permission_id) REFERENCES public.permissions(id);


--
-- Name: permission_user permission_user_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.permission_user
    ADD CONSTRAINT permission_user_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: role_user role_user_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.role_user
    ADD CONSTRAINT role_user_role_id_foreign FOREIGN KEY (role_id) REFERENCES public.roles(id);


--
-- Name: role_user role_user_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.role_user
    ADD CONSTRAINT role_user_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: roles roles_jurisdiction_level_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.roles
    ADD CONSTRAINT roles_jurisdiction_level_id_foreign FOREIGN KEY (jurisdiction_level_id) REFERENCES public.jurisdiction_levels(id);


--
-- Name: session_user session_user_session_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."session_user"
    ADD CONSTRAINT session_user_session_id_foreign FOREIGN KEY (session_id) REFERENCES public.sessions(id) ON DELETE CASCADE;


--
-- Name: session_user session_user_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."session_user"
    ADD CONSTRAINT session_user_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: sessions sessions_topic_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sessions
    ADD CONSTRAINT sessions_topic_id_foreign FOREIGN KEY (topic_id) REFERENCES public.topics(id) ON DELETE CASCADE;


--
-- Name: sessions sessions_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sessions
    ADD CONSTRAINT sessions_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: sessions sessions_village_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sessions
    ADD CONSTRAINT sessions_village_id_foreign FOREIGN KEY (village_id) REFERENCES public.villages(id);


--
-- Name: subcounties subcounties_district_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subcounties
    ADD CONSTRAINT subcounties_district_id_foreign FOREIGN KEY (district_id) REFERENCES public.districts(id);


--
-- Name: submodules submodules_created_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.submodules
    ADD CONSTRAINT submodules_created_by_foreign FOREIGN KEY (created_by) REFERENCES public.users(id);


--
-- Name: submodules submodules_module_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.submodules
    ADD CONSTRAINT submodules_module_id_foreign FOREIGN KEY (module_id) REFERENCES public.modules(id) ON DELETE CASCADE;


--
-- Name: topics topics_submodule_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.topics
    ADD CONSTRAINT topics_submodule_id_foreign FOREIGN KEY (submodule_id) REFERENCES public.submodules(id) ON DELETE CASCADE;


--
-- Name: topics topics_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.topics
    ADD CONSTRAINT topics_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: training_session_user training_session_user_training_session_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_session_user
    ADD CONSTRAINT training_session_user_training_session_id_foreign FOREIGN KEY (training_session_id) REFERENCES public.training_sessions(id) ON DELETE CASCADE;


--
-- Name: training_sessions training_sessions_training_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_sessions
    ADD CONSTRAINT training_sessions_training_id_foreign FOREIGN KEY (training_id) REFERENCES public.trainings(id) ON DELETE CASCADE;


--
-- Name: training_submodule_training training_submodule_training_training_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_submodule_training
    ADD CONSTRAINT training_submodule_training_training_id_foreign FOREIGN KEY (training_id) REFERENCES public.trainings(id) ON DELETE CASCADE;


--
-- Name: training_submodule_training training_submodule_training_training_submodule_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.training_submodule_training
    ADD CONSTRAINT training_submodule_training_training_submodule_id_foreign FOREIGN KEY (training_submodule_id) REFERENCES public.training_submodules(id) ON DELETE CASCADE;


--
-- Name: user_details user_details_district_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_details
    ADD CONSTRAINT user_details_district_id_foreign FOREIGN KEY (district_id) REFERENCES public.districts(id);


--
-- Name: user_details user_details_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_details
    ADD CONSTRAINT user_details_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: user_jurisdictions user_jurisdictions_created_by_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_jurisdictions
    ADD CONSTRAINT user_jurisdictions_created_by_foreign FOREIGN KEY (created_by) REFERENCES public.users(id);


--
-- Name: user_jurisdictions user_jurisdictions_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_jurisdictions
    ADD CONSTRAINT user_jurisdictions_user_id_foreign FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: users users_organisation_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_organisation_id_foreign FOREIGN KEY (organisation_id) REFERENCES public.organisations(id);


--
-- Name: users users_partner_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_partner_id_foreign FOREIGN KEY (partner_id) REFERENCES public.partners(id) ON DELETE CASCADE;


--
-- Name: villages villages_parish_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.villages
    ADD CONSTRAINT villages_parish_id_foreign FOREIGN KEY (parish_id) REFERENCES public.parishes(id);


--
--

--
--


SELECT pg_catalog.set_config('search_path', '', false);

--
-- Data for Name: migrations; Type: TABLE DATA; Schema: public; Owner: -
--

COPY public.migrations (id, migration, batch) FROM stdin;
1	2014_06_27_121509_create_organisations_table	1
2	2014_06_27_122518_create_activities_table	1
3	2014_06_27_140832_create_group_positions_table	1
4	2014_06_27_142759_create_enterprises_table	1
5	2014_06_27_144433_create_districts_table	1
6	2014_06_28_171307_create_education_levels_table	1
7	2014_06_29_140028_create_subcounties_table	1
8	2014_06_29_140041_create_parishes_table	1
9	2014_06_29_140053_create_villages_table	1
10	2014_07_11_195027_create_financial_institutions_table	1
11	2014_07_14_055159_create_cooperatives_table	1
12	2014_07_14_055444_create_participant_types_table	1
13	2014_07_14_071136_create_non_government_organisations_table	1
14	2014_07_14_092435_create_equipment_table	1
15	2014_07_14_093733_create_dairy_products_table	1
16	2014_07_14_093950_create_dairy_skills_table	1
17	2014_07_20_190249_create_government_agencies_table	1
18	2014_07_20_190632_create_mastercard_programs_table	1
19	2014_07_21_083752_create_community_roles_table	1
20	2014_07_21_091958_create_value_addition_activities_table	1
21	2014_10_12_000000_create_users_table	1
22	2014_10_12_100000_create_password_reset_tokens_table	1
23	2014_10_12_100000_create_password_resets_table	1
24	2019_08_19_000000_create_failed_jobs_table	1
25	2019_12_14_000001_create_personal_access_tokens_table	1
26	2023_06_27_101232_create_roles_table	1
27	2023_06_27_101241_create_permissions_table	1
28	2023_06_27_101330_create_user_details_table	1
29	2023_06_27_102403_create_role_user_table	1
30	2023_06_27_102420_create_permission_user_table	1
31	2023_06_27_102433_create_permission_role_table	1
32	2023_06_27_102659_create_audits_table	1
33	2023_06_27_121518_create_farmer_groups_table	1
34	2023_06_29_120353_create_jobs_table	1
35	2023_07_14_090459_create_participants_table	1
36	2023_07_21_090040_create_milk_collection_centres_table	1
37	2023_08_02_201955_create_enterprise_farmer_group_table	1
38	2023_08_02_202343_create_enterprise_participant_table	1
39	2023_08_18_094423_create_jurisdiction_levels_table	1
40	2023_08_18_153406_add_web_login_to_users_table	1
41	2023_08_18_153438_add_jurisdiction_level_to_roles_table	1
42	2023_08_18_153754_create_user_jurisdictions_table	1
43	2023_08_27_131100_create_forgot_passwords_table	1
44	2023_08_27_142846_create_notifications_table	1
45	2023_09_12_100219_add_dairy_skill_id_participants_table	1
46	2023_09_12_160426_add_non_government_organisation_id_participants_table	1
47	2023_09_12_160442_add_non_government_organisation_id_farmer_groups_table	1
48	2023_10_03_132854_create_skillables_table	2
49	2023_10_04_084230_add_field_to_skillables_table	3
50	2023_10_07_094139_create_supportables_table	4
51	2023_10_14_121523_add_fields_to_participants_table	5
52	2023_10_24_162059_add_fields_to_participants	6
54	2023_10_24_163650_remove_field_from_participants_table	7
55	2023_10_30_190522_add_fields_to_roles_table	8
56	2023_11_13_220941_update_columns_on_participants_table	9
57	2023_11_13_224427_update_column_on_participants_table	10
67	2023_11_21_100411_add_approval_fields_to_participants_table	11
68	2023_12_07_145804_create_training_modules_table	11
69	2023_12_07_151739_create_training_submodules_table	11
72	2023_12_08_131846_create_trainings_table	12
76	2023_12_08_122325_create_training_sessions_table	13
77	2023_12_08_220140_create_training_submodule_training_table	13
78	2023_12_09_170600_create_media_table	14
79	2023_12_09_184823_create_training_session_user_table	15
80	2023_12_09_185936_participant_training_session_table	15
85	2023_12_10_231935_create_training_levels_table	16
86	2023_12_10_232201_add_fields_to_training_submodules_table	16
87	2023_12_15_122515_add_fields_to_training_sessions_table	17
90	2024_01_06_134153_create_employment_table	18
91	2024_01_06_142416_create_earnings_table	18
102	2024_01_15_172503_create_aid_table	20
108	2024_01_29_154023_create_partners_table	21
109	2024_02_23_115539_create_bds_linkage_tables	21
110	2024_03_12_202024_add_next_of_kin_fields_to_participants_table	22
111	2024_03_25_153212_create_silc_table	23
112	2024_05_13_122910_add_filed_to_employment_table	24
113	2024_05_13_172105_add_fields_to_partners_table	25
114	2024_05_22_162500_create_aid_partner_table	26
115	2024_05_22_170457_add_referral_field_to_participants_table	27
116	2024_06_20_090314_create_reports_table	28
117	2024_07_30_105803_recreate_partners_table	29
118	2024_08_01_100125_create_fcm_tokens_table	30
120	2024_09_03_142820_create_dit_tables	31
122	2024_09_11_122848_add_fields_to_participant_bds_table	32
123	2024_09_12_111323_add_fields_to_dit_attendances_table	33
124	2024_09_12_180707_alter_fields_partners_table	34
126	2024_09_13_093750_add_field_training_submodules_table	35
127	2024_09_19_104250_update-silc-table	36
128	2024_09_25_094915_add_extra_refugee_fields_to_participants_table	37
129	2024_09_29_104136_change_fileds_on_participants_table	38
131	2024_10_14_102746_add_fields_to_user_jurisdictions_table	39
133	2024_10_22_102758_add_fields_to_training_sessions_table	40
134	2024_10_25_093700_add_fields_to_participant_training_session_table	41
135	2024_10_26_130246_create_training_category_table	42
136	2024_10_26_142615_create_training_tables	43
138	2024_10_28_194050_add_fields_to_sessions_table	44
141	2024_10_29_111459_create_login_logs_table	45
142	2024_10_29_131301_add_fields_to_users_table	46
143	2024_10_30_112552_add_employment_field_to_participants_table	47
145	2024_11_01_103954_add_field_to_trainings_table	48
146	2024_11_03_121904_add_approved_at_fields	49
\.


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

SELECT pg_catalog.setval('public.migrations_id_seq', 146, true);


--
--

