-- Schema: fineract_barebones_db
CREATE SCHEMA IF NOT EXISTS "fineract_barebones_db";

-- Table: acc_accounting_rule
CREATE TABLE "fineract_barebones_db"."acc_accounting_rule" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.acc_accounting_rule_id_seq'::regclass),
    "name" VARCHAR(100) DEFAULT NULL::character varying,
    "office_id" BIGINT,
    "debit_account_id" BIGINT,
    "allow_multiple_debits" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "credit_account_id" BIGINT,
    "allow_multiple_credits" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "description" VARCHAR(500) DEFAULT NULL::character varying,
    "system_defined" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "acc_accounting_rule_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "acc_accounting_rule_credit_account_id_key" UNIQUE ("credit_account_id"),
    CONSTRAINT "acc_accounting_rule_debit_account_id_key" UNIQUE ("debit_account_id"),
    CONSTRAINT "acc_accounting_rule_name_key" UNIQUE ("name"),
    CONSTRAINT "acc_accounting_rule_office_id_key" UNIQUE ("office_id")
);

-- Table: acc_gl_account
CREATE TABLE "fineract_barebones_db"."acc_gl_account" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.acc_gl_account_id_seq'::regclass),
    "name" VARCHAR(200) NOT NULL,
    "parent_id" BIGINT,
    "hierarchy" VARCHAR(50) DEFAULT NULL::character varying,
    "gl_code" VARCHAR(45) NOT NULL,
    "disabled" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "manual_journal_entries_allowed" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "account_usage" SMALLINT NOT NULL DEFAULT '2'::smallint,
    "classification_enum" SMALLINT NOT NULL,
    "tag_id" INTEGER,
    "description" VARCHAR(500) DEFAULT NULL::character varying,
    CONSTRAINT "acc_gl_account_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "acc_gl_account_gl_code_key" UNIQUE ("gl_code"),
    CONSTRAINT "acc_gl_account_parent_id_key" UNIQUE ("parent_id"),
    CONSTRAINT "acc_gl_account_tag_id_key" UNIQUE ("tag_id")
);

-- Table: acc_gl_closure
CREATE TABLE "fineract_barebones_db"."acc_gl_closure" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.acc_gl_closure_id_seq'::regclass),
    "office_id" BIGINT NOT NULL,
    "closing_date" DATE NOT NULL,
    "is_deleted" INTEGER NOT NULL DEFAULT 0,
    "createdby_id" BIGINT,
    "lastmodifiedby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodified_date" TIMESTAMP,
    "comments" VARCHAR(500) DEFAULT NULL::character varying,
    CONSTRAINT "acc_gl_closure_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "acc_gl_closure_createdby_id_key" UNIQUE ("createdby_id"),
    CONSTRAINT "acc_gl_closure_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id"),
    CONSTRAINT "acc_gl_closure_office_id_closing_date_key" UNIQUE ("office_id", "closing_date"),
    CONSTRAINT "acc_gl_closure_office_id_key" UNIQUE ("office_id")
);

-- Table: acc_gl_financial_activity_account
CREATE TABLE "fineract_barebones_db"."acc_gl_financial_activity_account" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.acc_gl_financial_activity_account_id_seq'::regclass),
    "gl_account_id" BIGINT NOT NULL DEFAULT '0'::bigint,
    "financial_activity_type" SMALLINT NOT NULL,
    CONSTRAINT "acc_gl_financial_activity_account_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "acc_gl_financial_activity_account_financial_activity_type_key" UNIQUE ("financial_activity_type"),
    CONSTRAINT "acc_gl_financial_activity_account_gl_account_id_key" UNIQUE ("gl_account_id")
);

-- Table: acc_gl_journal_entry
CREATE TABLE "fineract_barebones_db"."acc_gl_journal_entry" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.acc_gl_journal_entry_id_seq'::regclass),
    "account_id" BIGINT NOT NULL,
    "office_id" BIGINT NOT NULL,
    "reversal_id" BIGINT,
    "currency_code" VARCHAR(3) NOT NULL,
    "transaction_id" VARCHAR(50) NOT NULL,
    "loan_transaction_id" BIGINT,
    "savings_transaction_id" BIGINT,
    "client_transaction_id" BIGINT,
    "reversed" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "ref_num" VARCHAR(100) DEFAULT NULL::character varying,
    "manual_entry" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "entry_date" DATE NOT NULL,
    "type_enum" SMALLINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "description" VARCHAR(500) DEFAULT NULL::character varying,
    "entity_type_enum" SMALLINT,
    "entity_id" BIGINT,
    "createdby_id" BIGINT NOT NULL,
    "lastmodifiedby_id" BIGINT NOT NULL,
    "created_date" TIMESTAMP NOT NULL,
    "lastmodified_date" TIMESTAMP NOT NULL,
    "is_running_balance_calculated" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "office_running_balance" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "organization_running_balance" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "payment_details_id" BIGINT,
    "share_transaction_id" BIGINT,
    CONSTRAINT "acc_gl_journal_entry_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "acc_gl_journal_entry_account_id_key" UNIQUE ("account_id"),
    CONSTRAINT "acc_gl_journal_entry_client_transaction_id_key" UNIQUE ("client_transaction_id"),
    CONSTRAINT "acc_gl_journal_entry_createdby_id_key" UNIQUE ("createdby_id"),
    CONSTRAINT "acc_gl_journal_entry_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id"),
    CONSTRAINT "acc_gl_journal_entry_loan_transaction_id_key" UNIQUE ("loan_transaction_id"),
    CONSTRAINT "acc_gl_journal_entry_office_id_key" UNIQUE ("office_id"),
    CONSTRAINT "acc_gl_journal_entry_payment_details_id_key" UNIQUE ("payment_details_id"),
    CONSTRAINT "acc_gl_journal_entry_reversal_id_key" UNIQUE ("reversal_id"),
    CONSTRAINT "acc_gl_journal_entry_savings_transaction_id_key" UNIQUE ("savings_transaction_id"),
    CONSTRAINT "acc_gl_journal_entry_share_transaction_id_key" UNIQUE ("share_transaction_id")
);

-- Table: acc_product_mapping
CREATE TABLE "fineract_barebones_db"."acc_product_mapping" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.acc_product_mapping_id_seq'::regclass),
    "gl_account_id" BIGINT,
    "product_id" BIGINT,
    "product_type" SMALLINT,
    "payment_type" INTEGER,
    "charge_id" BIGINT,
    "financial_account_type" SMALLINT,
    CONSTRAINT "acc_product_mapping_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "acc_product_mapping_charge_id_key" UNIQUE ("charge_id"),
    CONSTRAINT "acc_product_mapping_payment_type_key" UNIQUE ("payment_type")
);

-- Table: acc_rule_tags
CREATE TABLE "fineract_barebones_db"."acc_rule_tags" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.acc_rule_tags_id_seq'::regclass),
    "acc_rule_id" BIGINT NOT NULL,
    "tag_id" INTEGER NOT NULL,
    "acc_type_enum" SMALLINT NOT NULL,
    CONSTRAINT "acc_rule_tags_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "acc_rule_tags_acc_rule_id_key" UNIQUE ("acc_rule_id"),
    CONSTRAINT "acc_rule_tags_acc_rule_id_tag_id_acc_type_enum_key" UNIQUE ("acc_rule_id", "tag_id", "acc_type_enum"),
    CONSTRAINT "acc_rule_tags_tag_id_key" UNIQUE ("tag_id")
);

-- Table: c_account_number_format
CREATE TABLE "fineract_barebones_db"."c_account_number_format" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.c_account_number_format_id_seq'::regclass),
    "account_type_enum" SMALLINT NOT NULL,
    "prefix_type_enum" SMALLINT,
    CONSTRAINT "c_account_number_format_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "c_account_number_format_account_type_enum_key" UNIQUE ("account_type_enum")
);

-- Table: c_cache
CREATE TABLE "fineract_barebones_db"."c_cache" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.c_cache_id_seq'::regclass),
    "cache_type_enum" SMALLINT NOT NULL DEFAULT '1'::smallint,
    CONSTRAINT "c_cache_pkey" PRIMARY KEY ("id")
);

-- Table: c_configuration
CREATE TABLE "fineract_barebones_db"."c_configuration" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.c_configuration_id_seq'::regclass),
    "name" VARCHAR(100) DEFAULT NULL::character varying,
    "value" INTEGER,
    "date_value" DATE,
    "enabled" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "is_trap_door" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "description" VARCHAR(300) DEFAULT NULL::character varying,
    CONSTRAINT "c_configuration_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "c_configuration_name_key" UNIQUE ("name")
);

-- Table: c_external_service
CREATE TABLE "fineract_barebones_db"."c_external_service" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.c_external_service_id_seq'::regclass),
    "name" VARCHAR(100) DEFAULT NULL::character varying,
    CONSTRAINT "c_external_service_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "c_external_service_name_key" UNIQUE ("name")
);

-- Table: c_external_service_properties
CREATE TABLE "fineract_barebones_db"."c_external_service_properties" (
    "name" VARCHAR(150) NOT NULL,
    "value" VARCHAR(250) DEFAULT NULL::character varying,
    "external_service_id" BIGINT NOT NULL,
    CONSTRAINT "c_external_service_properties_external_service_id_key" UNIQUE ("external_service_id")
);

-- Table: job
CREATE TABLE "fineract_barebones_db"."job" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.job_id_seq'::regclass),
    "name" VARCHAR(100) NOT NULL,
    "display_name" VARCHAR(100) NOT NULL,
    "cron_expression" VARCHAR(20) NOT NULL,
    "create_time" TIMESTAMP NOT NULL,
    "task_priority" SMALLINT NOT NULL DEFAULT '5'::smallint,
    "group_name" VARCHAR(50) DEFAULT NULL::character varying,
    "previous_run_start_time" TIMESTAMP,
    "next_run_time" TIMESTAMP,
    "job_key" VARCHAR(500) DEFAULT NULL::character varying,
    "initializing_errorlog" TEXT,
    "is_active" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "currently_running" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "updates_allowed" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "scheduler_group" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "is_misfired" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "job_pkey" PRIMARY KEY ("id")
);

-- Table: job_run_history
CREATE TABLE "fineract_barebones_db"."job_run_history" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.job_run_history_id_seq'::regclass),
    "job_id" BIGINT NOT NULL,
    "version" BIGINT NOT NULL,
    "start_time" TIMESTAMP NOT NULL,
    "end_time" TIMESTAMP NOT NULL,
    "status" VARCHAR(10) NOT NULL,
    "error_message" TEXT,
    "trigger_type" VARCHAR(25) NOT NULL,
    "error_log" TEXT,
    CONSTRAINT "job_run_history_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "job_run_history_job_id_key" UNIQUE ("job_id")
);

-- Table: m_account_transfer_details
CREATE TABLE "fineract_barebones_db"."m_account_transfer_details" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_account_transfer_details_id_seq'::regclass),
    "from_office_id" BIGINT NOT NULL,
    "to_office_id" BIGINT NOT NULL,
    "from_client_id" BIGINT,
    "to_client_id" BIGINT,
    "from_savings_account_id" BIGINT,
    "to_savings_account_id" BIGINT,
    "from_loan_account_id" BIGINT,
    "to_loan_account_id" BIGINT,
    "transfer_type" SMALLINT,
    CONSTRAINT "m_account_transfer_details_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_account_transfer_details_from_client_id_key" UNIQUE ("from_client_id"),
    CONSTRAINT "m_account_transfer_details_from_loan_account_id_key" UNIQUE ("from_loan_account_id"),
    CONSTRAINT "m_account_transfer_details_from_office_id_key" UNIQUE ("from_office_id"),
    CONSTRAINT "m_account_transfer_details_from_savings_account_id_key" UNIQUE ("from_savings_account_id"),
    CONSTRAINT "m_account_transfer_details_to_client_id_key" UNIQUE ("to_client_id"),
    CONSTRAINT "m_account_transfer_details_to_loan_account_id_key" UNIQUE ("to_loan_account_id"),
    CONSTRAINT "m_account_transfer_details_to_office_id_key" UNIQUE ("to_office_id"),
    CONSTRAINT "m_account_transfer_details_to_savings_account_id_key" UNIQUE ("to_savings_account_id")
);

-- Table: m_account_transfer_standing_instructions
CREATE TABLE "fineract_barebones_db"."m_account_transfer_standing_instructions" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_account_transfer_standing_instructions_id_seq'::regclass),
    "name" VARCHAR(250) NOT NULL,
    "account_transfer_details_id" BIGINT NOT NULL,
    "priority" SMALLINT NOT NULL,
    "status" SMALLINT NOT NULL,
    "instruction_type" SMALLINT NOT NULL,
    "amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "valid_from" DATE NOT NULL,
    "valid_till" DATE,
    "recurrence_type" SMALLINT NOT NULL,
    "recurrence_frequency" SMALLINT,
    "recurrence_interval" SMALLINT,
    "recurrence_on_day" SMALLINT,
    "recurrence_on_month" SMALLINT,
    "last_run_date" DATE,
    CONSTRAINT "m_account_transfer_standing_instructions_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_account_transfer_standing_ins_account_transfer_details_id_key" UNIQUE ("account_transfer_details_id"),
    CONSTRAINT "m_account_transfer_standing_instructions_name_key" UNIQUE ("name")
);

-- Table: m_account_transfer_standing_instructions_history
CREATE TABLE "fineract_barebones_db"."m_account_transfer_standing_instructions_history" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_account_transfer_standing_instructions_history_id_seq'::regclass),
    "standing_instruction_id" BIGINT NOT NULL,
    "status" VARCHAR(20) NOT NULL,
    "execution_time" TIMESTAMP NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "error_log" VARCHAR(500) DEFAULT NULL::character varying,
    CONSTRAINT "m_account_transfer_standing_instructions_history_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_account_transfer_standing_instruc_standing_instruction_id_key" UNIQUE ("standing_instruction_id")
);

-- Table: m_account_transfer_transaction
CREATE TABLE "fineract_barebones_db"."m_account_transfer_transaction" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_account_transfer_transaction_id_seq'::regclass),
    "account_transfer_details_id" BIGINT NOT NULL,
    "from_savings_transaction_id" BIGINT,
    "from_loan_transaction_id" BIGINT,
    "to_savings_transaction_id" BIGINT,
    "to_loan_transaction_id" BIGINT,
    "is_reversed" SMALLINT NOT NULL,
    "transaction_date" DATE NOT NULL,
    "currency_code" VARCHAR(3) NOT NULL,
    "currency_digits" SMALLINT NOT NULL,
    "currency_multiplesof" SMALLINT,
    "amount" NUMERIC(19,6) NOT NULL,
    "description" VARCHAR(200) NOT NULL,
    CONSTRAINT "m_account_transfer_transaction_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_account_transfer_transaction_account_transfer_details_id_key" UNIQUE ("account_transfer_details_id"),
    CONSTRAINT "m_account_transfer_transaction_from_loan_transaction_id_key" UNIQUE ("from_loan_transaction_id"),
    CONSTRAINT "m_account_transfer_transaction_from_savings_transaction_id_key" UNIQUE ("from_savings_transaction_id"),
    CONSTRAINT "m_account_transfer_transaction_to_loan_transaction_id_key" UNIQUE ("to_loan_transaction_id"),
    CONSTRAINT "m_account_transfer_transaction_to_savings_transaction_id_key" UNIQUE ("to_savings_transaction_id")
);

-- Table: m_address
CREATE TABLE "fineract_barebones_db"."m_address" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_address_id_seq'::regclass),
    "street" VARCHAR(100) DEFAULT NULL::character varying,
    "address_line_1" VARCHAR(100) DEFAULT NULL::character varying,
    "address_line_2" VARCHAR(100) DEFAULT NULL::character varying,
    "address_line_3" VARCHAR(100) DEFAULT NULL::character varying,
    "town_village" VARCHAR(100) DEFAULT NULL::character varying,
    "city" VARCHAR(100) DEFAULT NULL::character varying,
    "county_district" VARCHAR(100) DEFAULT NULL::character varying,
    "state_province_id" INTEGER,
    "country_id" INTEGER,
    "postal_code" VARCHAR(10) DEFAULT NULL::character varying,
    "latitude" NUMERIC(10,8) DEFAULT 0.00000000,
    "longitude" NUMERIC(10,8) DEFAULT 0.00000000,
    "created_by" VARCHAR(100) DEFAULT NULL::character varying,
    "created_on" DATE,
    "updated_by" VARCHAR(100) DEFAULT NULL::character varying,
    "updated_on" DATE,
    CONSTRAINT "m_address_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_address_country_id_key" UNIQUE ("country_id"),
    CONSTRAINT "m_address_state_province_id_key" UNIQUE ("state_province_id")
);

-- Table: m_appuser_previous_password
CREATE TABLE "fineract_barebones_db"."m_appuser_previous_password" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_appuser_previous_password_id_seq'::regclass),
    "user_id" BIGINT NOT NULL,
    "password" VARCHAR(255) NOT NULL,
    "removal_date" DATE NOT NULL,
    CONSTRAINT "m_appuser_previous_password_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_appuser_previous_password_user_id_key" UNIQUE ("user_id")
);

-- Table: m_appuser_role
CREATE TABLE "fineract_barebones_db"."m_appuser_role" (
    "appuser_id" BIGINT NOT NULL,
    "role_id" BIGINT NOT NULL,
    CONSTRAINT "m_appuser_role_pkey" PRIMARY KEY ("appuser_id", "role_id"),
    CONSTRAINT "m_appuser_role_appuser_id_key" UNIQUE ("appuser_id"),
    CONSTRAINT "m_appuser_role_role_id_key" UNIQUE ("role_id")
);

-- Table: m_calendar
CREATE TABLE "fineract_barebones_db"."m_calendar" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_calendar_id_seq'::regclass),
    "title" VARCHAR(70) NOT NULL,
    "description" VARCHAR(100) DEFAULT NULL::character varying,
    "location" VARCHAR(50) DEFAULT NULL::character varying,
    "start_date" DATE NOT NULL,
    "end_date" DATE,
    "duration" SMALLINT,
    "calendar_type_enum" SMALLINT NOT NULL,
    "repeating" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "recurrence" VARCHAR(100) DEFAULT NULL::character varying,
    "remind_by_enum" SMALLINT,
    "first_reminder" SMALLINT,
    "second_reminder" SMALLINT,
    "createdby_id" BIGINT,
    "lastmodifiedby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodified_date" TIMESTAMP,
    "meeting_time" TIME,
    CONSTRAINT "m_calendar_pkey" PRIMARY KEY ("id")
);

-- Table: m_calendar_history
CREATE TABLE "fineract_barebones_db"."m_calendar_history" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_calendar_history_id_seq'::regclass),
    "calendar_id" BIGINT NOT NULL,
    "title" VARCHAR(70) NOT NULL,
    "description" VARCHAR(100) DEFAULT NULL::character varying,
    "location" VARCHAR(50) DEFAULT NULL::character varying,
    "start_date" DATE NOT NULL,
    "end_date" DATE,
    "duration" SMALLINT,
    "calendar_type_enum" SMALLINT NOT NULL,
    "repeating" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "recurrence" VARCHAR(100) DEFAULT NULL::character varying,
    "remind_by_enum" SMALLINT,
    "first_reminder" SMALLINT,
    "second_reminder" SMALLINT,
    CONSTRAINT "m_calendar_history_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_calendar_history_calendar_id_key" UNIQUE ("calendar_id")
);

-- Table: m_calendar_instance
CREATE TABLE "fineract_barebones_db"."m_calendar_instance" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_calendar_instance_id_seq'::regclass),
    "calendar_id" BIGINT NOT NULL,
    "entity_id" BIGINT NOT NULL,
    "entity_type_enum" SMALLINT NOT NULL,
    CONSTRAINT "m_calendar_instance_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_calendar_instance_calendar_id_key" UNIQUE ("calendar_id")
);

-- Table: m_cashier_transactions
CREATE TABLE "fineract_barebones_db"."m_cashier_transactions" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_cashier_transactions_id_seq'::regclass),
    "cashier_id" BIGINT NOT NULL,
    "txn_type" SMALLINT NOT NULL,
    "txn_amount" NUMERIC(19,6) NOT NULL,
    "txn_date" DATE NOT NULL,
    "created_date" TIMESTAMP NOT NULL,
    "entity_type" VARCHAR(50) DEFAULT NULL::character varying,
    "entity_id" BIGINT,
    "txn_note" VARCHAR(200) DEFAULT NULL::character varying,
    "currency_code" VARCHAR(3) DEFAULT NULL::character varying,
    CONSTRAINT "m_cashier_transactions_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_cashier_transactions_cashier_id_key" UNIQUE ("cashier_id")
);

-- Table: m_cashiers
CREATE TABLE "fineract_barebones_db"."m_cashiers" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_cashiers_id_seq'::regclass),
    "staff_id" BIGINT,
    "teller_id" BIGINT,
    "description" VARCHAR(100) DEFAULT NULL::character varying,
    "start_date" DATE,
    "end_date" DATE,
    "start_time" VARCHAR(10) DEFAULT NULL::character varying,
    "end_time" VARCHAR(10) DEFAULT NULL::character varying,
    "full_day" SMALLINT,
    CONSTRAINT "m_cashiers_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_cashiers_staff_id_key" UNIQUE ("staff_id"),
    CONSTRAINT "m_cashiers_teller_id_key" UNIQUE ("teller_id")
);

-- Table: m_charge
CREATE TABLE "fineract_barebones_db"."m_charge" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_charge_id_seq'::regclass),
    "name" VARCHAR(100) DEFAULT NULL::character varying,
    "currency_code" VARCHAR(3) NOT NULL,
    "charge_applies_to_enum" SMALLINT NOT NULL,
    "charge_time_enum" SMALLINT NOT NULL,
    "charge_calculation_enum" SMALLINT NOT NULL,
    "charge_payment_mode_enum" SMALLINT,
    "amount" NUMERIC(19,6) NOT NULL,
    "fee_on_day" SMALLINT,
    "fee_interval" SMALLINT,
    "fee_on_month" SMALLINT,
    "is_penalty" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "is_active" SMALLINT NOT NULL,
    "is_deleted" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "min_cap" NUMERIC(19,6) DEFAULT NULL::numeric,
    "max_cap" NUMERIC(19,6) DEFAULT NULL::numeric,
    "fee_frequency" SMALLINT,
    "income_or_liability_account_id" BIGINT,
    "tax_group_id" BIGINT,
    CONSTRAINT "m_charge_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_charge_income_or_liability_account_id_key" UNIQUE ("income_or_liability_account_id"),
    CONSTRAINT "m_charge_name_key" UNIQUE ("name"),
    CONSTRAINT "m_charge_tax_group_id_key" UNIQUE ("tax_group_id")
);

-- Table: m_client
CREATE TABLE "fineract_barebones_db"."m_client" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_client_id_seq'::regclass),
    "account_no" VARCHAR(20) NOT NULL,
    "external_id" VARCHAR(100) DEFAULT NULL::character varying,
    "status_enum" INTEGER NOT NULL DEFAULT 300,
    "sub_status" INTEGER,
    "activation_date" DATE,
    "office_joining_date" DATE,
    "office_id" BIGINT NOT NULL,
    "transfer_to_office_id" BIGINT,
    "staff_id" BIGINT,
    "firstname" VARCHAR(50) DEFAULT NULL::character varying,
    "middlename" VARCHAR(50) DEFAULT NULL::character varying,
    "lastname" VARCHAR(50) DEFAULT NULL::character varying,
    "fullname" VARCHAR(100) DEFAULT NULL::character varying,
    "display_name" VARCHAR(100) NOT NULL,
    "mobile_no" VARCHAR(50) DEFAULT NULL::character varying,
    "gender_cv_id" INTEGER,
    "date_of_birth" DATE,
    "image_id" BIGINT,
    "closure_reason_cv_id" INTEGER,
    "closedon_date" DATE,
    "updated_by" BIGINT,
    "updated_on" DATE,
    "submittedon_date" DATE,
    "submittedon_userid" BIGINT,
    "activatedon_userid" BIGINT,
    "closedon_userid" BIGINT,
    "default_savings_product" BIGINT,
    "default_savings_account" BIGINT,
    "client_type_cv_id" INTEGER,
    "client_classification_cv_id" INTEGER,
    "reject_reason_cv_id" INTEGER,
    "rejectedon_date" DATE,
    "rejectedon_userid" BIGINT,
    "withdraw_reason_cv_id" INTEGER,
    "withdrawn_on_date" DATE,
    "withdraw_on_userid" BIGINT,
    "reactivated_on_date" DATE,
    "reactivated_on_userid" BIGINT,
    "legal_form_enum" INTEGER,
    "reopened_on_date" DATE,
    "reopened_by_userid" BIGINT,
    CONSTRAINT "m_client_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_client_account_no_key" UNIQUE ("account_no"),
    CONSTRAINT "m_client_client_classification_cv_id_key" UNIQUE ("client_classification_cv_id"),
    CONSTRAINT "m_client_client_type_cv_id_key" UNIQUE ("client_type_cv_id"),
    CONSTRAINT "m_client_closure_reason_cv_id_key" UNIQUE ("closure_reason_cv_id"),
    CONSTRAINT "m_client_default_savings_account_key" UNIQUE ("default_savings_account"),
    CONSTRAINT "m_client_default_savings_product_key" UNIQUE ("default_savings_product"),
    CONSTRAINT "m_client_external_id_key" UNIQUE ("external_id"),
    CONSTRAINT "m_client_gender_cv_id_key" UNIQUE ("gender_cv_id"),
    CONSTRAINT "m_client_image_id_key" UNIQUE ("image_id"),
    CONSTRAINT "m_client_mobile_no_key" UNIQUE ("mobile_no"),
    CONSTRAINT "m_client_office_id_key" UNIQUE ("office_id"),
    CONSTRAINT "m_client_reject_reason_cv_id_key" UNIQUE ("reject_reason_cv_id"),
    CONSTRAINT "m_client_staff_id_key" UNIQUE ("staff_id"),
    CONSTRAINT "m_client_sub_status_key" UNIQUE ("sub_status"),
    CONSTRAINT "m_client_transfer_to_office_id_key" UNIQUE ("transfer_to_office_id"),
    CONSTRAINT "m_client_withdraw_reason_cv_id_key" UNIQUE ("withdraw_reason_cv_id")
);

-- Table: m_client_address
CREATE TABLE "fineract_barebones_db"."m_client_address" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_client_address_id_seq'::regclass),
    "client_id" BIGINT NOT NULL DEFAULT '0'::bigint,
    "address_id" BIGINT NOT NULL DEFAULT '0'::bigint,
    "address_type_id" INTEGER NOT NULL DEFAULT 0,
    "is_active" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_client_address_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_client_address_address_id_key" UNIQUE ("address_id"),
    CONSTRAINT "m_client_address_address_type_id_key" UNIQUE ("address_type_id"),
    CONSTRAINT "m_client_address_client_id_key" UNIQUE ("client_id")
);

-- Table: m_client_attendance
CREATE TABLE "fineract_barebones_db"."m_client_attendance" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_client_attendance_id_seq'::regclass),
    "client_id" BIGINT NOT NULL DEFAULT '0'::bigint,
    "meeting_id" BIGINT NOT NULL,
    "attendance_type_enum" SMALLINT NOT NULL,
    CONSTRAINT "m_client_attendance_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_client_attendance_client_id_meeting_id_key" UNIQUE ("client_id", "meeting_id"),
    CONSTRAINT "m_client_attendance_meeting_id_key" UNIQUE ("meeting_id")
);

-- Table: m_client_charge
CREATE TABLE "fineract_barebones_db"."m_client_charge" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_client_charge_id_seq'::regclass),
    "client_id" BIGINT NOT NULL,
    "charge_id" BIGINT NOT NULL,
    "is_penalty" SMALLINT NOT NULL,
    "charge_time_enum" SMALLINT NOT NULL,
    "charge_due_date" DATE,
    "charge_calculation_enum" SMALLINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "amount_paid_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_waived_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_writtenoff_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_outstanding_derived" NUMERIC(19,6) NOT NULL,
    "is_paid_derived" SMALLINT,
    "waived" SMALLINT,
    "is_active" SMALLINT,
    "inactivated_on_date" DATE,
    CONSTRAINT "m_client_charge_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_client_charge_charge_id_key" UNIQUE ("charge_id"),
    CONSTRAINT "m_client_charge_client_id_key" UNIQUE ("client_id")
);

-- Table: m_client_charge_paid_by
CREATE TABLE "fineract_barebones_db"."m_client_charge_paid_by" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_client_charge_paid_by_id_seq'::regclass),
    "client_transaction_id" BIGINT NOT NULL,
    "client_charge_id" BIGINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    CONSTRAINT "m_client_charge_paid_by_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_client_charge_paid_by_client_charge_id_key" UNIQUE ("client_charge_id"),
    CONSTRAINT "m_client_charge_paid_by_client_transaction_id_key" UNIQUE ("client_transaction_id")
);

-- Table: m_client_identifier
CREATE TABLE "fineract_barebones_db"."m_client_identifier" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_client_identifier_id_seq'::regclass),
    "client_id" BIGINT NOT NULL,
    "document_type_id" INTEGER NOT NULL,
    "document_key" VARCHAR(50) NOT NULL,
    "status" INTEGER NOT NULL DEFAULT 300,
    "active" INTEGER,
    "description" VARCHAR(500) DEFAULT NULL::character varying,
    "createdby_id" BIGINT,
    "lastmodifiedby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodified_date" TIMESTAMP,
    CONSTRAINT "m_client_identifier_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_client_identifier_client_id_document_type_id_active_key" UNIQUE ("client_id", "document_type_id", "active"),
    CONSTRAINT "m_client_identifier_client_id_key" UNIQUE ("client_id"),
    CONSTRAINT "m_client_identifier_document_type_id_document_key_key" UNIQUE ("document_type_id", "document_key"),
    CONSTRAINT "m_client_identifier_document_type_id_key" UNIQUE ("document_type_id")
);

-- Table: m_client_non_person
CREATE TABLE "fineract_barebones_db"."m_client_non_person" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_client_non_person_id_seq'::regclass),
    "client_id" BIGINT NOT NULL,
    "constitution_cv_id" INTEGER NOT NULL,
    "incorp_no" VARCHAR(50) DEFAULT NULL::character varying,
    "incorp_validity_till" TIMESTAMP,
    "main_business_line_cv_id" INTEGER,
    "remarks" VARCHAR(150) DEFAULT NULL::character varying,
    CONSTRAINT "m_client_non_person_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_client_non_person_client_id_key" UNIQUE ("client_id")
);

-- Table: m_client_transaction
CREATE TABLE "fineract_barebones_db"."m_client_transaction" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_client_transaction_id_seq'::regclass),
    "client_id" BIGINT NOT NULL,
    "office_id" BIGINT NOT NULL,
    "currency_code" VARCHAR(3) NOT NULL,
    "payment_detail_id" BIGINT,
    "is_reversed" SMALLINT NOT NULL,
    "external_id" VARCHAR(50) DEFAULT NULL::character varying,
    "transaction_date" DATE NOT NULL,
    "transaction_type_enum" SMALLINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "created_date" TIMESTAMP NOT NULL,
    "appuser_id" BIGINT NOT NULL,
    CONSTRAINT "m_client_transaction_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_client_transaction_appuser_id_key" UNIQUE ("appuser_id"),
    CONSTRAINT "m_client_transaction_client_id_key" UNIQUE ("client_id"),
    CONSTRAINT "m_client_transaction_external_id_key" UNIQUE ("external_id")
);

-- Table: m_code
CREATE TABLE "fineract_barebones_db"."m_code" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.m_code_id_seq'::regclass),
    "code_name" VARCHAR(100) DEFAULT NULL::character varying,
    "is_system_defined" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_code_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_code_code_name_key" UNIQUE ("code_name")
);

-- Table: m_code_value
CREATE TABLE "fineract_barebones_db"."m_code_value" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.m_code_value_id_seq'::regclass),
    "code_id" INTEGER NOT NULL,
    "code_value" VARCHAR(100) DEFAULT NULL::character varying,
    "code_description" VARCHAR(500) DEFAULT NULL::character varying,
    "order_position" INTEGER NOT NULL DEFAULT 0,
    "code_score" INTEGER,
    "is_active" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "is_mandatory" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_code_value_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_code_value_code_id_code_value_key" UNIQUE ("code_id", "code_value"),
    CONSTRAINT "m_code_value_code_id_key" UNIQUE ("code_id")
);

-- Table: m_currency
CREATE TABLE "fineract_barebones_db"."m_currency" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_currency_id_seq'::regclass),
    "code" VARCHAR(3) NOT NULL,
    "decimal_places" SMALLINT NOT NULL,
    "currency_multiplesof" SMALLINT,
    "display_symbol" VARCHAR(10) DEFAULT NULL::character varying,
    "name" VARCHAR(50) NOT NULL,
    "internationalized_name_code" VARCHAR(50) NOT NULL,
    CONSTRAINT "m_currency_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_currency_code_key" UNIQUE ("code")
);

-- Table: m_deposit_account_on_hold_transaction
CREATE TABLE "fineract_barebones_db"."m_deposit_account_on_hold_transaction" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_deposit_account_on_hold_transaction_id_seq'::regclass),
    "savings_account_id" BIGINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "transaction_type_enum" SMALLINT NOT NULL,
    "transaction_date" DATE NOT NULL,
    "is_reversed" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "created_date" TIMESTAMP NOT NULL,
    CONSTRAINT "m_deposit_account_on_hold_transaction_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_deposit_account_on_hold_transaction_savings_account_id_key" UNIQUE ("savings_account_id")
);

-- Table: m_deposit_account_recurring_detail
CREATE TABLE "fineract_barebones_db"."m_deposit_account_recurring_detail" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_deposit_account_recurring_detail_id_seq'::regclass),
    "savings_account_id" BIGINT NOT NULL DEFAULT '0'::bigint,
    "mandatory_recommended_deposit_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "is_mandatory" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "allow_withdrawal" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "adjust_advance_towards_future_payments" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "is_calendar_inherited" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "total_overdue_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "no_of_overdue_installments" INTEGER,
    CONSTRAINT "m_deposit_account_recurring_detail_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_deposit_account_recurring_detail_savings_account_id_key" UNIQUE ("savings_account_id")
);

-- Table: m_deposit_account_term_and_preclosure
CREATE TABLE "fineract_barebones_db"."m_deposit_account_term_and_preclosure" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_deposit_account_term_and_preclosure_id_seq'::regclass),
    "savings_account_id" BIGINT NOT NULL DEFAULT '0'::bigint,
    "min_deposit_term" INTEGER,
    "max_deposit_term" INTEGER,
    "min_deposit_term_type_enum" SMALLINT,
    "max_deposit_term_type_enum" SMALLINT,
    "in_multiples_of_deposit_term" INTEGER,
    "in_multiples_of_deposit_term_type_enum" SMALLINT,
    "pre_closure_penal_applicable" SMALLINT,
    "pre_closure_penal_interest" NUMERIC(19,6) DEFAULT NULL::numeric,
    "pre_closure_penal_interest_on_enum" SMALLINT,
    "deposit_period" INTEGER,
    "deposit_period_frequency_enum" SMALLINT,
    "deposit_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "maturity_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "maturity_date" DATE,
    "on_account_closure_enum" SMALLINT,
    "expected_firstdepositon_date" DATE,
    "transfer_interest_to_linked_account" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_deposit_account_term_and_preclosure_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_deposit_account_term_and_preclosure_savings_account_id_key" UNIQUE ("savings_account_id")
);

-- Table: m_deposit_product_interest_rate_chart
CREATE TABLE "fineract_barebones_db"."m_deposit_product_interest_rate_chart" (
    "deposit_product_id" BIGINT NOT NULL,
    "interest_rate_chart_id" BIGINT NOT NULL,
    CONSTRAINT "m_deposit_product_interest_ra_deposit_product_id_interest_r_key" UNIQUE ("deposit_product_id", "interest_rate_chart_id"),
    CONSTRAINT "m_deposit_product_interest_rate_char_interest_rate_chart_id_key" UNIQUE ("interest_rate_chart_id")
);

-- Table: m_deposit_product_recurring_detail
CREATE TABLE "fineract_barebones_db"."m_deposit_product_recurring_detail" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_deposit_product_recurring_detail_id_seq'::regclass),
    "savings_product_id" BIGINT NOT NULL DEFAULT '0'::bigint,
    "is_mandatory" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "allow_withdrawal" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "adjust_advance_towards_future_payments" SMALLINT NOT NULL DEFAULT '1'::smallint,
    CONSTRAINT "m_deposit_product_recurring_detail_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_deposit_product_recurring_detail_savings_product_id_key" UNIQUE ("savings_product_id")
);

-- Table: m_deposit_product_term_and_preclosure
CREATE TABLE "fineract_barebones_db"."m_deposit_product_term_and_preclosure" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_deposit_product_term_and_preclosure_id_seq'::regclass),
    "savings_product_id" BIGINT NOT NULL DEFAULT '0'::bigint,
    "min_deposit_term" INTEGER,
    "max_deposit_term" INTEGER,
    "min_deposit_term_type_enum" SMALLINT,
    "max_deposit_term_type_enum" SMALLINT,
    "in_multiples_of_deposit_term" INTEGER,
    "in_multiples_of_deposit_term_type_enum" SMALLINT,
    "pre_closure_penal_applicable" SMALLINT,
    "pre_closure_penal_interest" NUMERIC(19,6) DEFAULT NULL::numeric,
    "pre_closure_penal_interest_on_enum" SMALLINT,
    "min_deposit_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "max_deposit_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "deposit_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    CONSTRAINT "m_deposit_product_term_and_preclosure_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_deposit_product_term_and_preclosure_savings_product_id_key" UNIQUE ("savings_product_id")
);

-- Table: m_document
CREATE TABLE "fineract_barebones_db"."m_document" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.m_document_id_seq'::regclass),
    "parent_entity_type" VARCHAR(50) NOT NULL,
    "parent_entity_id" INTEGER NOT NULL DEFAULT 0,
    "name" VARCHAR(250) NOT NULL,
    "file_name" VARCHAR(250) NOT NULL,
    "size" INTEGER DEFAULT 0,
    "type" VARCHAR(500) DEFAULT NULL::character varying,
    "description" VARCHAR(1000) DEFAULT NULL::character varying,
    "location" VARCHAR(500) NOT NULL DEFAULT '0'::character varying,
    "storage_type_enum" SMALLINT,
    CONSTRAINT "m_document_pkey" PRIMARY KEY ("id")
);

-- Table: m_entity_datatable_check
CREATE TABLE "fineract_barebones_db"."m_entity_datatable_check" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.m_entity_datatable_check_id_seq'::regclass),
    "application_table_name" VARCHAR(200) NOT NULL,
    "x_registered_table_name" VARCHAR(50) NOT NULL,
    "status_enum" INTEGER NOT NULL,
    "system_defined" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "product_id" BIGINT,
    CONSTRAINT "m_entity_datatable_check_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_entity_datatable_check_application_table_name_x_registere_key" UNIQUE ("application_table_name", "x_registered_table_name", "status_enum", "product_id"),
    CONSTRAINT "m_entity_datatable_check_product_id_key" UNIQUE ("product_id"),
    CONSTRAINT "m_entity_datatable_check_x_registered_table_name_key" UNIQUE ("x_registered_table_name")
);

-- Table: m_entity_relation
CREATE TABLE "fineract_barebones_db"."m_entity_relation" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_entity_relation_id_seq'::regclass),
    "from_entity_type" INTEGER NOT NULL,
    "to_entity_type" INTEGER NOT NULL,
    "code_name" VARCHAR(50) NOT NULL,
    CONSTRAINT "m_entity_relation_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_entity_relation_from_entity_type_to_entity_type_code_name_key" UNIQUE ("from_entity_type", "to_entity_type", "code_name")
);

-- Table: m_entity_to_entity_access
CREATE TABLE "fineract_barebones_db"."m_entity_to_entity_access" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_entity_to_entity_access_id_seq'::regclass),
    "entity_type" VARCHAR(50) NOT NULL,
    "entity_id" BIGINT NOT NULL,
    "access_type_code_value_id" INTEGER NOT NULL,
    "second_entity_type" VARCHAR(50) NOT NULL,
    "second_entity_id" BIGINT NOT NULL,
    CONSTRAINT "m_entity_to_entity_access_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_entity_to_entity_access_access_type_code_value_id_key" UNIQUE ("access_type_code_value_id"),
    CONSTRAINT "m_entity_to_entity_access_entity_type_entity_id_access_type_key" UNIQUE ("entity_type", "entity_id", "access_type_code_value_id", "second_entity_type", "second_entity_id"),
    CONSTRAINT "m_entity_to_entity_access_entity_type_entity_id_key" UNIQUE ("entity_type", "entity_id")
);

-- Table: m_entity_to_entity_mapping
CREATE TABLE "fineract_barebones_db"."m_entity_to_entity_mapping" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_entity_to_entity_mapping_id_seq'::regclass),
    "rel_id" BIGINT NOT NULL DEFAULT '0'::bigint,
    "from_id" BIGINT NOT NULL DEFAULT '0'::bigint,
    "to_id" BIGINT NOT NULL,
    "start_date" DATE,
    "end_date" DATE,
    CONSTRAINT "m_entity_to_entity_mapping_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_entity_to_entity_mapping_rel_id_from_id_to_id_key" UNIQUE ("rel_id", "from_id", "to_id")
);

-- Table: m_field_configuration
CREATE TABLE "fineract_barebones_db"."m_field_configuration" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_field_configuration_id_seq'::regclass),
    "entity" VARCHAR(100) NOT NULL,
    "subentity" VARCHAR(100) NOT NULL,
    "field" VARCHAR(100) NOT NULL,
    "is_enabled" SMALLINT NOT NULL,
    "is_mandatory" SMALLINT NOT NULL,
    "validation_regex" VARCHAR(50) DEFAULT NULL::character varying,
    CONSTRAINT "m_field_configuration_pkey" PRIMARY KEY ("id")
);

-- Table: m_fund
CREATE TABLE "fineract_barebones_db"."m_fund" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_fund_id_seq'::regclass),
    "name" VARCHAR(255) DEFAULT NULL::character varying,
    "external_id" VARCHAR(100) DEFAULT NULL::character varying,
    CONSTRAINT "m_fund_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_fund_external_id_key" UNIQUE ("external_id"),
    CONSTRAINT "m_fund_name_key" UNIQUE ("name")
);

-- Table: m_group
CREATE TABLE "fineract_barebones_db"."m_group" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_group_id_seq'::regclass),
    "external_id" VARCHAR(100) DEFAULT NULL::character varying,
    "status_enum" INTEGER NOT NULL DEFAULT 300,
    "activation_date" DATE,
    "office_id" BIGINT NOT NULL,
    "staff_id" BIGINT,
    "parent_id" BIGINT,
    "level_id" INTEGER NOT NULL,
    "display_name" VARCHAR(100) NOT NULL,
    "hierarchy" VARCHAR(100) DEFAULT NULL::character varying,
    "closure_reason_cv_id" INTEGER,
    "closedon_date" DATE,
    "activatedon_userid" BIGINT,
    "submittedon_date" DATE,
    "submittedon_userid" BIGINT,
    "closedon_userid" BIGINT,
    "account_no" VARCHAR(20) NOT NULL,
    CONSTRAINT "m_group_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_group_closure_reason_cv_id_key" UNIQUE ("closure_reason_cv_id"),
    CONSTRAINT "m_group_display_name_level_id_key" UNIQUE ("display_name", "level_id"),
    CONSTRAINT "m_group_external_id_key" UNIQUE ("external_id"),
    CONSTRAINT "m_group_external_id_level_id_key" UNIQUE ("external_id", "level_id"),
    CONSTRAINT "m_group_level_id_key" UNIQUE ("level_id"),
    CONSTRAINT "m_group_office_id_key" UNIQUE ("office_id"),
    CONSTRAINT "m_group_parent_id_key" UNIQUE ("parent_id"),
    CONSTRAINT "m_group_staff_id_key" UNIQUE ("staff_id")
);

-- Table: m_group_client
CREATE TABLE "fineract_barebones_db"."m_group_client" (
    "group_id" BIGINT NOT NULL,
    "client_id" BIGINT NOT NULL,
    CONSTRAINT "m_group_client_pkey" PRIMARY KEY ("group_id", "client_id"),
    CONSTRAINT "m_group_client_client_id_key" UNIQUE ("client_id")
);

-- Table: m_group_level
CREATE TABLE "fineract_barebones_db"."m_group_level" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.m_group_level_id_seq'::regclass),
    "parent_id" INTEGER,
    "super_parent" SMALLINT NOT NULL,
    "level_name" VARCHAR(100) NOT NULL,
    "recursable" SMALLINT NOT NULL,
    "can_have_clients" SMALLINT NOT NULL,
    CONSTRAINT "m_group_level_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_group_level_parent_id_key" UNIQUE ("parent_id")
);

-- Table: m_group_roles
CREATE TABLE "fineract_barebones_db"."m_group_roles" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_group_roles_id_seq'::regclass),
    "client_id" BIGINT,
    "group_id" BIGINT,
    "role_cv_id" INTEGER,
    CONSTRAINT "m_group_roles_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_group_roles_client_id_group_id_role_cv_id_key" UNIQUE ("client_id", "group_id", "role_cv_id"),
    CONSTRAINT "m_group_roles_client_id_key" UNIQUE ("client_id"),
    CONSTRAINT "m_group_roles_group_id_key" UNIQUE ("group_id"),
    CONSTRAINT "m_group_roles_role_cv_id_key" UNIQUE ("role_cv_id")
);

-- Table: m_guarantor
CREATE TABLE "fineract_barebones_db"."m_guarantor" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_guarantor_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "client_reln_cv_id" INTEGER,
    "type_enum" SMALLINT NOT NULL,
    "entity_id" BIGINT,
    "firstname" VARCHAR(50) DEFAULT NULL::character varying,
    "lastname" VARCHAR(50) DEFAULT NULL::character varying,
    "dob" DATE,
    "address_line_1" VARCHAR(500) DEFAULT NULL::character varying,
    "address_line_2" VARCHAR(500) DEFAULT NULL::character varying,
    "city" VARCHAR(50) DEFAULT NULL::character varying,
    "state" VARCHAR(50) DEFAULT NULL::character varying,
    "country" VARCHAR(50) DEFAULT NULL::character varying,
    "zip" VARCHAR(20) DEFAULT NULL::character varying,
    "house_phone_number" VARCHAR(20) DEFAULT NULL::character varying,
    "mobile_number" VARCHAR(20) DEFAULT NULL::character varying,
    "comment" VARCHAR(500) DEFAULT NULL::character varying,
    "is_active" SMALLINT NOT NULL DEFAULT '1'::smallint,
    CONSTRAINT "m_guarantor_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_guarantor_client_reln_cv_id_key" UNIQUE ("client_reln_cv_id"),
    CONSTRAINT "m_guarantor_loan_id_key" UNIQUE ("loan_id")
);

-- Table: m_guarantor_funding_details
CREATE TABLE "fineract_barebones_db"."m_guarantor_funding_details" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_guarantor_funding_details_id_seq'::regclass),
    "guarantor_id" BIGINT NOT NULL,
    "account_associations_id" BIGINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "amount_released_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_remaining_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_transfered_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "status_enum" SMALLINT NOT NULL,
    CONSTRAINT "m_guarantor_funding_details_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_guarantor_funding_details_account_associations_id_key" UNIQUE ("account_associations_id"),
    CONSTRAINT "m_guarantor_funding_details_guarantor_id_key" UNIQUE ("guarantor_id")
);

-- Table: m_guarantor_transaction
CREATE TABLE "fineract_barebones_db"."m_guarantor_transaction" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_guarantor_transaction_id_seq'::regclass),
    "guarantor_fund_detail_id" BIGINT NOT NULL,
    "loan_transaction_id" BIGINT,
    "deposit_on_hold_transaction_id" BIGINT NOT NULL,
    "is_reversed" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_guarantor_transaction_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_guarantor_transaction_deposit_on_hold_transaction_id_key" UNIQUE ("deposit_on_hold_transaction_id"),
    CONSTRAINT "m_guarantor_transaction_guarantor_fund_detail_id_key" UNIQUE ("guarantor_fund_detail_id"),
    CONSTRAINT "m_guarantor_transaction_loan_transaction_id_key" UNIQUE ("loan_transaction_id")
);

-- Table: m_holiday
CREATE TABLE "fineract_barebones_db"."m_holiday" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_holiday_id_seq'::regclass),
    "name" VARCHAR(100) NOT NULL,
    "from_date" TIMESTAMP NOT NULL,
    "to_date" TIMESTAMP NOT NULL,
    "repayments_rescheduled_to" TIMESTAMP NOT NULL,
    "status_enum" INTEGER NOT NULL DEFAULT 100,
    "processed" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "description" VARCHAR(100) DEFAULT NULL::character varying,
    CONSTRAINT "m_holiday_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_holiday_name_from_date_key" UNIQUE ("name", "from_date")
);

-- Table: m_holiday_office
CREATE TABLE "fineract_barebones_db"."m_holiday_office" (
    "holiday_id" BIGINT NOT NULL,
    "office_id" BIGINT NOT NULL,
    CONSTRAINT "m_holiday_office_pkey" PRIMARY KEY ("holiday_id", "office_id"),
    CONSTRAINT "m_holiday_office_holiday_id_key" UNIQUE ("holiday_id"),
    CONSTRAINT "m_holiday_office_office_id_key" UNIQUE ("office_id")
);

-- Table: m_hook
CREATE TABLE "fineract_barebones_db"."m_hook" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_hook_id_seq'::regclass),
    "template_id" SMALLINT NOT NULL,
    "is_active" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "name" VARCHAR(45) NOT NULL,
    "createdby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    "lastmodified_date" TIMESTAMP,
    "ugd_template_id" BIGINT,
    CONSTRAINT "m_hook_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_hook_template_id_key" UNIQUE ("template_id"),
    CONSTRAINT "m_hook_ugd_template_id_key" UNIQUE ("ugd_template_id")
);

-- Table: m_hook_configuration
CREATE TABLE "fineract_barebones_db"."m_hook_configuration" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_hook_configuration_id_seq'::regclass),
    "hook_id" BIGINT,
    "field_type" VARCHAR(45) NOT NULL,
    "field_name" VARCHAR(100) NOT NULL,
    "field_value" VARCHAR(100) NOT NULL,
    CONSTRAINT "m_hook_configuration_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_hook_configuration_hook_id_key" UNIQUE ("hook_id")
);

-- Table: m_hook_registered_events
CREATE TABLE "fineract_barebones_db"."m_hook_registered_events" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_hook_registered_events_id_seq'::regclass),
    "hook_id" BIGINT NOT NULL,
    "entity_name" VARCHAR(45) NOT NULL,
    "action_name" VARCHAR(45) NOT NULL,
    CONSTRAINT "m_hook_registered_events_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_hook_registered_events_hook_id_key" UNIQUE ("hook_id")
);

-- Table: m_hook_schema
CREATE TABLE "fineract_barebones_db"."m_hook_schema" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.m_hook_schema_id_seq'::regclass),
    "hook_template_id" SMALLINT NOT NULL,
    "field_type" VARCHAR(45) NOT NULL,
    "field_name" VARCHAR(100) NOT NULL,
    "placeholder" VARCHAR(100) DEFAULT NULL::character varying,
    "optional" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_hook_schema_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_hook_schema_hook_template_id_key" UNIQUE ("hook_template_id")
);

-- Table: m_hook_templates
CREATE TABLE "fineract_barebones_db"."m_hook_templates" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.m_hook_templates_id_seq'::regclass),
    "name" VARCHAR(45) NOT NULL,
    CONSTRAINT "m_hook_templates_pkey" PRIMARY KEY ("id")
);

-- Table: m_image
CREATE TABLE "fineract_barebones_db"."m_image" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_image_id_seq'::regclass),
    "location" VARCHAR(500) DEFAULT NULL::character varying,
    "storage_type_enum" SMALLINT,
    CONSTRAINT "m_image_pkey" PRIMARY KEY ("id")
);

-- Table: m_interest_incentives
CREATE TABLE "fineract_barebones_db"."m_interest_incentives" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_interest_incentives_id_seq'::regclass),
    "interest_rate_slab_id" BIGINT NOT NULL,
    "entiry_type" SMALLINT NOT NULL,
    "attribute_name" SMALLINT NOT NULL,
    "condition_type" SMALLINT NOT NULL,
    "attribute_value" VARCHAR(50) NOT NULL,
    "incentive_type" SMALLINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    CONSTRAINT "m_interest_incentives_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_interest_incentives_interest_rate_slab_id_key" UNIQUE ("interest_rate_slab_id")
);

-- Table: m_interest_rate_chart
CREATE TABLE "fineract_barebones_db"."m_interest_rate_chart" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_interest_rate_chart_id_seq'::regclass),
    "name" VARCHAR(100) DEFAULT NULL::character varying,
    "description" VARCHAR(200) DEFAULT NULL::character varying,
    "from_date" DATE NOT NULL,
    "end_date" DATE,
    "is_primary_grouping_by_amount" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_interest_rate_chart_pkey" PRIMARY KEY ("id")
);

-- Table: m_interest_rate_slab
CREATE TABLE "fineract_barebones_db"."m_interest_rate_slab" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_interest_rate_slab_id_seq'::regclass),
    "interest_rate_chart_id" BIGINT NOT NULL,
    "description" VARCHAR(200) DEFAULT NULL::character varying,
    "period_type_enum" SMALLINT,
    "from_period" INTEGER,
    "to_period" INTEGER,
    "amount_range_from" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_range_to" NUMERIC(19,6) DEFAULT NULL::numeric,
    "annual_interest_rate" NUMERIC(19,6) NOT NULL,
    "currency_code" VARCHAR(3) NOT NULL,
    CONSTRAINT "m_interest_rate_slab_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_interest_rate_slab_interest_rate_chart_id_key" UNIQUE ("interest_rate_chart_id")
);

-- Table: m_loan_arrears_aging
CREATE TABLE "fineract_barebones_db"."m_loan_arrears_aging" (
    "loan_id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_arrears_aging_loan_id_seq'::regclass),
    "principal_overdue_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "interest_overdue_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "fee_charges_overdue_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "penalty_charges_overdue_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "total_overdue_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "overdue_since_date_derived" DATE,
    CONSTRAINT "m_loan_arrears_aging_pkey" PRIMARY KEY ("loan_id")
);

-- Table: m_loan_charge
CREATE TABLE "fineract_barebones_db"."m_loan_charge" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_charge_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "charge_id" BIGINT NOT NULL,
    "is_penalty" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "charge_time_enum" SMALLINT NOT NULL,
    "due_for_collection_as_of_date" DATE,
    "charge_calculation_enum" SMALLINT NOT NULL,
    "charge_payment_mode_enum" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "calculation_percentage" NUMERIC(19,6) DEFAULT NULL::numeric,
    "calculation_on_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "charge_amount_or_percentage" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount" NUMERIC(19,6) NOT NULL,
    "amount_paid_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_waived_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_writtenoff_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_outstanding_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "is_paid_derived" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "waived" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "min_cap" NUMERIC(19,6) DEFAULT NULL::numeric,
    "max_cap" NUMERIC(19,6) DEFAULT NULL::numeric,
    "is_active" SMALLINT NOT NULL DEFAULT '1'::smallint,
    CONSTRAINT "m_loan_charge_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_charge_charge_id_key" UNIQUE ("charge_id"),
    CONSTRAINT "m_loan_charge_loan_id_key" UNIQUE ("loan_id")
);

-- Table: m_loan_charge_paid_by
CREATE TABLE "fineract_barebones_db"."m_loan_charge_paid_by" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_charge_paid_by_id_seq'::regclass),
    "loan_transaction_id" BIGINT NOT NULL,
    "loan_charge_id" BIGINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "installment_number" SMALLINT,
    CONSTRAINT "m_loan_charge_paid_by_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_charge_paid_by_loan_charge_id_key" UNIQUE ("loan_charge_id"),
    CONSTRAINT "m_loan_charge_paid_by_loan_transaction_id_key" UNIQUE ("loan_transaction_id")
);

-- Table: m_loan_collateral
CREATE TABLE "fineract_barebones_db"."m_loan_collateral" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_collateral_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "type_cv_id" INTEGER NOT NULL,
    "value" NUMERIC(19,6) DEFAULT NULL::numeric,
    "description" VARCHAR(500) DEFAULT NULL::character varying,
    CONSTRAINT "m_loan_collateral_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_collateral_loan_id_key" UNIQUE ("loan_id"),
    CONSTRAINT "m_loan_collateral_type_cv_id_key" UNIQUE ("type_cv_id")
);

-- Table: m_loan_disbursement_detail
CREATE TABLE "fineract_barebones_db"."m_loan_disbursement_detail" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_disbursement_detail_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "expected_disburse_date" TIMESTAMP NOT NULL,
    "disbursedon_date" TIMESTAMP,
    "principal" NUMERIC(19,6) NOT NULL,
    CONSTRAINT "m_loan_disbursement_detail_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_disbursement_detail_loan_id_key" UNIQUE ("loan_id")
);

-- Table: m_loan_installment_charge
CREATE TABLE "fineract_barebones_db"."m_loan_installment_charge" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_installment_charge_id_seq'::regclass),
    "loan_charge_id" BIGINT NOT NULL,
    "loan_schedule_id" BIGINT NOT NULL,
    "due_date" DATE,
    "amount" NUMERIC(19,6) NOT NULL,
    "amount_paid_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_waived_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_writtenoff_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_outstanding_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "is_paid_derived" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "waived" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "amount_through_charge_payment" NUMERIC(19,6) DEFAULT NULL::numeric,
    CONSTRAINT "m_loan_installment_charge_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_installment_charge_loan_charge_id_key" UNIQUE ("loan_charge_id"),
    CONSTRAINT "m_loan_installment_charge_loan_schedule_id_key" UNIQUE ("loan_schedule_id")
);

-- Table: m_loan_interest_recalculation_additional_details
CREATE TABLE "fineract_barebones_db"."m_loan_interest_recalculation_additional_details" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_interest_recalculation_additional_details_id_seq'::regclass),
    "loan_repayment_schedule_id" BIGINT NOT NULL,
    "effective_date" DATE NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    CONSTRAINT "m_loan_interest_recalculation_additional_details_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_interest_recalculation_ad_loan_repayment_schedule_id_key" UNIQUE ("loan_repayment_schedule_id")
);

-- Table: m_loan_officer_assignment_history
CREATE TABLE "fineract_barebones_db"."m_loan_officer_assignment_history" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_officer_assignment_history_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "loan_officer_id" BIGINT,
    "start_date" DATE NOT NULL,
    "end_date" DATE,
    "createdby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodified_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    CONSTRAINT "m_loan_officer_assignment_history_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_officer_assignment_history_loan_id_key" UNIQUE ("loan_id"),
    CONSTRAINT "m_loan_officer_assignment_history_loan_officer_id_key" UNIQUE ("loan_officer_id")
);

-- Table: m_loan_overdue_installment_charge
CREATE TABLE "fineract_barebones_db"."m_loan_overdue_installment_charge" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_overdue_installment_charge_id_seq'::regclass),
    "loan_charge_id" BIGINT NOT NULL,
    "loan_schedule_id" BIGINT NOT NULL,
    "frequency_number" INTEGER NOT NULL,
    CONSTRAINT "m_loan_overdue_installment_charge_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_overdue_installment_charge_loan_charge_id_key" UNIQUE ("loan_charge_id"),
    CONSTRAINT "m_loan_overdue_installment_charge_loan_schedule_id_key" UNIQUE ("loan_schedule_id")
);

-- Table: m_loan_paid_in_advance
CREATE TABLE "fineract_barebones_db"."m_loan_paid_in_advance" (
    "loan_id" BIGINT NOT NULL,
    "principal_in_advance_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "interest_in_advance_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "fee_charges_in_advance_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "penalty_charges_in_advance_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "total_in_advance_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    CONSTRAINT "m_loan_paid_in_advance_pkey" PRIMARY KEY ("loan_id")
);

-- Table: m_loan_recalculation_details
CREATE TABLE "fineract_barebones_db"."m_loan_recalculation_details" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_recalculation_details_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "compound_type_enum" SMALLINT NOT NULL,
    "reschedule_strategy_enum" SMALLINT NOT NULL,
    "rest_frequency_type_enum" SMALLINT NOT NULL,
    "rest_frequency_interval" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "compounding_frequency_type_enum" SMALLINT,
    "compounding_frequency_interval" SMALLINT,
    "rest_frequency_nth_day_enum" INTEGER,
    "rest_frequency_on_day" INTEGER,
    "rest_frequency_weekday_enum" INTEGER,
    "compounding_frequency_nth_day_enum" INTEGER,
    "compounding_frequency_on_day" INTEGER,
    "is_compounding_to_be_posted_as_transaction" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "compounding_frequency_weekday_enum" INTEGER,
    "allow_compounding_on_eod" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_loan_recalculation_details_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_recalculation_details_loan_id_key" UNIQUE ("loan_id")
);

-- Table: m_loan_repayment_schedule
CREATE TABLE "fineract_barebones_db"."m_loan_repayment_schedule" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_repayment_schedule_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "fromdate" DATE,
    "duedate" DATE NOT NULL,
    "installment" SMALLINT NOT NULL,
    "principal_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "principal_completed_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "principal_writtenoff_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "interest_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "interest_completed_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "interest_writtenoff_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "interest_waived_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "accrual_interest_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "fee_charges_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "fee_charges_completed_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "fee_charges_writtenoff_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "fee_charges_waived_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "accrual_fee_charges_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "penalty_charges_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "penalty_charges_completed_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "penalty_charges_writtenoff_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "penalty_charges_waived_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "accrual_penalty_charges_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_paid_in_advance_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_paid_late_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "completed_derived" BOOLEAN NOT NULL,
    "obligations_met_on_date" DATE,
    "createdby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodified_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    "recalculated_interest_component" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_loan_repayment_schedule_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_repayment_schedule_loan_id_key" UNIQUE ("loan_id")
);

-- Table: m_loan_repayment_schedule_history
CREATE TABLE "fineract_barebones_db"."m_loan_repayment_schedule_history" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_repayment_schedule_history_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "loan_reschedule_request_id" BIGINT,
    "fromdate" DATE,
    "duedate" DATE NOT NULL,
    "installment" SMALLINT NOT NULL,
    "principal_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "interest_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "fee_charges_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "penalty_charges_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "createdby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodified_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    "version" INTEGER NOT NULL,
    CONSTRAINT "m_loan_repayment_schedule_history_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_repayment_schedule_histor_loan_reschedule_request_id_key" UNIQUE ("loan_reschedule_request_id"),
    CONSTRAINT "m_loan_repayment_schedule_history_loan_id_key" UNIQUE ("loan_id")
);

-- Table: m_loan_reschedule_request
CREATE TABLE "fineract_barebones_db"."m_loan_reschedule_request" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_reschedule_request_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "status_enum" SMALLINT NOT NULL,
    "reschedule_from_installment" SMALLINT NOT NULL,
    "reschedule_from_date" DATE NOT NULL,
    "recalculate_interest" SMALLINT,
    "interest" TEXT,
    "reschedule_reason_cv_id" INTEGER,
    "reschedule_reason_comment" VARCHAR(500) DEFAULT NULL::character varying,
    "submitted_on_date" DATE NOT NULL,
    "submitted_by_user_id" BIGINT NOT NULL,
    "approved_on_date" DATE,
    "approved_by_user_id" BIGINT,
    "rejected_on_date" DATE,
    "rejected_by_user_id" BIGINT,
    CONSTRAINT "m_loan_reschedule_request_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_reschedule_request_approved_by_user_id_key" UNIQUE ("approved_by_user_id"),
    CONSTRAINT "m_loan_reschedule_request_loan_id_key" UNIQUE ("loan_id"),
    CONSTRAINT "m_loan_reschedule_request_rejected_by_user_id_key" UNIQUE ("rejected_by_user_id"),
    CONSTRAINT "m_loan_reschedule_request_reschedule_reason_cv_id_key" UNIQUE ("reschedule_reason_cv_id"),
    CONSTRAINT "m_loan_reschedule_request_submitted_by_user_id_key" UNIQUE ("submitted_by_user_id")
);

-- Table: m_loan_reschedule_request_term_variations_mapping
CREATE TABLE "fineract_barebones_db"."m_loan_reschedule_request_term_variations_mapping" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_reschedule_request_term_variations_mapping_id_seq'::regclass),
    "loan_reschedule_request_id" BIGINT NOT NULL,
    "loan_term_variations_id" BIGINT NOT NULL,
    CONSTRAINT "m_loan_reschedule_request_term_variations_mapping_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_reschedule_request_term_v_loan_reschedule_request_id_key" UNIQUE ("loan_reschedule_request_id"),
    CONSTRAINT "m_loan_reschedule_request_term_vari_loan_term_variations_id_key" UNIQUE ("loan_term_variations_id")
);

-- Table: m_loan_term_variations
CREATE TABLE "fineract_barebones_db"."m_loan_term_variations" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_term_variations_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "term_type" SMALLINT NOT NULL,
    "applicable_date" DATE NOT NULL,
    "decimal_value" NUMERIC(19,6) DEFAULT NULL::numeric,
    "date_value" DATE,
    "is_specific_to_installment" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "applied_on_loan_status" SMALLINT NOT NULL,
    "is_active" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "parent_id" BIGINT,
    CONSTRAINT "m_loan_term_variations_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_term_variations_loan_id_key" UNIQUE ("loan_id")
);

-- Table: m_loan_topup
CREATE TABLE "fineract_barebones_db"."m_loan_topup" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_topup_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "closure_loan_id" BIGINT NOT NULL,
    "account_transfer_details_id" BIGINT,
    "topup_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    CONSTRAINT "m_loan_topup_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_topup_account_transfer_details_id_key" UNIQUE ("account_transfer_details_id"),
    CONSTRAINT "m_loan_topup_closure_loan_id_key" UNIQUE ("closure_loan_id"),
    CONSTRAINT "m_loan_topup_loan_id_key" UNIQUE ("loan_id")
);

-- Table: m_loan_tranche_charges
CREATE TABLE "fineract_barebones_db"."m_loan_tranche_charges" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_tranche_charges_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "charge_id" BIGINT NOT NULL,
    CONSTRAINT "m_loan_tranche_charges_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_tranche_charges_charge_id_key" UNIQUE ("charge_id"),
    CONSTRAINT "m_loan_tranche_charges_loan_id_key" UNIQUE ("loan_id")
);

-- Table: m_loan_tranche_disbursement_charge
CREATE TABLE "fineract_barebones_db"."m_loan_tranche_disbursement_charge" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_tranche_disbursement_charge_id_seq'::regclass),
    "loan_charge_id" BIGINT NOT NULL,
    "disbursement_detail_id" BIGINT,
    CONSTRAINT "m_loan_tranche_disbursement_charge_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_tranche_disbursement_charge_disbursement_detail_id_key" UNIQUE ("disbursement_detail_id"),
    CONSTRAINT "m_loan_tranche_disbursement_charge_loan_charge_id_key" UNIQUE ("loan_charge_id")
);

-- Table: m_loan_transaction
CREATE TABLE "fineract_barebones_db"."m_loan_transaction" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_transaction_id_seq'::regclass),
    "loan_id" BIGINT NOT NULL,
    "office_id" BIGINT NOT NULL,
    "payment_detail_id" BIGINT,
    "is_reversed" SMALLINT NOT NULL,
    "external_id" VARCHAR(100) DEFAULT NULL::character varying,
    "transaction_type_enum" SMALLINT NOT NULL,
    "transaction_date" DATE NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "principal_portion_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "interest_portion_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "fee_charges_portion_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "penalty_charges_portion_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "overpayment_portion_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "unrecognized_income_portion" NUMERIC(19,6) DEFAULT NULL::numeric,
    "outstanding_loan_balance_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "submitted_on_date" DATE NOT NULL,
    "manually_adjusted_or_reversed" SMALLINT DEFAULT '0'::smallint,
    "created_date" TIMESTAMP,
    "appuser_id" BIGINT,
    CONSTRAINT "m_loan_transaction_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_transaction_external_id_key" UNIQUE ("external_id"),
    CONSTRAINT "m_loan_transaction_loan_id_key" UNIQUE ("loan_id"),
    CONSTRAINT "m_loan_transaction_office_id_key" UNIQUE ("office_id"),
    CONSTRAINT "m_loan_transaction_payment_detail_id_key" UNIQUE ("payment_detail_id")
);

-- Table: m_loan_transaction_repayment_schedule_mapping
CREATE TABLE "fineract_barebones_db"."m_loan_transaction_repayment_schedule_mapping" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loan_transaction_repayment_schedule_mapping_id_seq'::regclass),
    "loan_transaction_id" BIGINT NOT NULL,
    "loan_repayment_schedule_id" BIGINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "principal_portion_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "interest_portion_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "fee_charges_portion_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "penalty_charges_portion_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    CONSTRAINT "m_loan_transaction_repayment_schedule_mapping_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loan_transaction_repayment_sch_loan_repayment_schedule_id_key" UNIQUE ("loan_repayment_schedule_id"),
    CONSTRAINT "m_loan_transaction_repayment_schedule_m_loan_transaction_id_key" UNIQUE ("loan_transaction_id")
);

-- Table: m_loanproduct_provisioning_entry
CREATE TABLE "fineract_barebones_db"."m_loanproduct_provisioning_entry" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loanproduct_provisioning_entry_id_seq'::regclass),
    "history_id" BIGINT NOT NULL,
    "criteria_id" BIGINT NOT NULL,
    "currency_code" VARCHAR(3) NOT NULL,
    "office_id" BIGINT NOT NULL,
    "product_id" BIGINT NOT NULL,
    "category_id" BIGINT NOT NULL,
    "overdue_in_days" BIGINT DEFAULT '0'::bigint,
    "reseve_amount" NUMERIC(20,6) DEFAULT 0.000000,
    "liability_account" BIGINT,
    "expense_account" BIGINT,
    CONSTRAINT "m_loanproduct_provisioning_entry_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loanproduct_provisioning_entry_category_id_key" UNIQUE ("category_id"),
    CONSTRAINT "m_loanproduct_provisioning_entry_criteria_id_key" UNIQUE ("criteria_id"),
    CONSTRAINT "m_loanproduct_provisioning_entry_currency_code_key" UNIQUE ("currency_code"),
    CONSTRAINT "m_loanproduct_provisioning_entry_expense_account_key" UNIQUE ("expense_account"),
    CONSTRAINT "m_loanproduct_provisioning_entry_history_id_key" UNIQUE ("history_id"),
    CONSTRAINT "m_loanproduct_provisioning_entry_liability_account_key" UNIQUE ("liability_account"),
    CONSTRAINT "m_loanproduct_provisioning_entry_office_id_key" UNIQUE ("office_id"),
    CONSTRAINT "m_loanproduct_provisioning_entry_product_id_key" UNIQUE ("product_id")
);

-- Table: m_loanproduct_provisioning_mapping
CREATE TABLE "fineract_barebones_db"."m_loanproduct_provisioning_mapping" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_loanproduct_provisioning_mapping_id_seq'::regclass),
    "product_id" BIGINT NOT NULL,
    "criteria_id" BIGINT NOT NULL,
    CONSTRAINT "m_loanproduct_provisioning_mapping_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_loanproduct_provisioning_mapping_criteria_id_key" UNIQUE ("criteria_id"),
    CONSTRAINT "m_loanproduct_provisioning_mapping_product_id_key" UNIQUE ("product_id")
);

-- Table: m_mandatory_savings_schedule
CREATE TABLE "fineract_barebones_db"."m_mandatory_savings_schedule" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_mandatory_savings_schedule_id_seq'::regclass),
    "savings_account_id" BIGINT NOT NULL,
    "fromdate" DATE,
    "duedate" DATE NOT NULL,
    "installment" SMALLINT NOT NULL,
    "deposit_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "deposit_amount_completed_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_paid_in_advance_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_paid_late_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "completed_derived" BOOLEAN NOT NULL,
    "obligations_met_on_date" DATE,
    "createdby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodified_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    CONSTRAINT "m_mandatory_savings_schedule_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_mandatory_savings_schedule_savings_account_id_key" UNIQUE ("savings_account_id")
);

-- Table: m_meeting
CREATE TABLE "fineract_barebones_db"."m_meeting" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_meeting_id_seq'::regclass),
    "calendar_instance_id" BIGINT NOT NULL,
    "meeting_date" DATE NOT NULL,
    CONSTRAINT "m_meeting_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_meeting_calendar_instance_id_meeting_date_key" UNIQUE ("calendar_instance_id", "meeting_date")
);

-- Table: m_note
CREATE TABLE "fineract_barebones_db"."m_note" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_note_id_seq'::regclass),
    "client_id" BIGINT,
    "group_id" BIGINT,
    "loan_id" BIGINT,
    "loan_transaction_id" BIGINT,
    "savings_account_id" BIGINT,
    "savings_account_transaction_id" BIGINT,
    "share_account_id" BIGINT,
    "note_type_enum" SMALLINT NOT NULL,
    "note" VARCHAR(1000) DEFAULT NULL::character varying,
    "created_date" TIMESTAMP,
    "createdby_id" BIGINT,
    "lastmodified_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    CONSTRAINT "m_note_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_note_client_id_key" UNIQUE ("client_id"),
    CONSTRAINT "m_note_createdby_id_key" UNIQUE ("createdby_id"),
    CONSTRAINT "m_note_group_id_key" UNIQUE ("group_id"),
    CONSTRAINT "m_note_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id"),
    CONSTRAINT "m_note_loan_id_key" UNIQUE ("loan_id"),
    CONSTRAINT "m_note_loan_transaction_id_key" UNIQUE ("loan_transaction_id"),
    CONSTRAINT "m_note_savings_account_id_key" UNIQUE ("savings_account_id")
);

-- Table: m_office
CREATE TABLE "fineract_barebones_db"."m_office" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_office_id_seq'::regclass),
    "parent_id" BIGINT,
    "hierarchy" VARCHAR(100) DEFAULT NULL::character varying,
    "external_id" VARCHAR(100) DEFAULT NULL::character varying,
    "name" VARCHAR(50) NOT NULL,
    "opening_date" DATE NOT NULL,
    CONSTRAINT "m_office_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_office_external_id_key" UNIQUE ("external_id"),
    CONSTRAINT "m_office_name_key" UNIQUE ("name"),
    CONSTRAINT "m_office_parent_id_key" UNIQUE ("parent_id")
);

-- Table: m_office_transaction
CREATE TABLE "fineract_barebones_db"."m_office_transaction" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_office_transaction_id_seq'::regclass),
    "from_office_id" BIGINT,
    "to_office_id" BIGINT,
    "currency_code" VARCHAR(3) NOT NULL,
    "currency_digits" INTEGER NOT NULL,
    "transaction_amount" NUMERIC(19,6) NOT NULL,
    "transaction_date" DATE NOT NULL,
    "description" VARCHAR(100) DEFAULT NULL::character varying,
    CONSTRAINT "m_office_transaction_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_office_transaction_from_office_id_key" UNIQUE ("from_office_id"),
    CONSTRAINT "m_office_transaction_to_office_id_key" UNIQUE ("to_office_id")
);

-- Table: m_organisation_currency
CREATE TABLE "fineract_barebones_db"."m_organisation_currency" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_organisation_currency_id_seq'::regclass),
    "code" VARCHAR(3) NOT NULL,
    "decimal_places" SMALLINT NOT NULL,
    "currency_multiplesof" SMALLINT,
    "name" VARCHAR(50) NOT NULL,
    "display_symbol" VARCHAR(10) DEFAULT NULL::character varying,
    "internationalized_name_code" VARCHAR(50) NOT NULL,
    CONSTRAINT "m_organisation_currency_pkey" PRIMARY KEY ("id")
);

-- Table: m_password_validation_policy
CREATE TABLE "fineract_barebones_db"."m_password_validation_policy" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.m_password_validation_policy_id_seq'::regclass),
    "regex" TEXT NOT NULL,
    "description" TEXT NOT NULL,
    "active" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "key" VARCHAR(255) NOT NULL,
    CONSTRAINT "m_password_validation_policy_pkey" PRIMARY KEY ("id")
);

-- Table: m_payment_detail
CREATE TABLE "fineract_barebones_db"."m_payment_detail" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_payment_detail_id_seq'::regclass),
    "payment_type_id" INTEGER,
    "account_number" VARCHAR(100) DEFAULT NULL::character varying,
    "check_number" VARCHAR(100) DEFAULT NULL::character varying,
    "receipt_number" VARCHAR(100) DEFAULT NULL::character varying,
    "bank_number" VARCHAR(100) DEFAULT NULL::character varying,
    "routing_code" VARCHAR(100) DEFAULT NULL::character varying,
    CONSTRAINT "m_payment_detail_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_payment_detail_payment_type_id_key" UNIQUE ("payment_type_id")
);

-- Table: m_payment_type
CREATE TABLE "fineract_barebones_db"."m_payment_type" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.m_payment_type_id_seq'::regclass),
    "value" VARCHAR(100) DEFAULT NULL::character varying,
    "description" VARCHAR(500) DEFAULT NULL::character varying,
    "is_cash_payment" SMALLINT DEFAULT '0'::smallint,
    "order_position" INTEGER NOT NULL DEFAULT 0,
    CONSTRAINT "m_payment_type_pkey" PRIMARY KEY ("id")
);

-- Table: m_permission
CREATE TABLE "fineract_barebones_db"."m_permission" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_permission_id_seq'::regclass),
    "grouping" VARCHAR(45) DEFAULT NULL::character varying,
    "code" VARCHAR(100) NOT NULL,
    "entity_name" VARCHAR(100) DEFAULT NULL::character varying,
    "action_name" VARCHAR(100) DEFAULT NULL::character varying,
    "can_maker_checker" SMALLINT NOT NULL DEFAULT '1'::smallint,
    CONSTRAINT "m_permission_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_permission_code_key" UNIQUE ("code")
);

-- Table: m_portfolio_account_associations
CREATE TABLE "fineract_barebones_db"."m_portfolio_account_associations" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_portfolio_account_associations_id_seq'::regclass),
    "loan_account_id" BIGINT,
    "savings_account_id" BIGINT,
    "linked_loan_account_id" BIGINT,
    "linked_savings_account_id" BIGINT,
    "association_type_enum" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "is_active" SMALLINT NOT NULL DEFAULT '1'::smallint,
    CONSTRAINT "m_portfolio_account_associations_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_portfolio_account_associations_linked_loan_account_id_key" UNIQUE ("linked_loan_account_id"),
    CONSTRAINT "m_portfolio_account_associations_linked_savings_account_id_key" UNIQUE ("linked_savings_account_id"),
    CONSTRAINT "m_portfolio_account_associations_loan_account_id_key" UNIQUE ("loan_account_id"),
    CONSTRAINT "m_portfolio_account_associations_savings_account_id_key" UNIQUE ("savings_account_id")
);

-- Table: m_portfolio_command_source
CREATE TABLE "fineract_barebones_db"."m_portfolio_command_source" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_portfolio_command_source_id_seq'::regclass),
    "action_name" VARCHAR(50) NOT NULL,
    "entity_name" VARCHAR(50) NOT NULL,
    "office_id" BIGINT,
    "group_id" BIGINT,
    "client_id" BIGINT,
    "loan_id" BIGINT,
    "savings_account_id" BIGINT,
    "api_get_url" VARCHAR(100) NOT NULL,
    "resource_id" BIGINT,
    "subresource_id" BIGINT,
    "command_as_json" TEXT NOT NULL,
    "maker_id" BIGINT NOT NULL,
    "made_on_date" TIMESTAMP NOT NULL,
    "checker_id" BIGINT,
    "checked_on_date" TIMESTAMP,
    "status" SMALLINT NOT NULL,
    "product_id" BIGINT,
    "transaction_id" VARCHAR(100) DEFAULT NULL::character varying,
    CONSTRAINT "m_portfolio_command_source_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_portfolio_command_source_action_name_key" UNIQUE ("action_name"),
    CONSTRAINT "m_portfolio_command_source_checked_on_date_key" UNIQUE ("checked_on_date"),
    CONSTRAINT "m_portfolio_command_source_checker_id_key" UNIQUE ("checker_id"),
    CONSTRAINT "m_portfolio_command_source_entity_name_resource_id_key" UNIQUE ("entity_name", "resource_id"),
    CONSTRAINT "m_portfolio_command_source_made_on_date_key" UNIQUE ("made_on_date"),
    CONSTRAINT "m_portfolio_command_source_maker_id_key" UNIQUE ("maker_id"),
    CONSTRAINT "m_portfolio_command_source_office_id_key" UNIQUE ("office_id"),
    CONSTRAINT "m_portfolio_command_source_status_key" UNIQUE ("status")
);

-- Table: m_product_loan_charge
CREATE TABLE "fineract_barebones_db"."m_product_loan_charge" (
    "product_loan_id" BIGINT NOT NULL,
    "charge_id" BIGINT NOT NULL,
    CONSTRAINT "m_product_loan_charge_pkey" PRIMARY KEY ("product_loan_id", "charge_id"),
    CONSTRAINT "m_product_loan_charge_charge_id_key" UNIQUE ("charge_id")
);

-- Table: m_product_loan_configurable_attributes
CREATE TABLE "fineract_barebones_db"."m_product_loan_configurable_attributes" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_product_loan_configurable_attributes_id_seq'::regclass),
    "loan_product_id" BIGINT NOT NULL,
    "amortization_method_enum" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "interest_method_enum" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "loan_transaction_strategy_id" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "interest_calculated_in_period_enum" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "arrearstolerance_amount" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "repay_every" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "moratorium" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "grace_on_arrears_ageing" SMALLINT NOT NULL DEFAULT '1'::smallint,
    CONSTRAINT "m_product_loan_configurable_attributes_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_product_loan_configurable_attributes_loan_product_id_key" UNIQUE ("loan_product_id")
);

-- Table: m_product_loan_guarantee_details
CREATE TABLE "fineract_barebones_db"."m_product_loan_guarantee_details" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_product_loan_guarantee_details_id_seq'::regclass),
    "loan_product_id" BIGINT NOT NULL,
    "mandatory_guarantee" NUMERIC(19,5) NOT NULL,
    "minimum_guarantee_from_own_funds" NUMERIC(19,5) DEFAULT NULL::numeric,
    "minimum_guarantee_from_guarantor_funds" NUMERIC(19,5) DEFAULT NULL::numeric,
    CONSTRAINT "m_product_loan_guarantee_details_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_product_loan_guarantee_details_loan_product_id_key" UNIQUE ("loan_product_id")
);

-- Table: m_product_loan_recalculation_details
CREATE TABLE "fineract_barebones_db"."m_product_loan_recalculation_details" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_product_loan_recalculation_details_id_seq'::regclass),
    "product_id" BIGINT NOT NULL,
    "compound_type_enum" SMALLINT NOT NULL,
    "reschedule_strategy_enum" SMALLINT NOT NULL,
    "rest_frequency_type_enum" SMALLINT NOT NULL,
    "rest_frequency_interval" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "arrears_based_on_original_schedule" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "pre_close_interest_calculation_strategy" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "compounding_frequency_type_enum" SMALLINT,
    "compounding_frequency_interval" SMALLINT,
    "rest_frequency_nth_day_enum" INTEGER,
    "rest_frequency_on_day" INTEGER,
    "rest_frequency_weekday_enum" INTEGER,
    "compounding_frequency_nth_day_enum" INTEGER,
    "compounding_frequency_on_day" INTEGER,
    "compounding_frequency_weekday_enum" INTEGER,
    "is_compounding_to_be_posted_as_transaction" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "allow_compounding_on_eod" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_product_loan_recalculation_details_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_product_loan_recalculation_details_product_id_key" UNIQUE ("product_id")
);

-- Table: m_product_loan_variable_installment_config
CREATE TABLE "fineract_barebones_db"."m_product_loan_variable_installment_config" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_product_loan_variable_installment_config_id_seq'::regclass),
    "loan_product_id" BIGINT NOT NULL,
    "minimum_gap" INTEGER NOT NULL,
    "maximum_gap" INTEGER NOT NULL,
    CONSTRAINT "m_product_loan_variable_installment_config_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_product_loan_variable_installment_config_loan_product_id_key" UNIQUE ("loan_product_id")
);

-- Table: m_product_loan_variations_borrower_cycle
CREATE TABLE "fineract_barebones_db"."m_product_loan_variations_borrower_cycle" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_product_loan_variations_borrower_cycle_id_seq'::regclass),
    "loan_product_id" BIGINT NOT NULL DEFAULT '0'::bigint,
    "borrower_cycle_number" INTEGER NOT NULL DEFAULT 0,
    "value_condition" INTEGER NOT NULL DEFAULT 0,
    "param_type" INTEGER NOT NULL DEFAULT 0,
    "default_value" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "max_value" NUMERIC(19,6) DEFAULT NULL::numeric,
    "min_value" NUMERIC(19,6) DEFAULT NULL::numeric,
    CONSTRAINT "m_product_loan_variations_borrower_cycle_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_product_loan_variations_borrower_cycle_loan_product_id_key" UNIQUE ("loan_product_id")
);

-- Table: m_product_mix
CREATE TABLE "fineract_barebones_db"."m_product_mix" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_product_mix_id_seq'::regclass),
    "product_id" BIGINT NOT NULL,
    "restricted_product_id" BIGINT NOT NULL,
    CONSTRAINT "m_product_mix_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_product_mix_product_id_key" UNIQUE ("product_id"),
    CONSTRAINT "m_product_mix_restricted_product_id_key" UNIQUE ("restricted_product_id")
);

-- Table: m_provision_category
CREATE TABLE "fineract_barebones_db"."m_provision_category" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_provision_category_id_seq'::regclass),
    "category_name" VARCHAR(100) NOT NULL,
    "description" VARCHAR(300) DEFAULT NULL::character varying,
    CONSTRAINT "m_provision_category_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_provision_category_category_name_key" UNIQUE ("category_name")
);

-- Table: m_provisioning_criteria
CREATE TABLE "fineract_barebones_db"."m_provisioning_criteria" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_provisioning_criteria_id_seq'::regclass),
    "criteria_name" VARCHAR(200) NOT NULL,
    "createdby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    "lastmodified_date" TIMESTAMP,
    CONSTRAINT "m_provisioning_criteria_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_provisioning_criteria_createdby_id_key" UNIQUE ("createdby_id"),
    CONSTRAINT "m_provisioning_criteria_criteria_name_key" UNIQUE ("criteria_name"),
    CONSTRAINT "m_provisioning_criteria_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id")
);

-- Table: m_provisioning_criteria_definition
CREATE TABLE "fineract_barebones_db"."m_provisioning_criteria_definition" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_provisioning_criteria_definition_id_seq'::regclass),
    "criteria_id" BIGINT NOT NULL,
    "category_id" BIGINT NOT NULL,
    "min_age" BIGINT NOT NULL,
    "max_age" BIGINT NOT NULL,
    "provision_percentage" NUMERIC(5,2) NOT NULL,
    "liability_account" BIGINT,
    "expense_account" BIGINT,
    CONSTRAINT "m_provisioning_criteria_definition_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_provisioning_criteria_definition_category_id_key" UNIQUE ("category_id"),
    CONSTRAINT "m_provisioning_criteria_definition_criteria_id_key" UNIQUE ("criteria_id"),
    CONSTRAINT "m_provisioning_criteria_definition_expense_account_key" UNIQUE ("expense_account"),
    CONSTRAINT "m_provisioning_criteria_definition_liability_account_key" UNIQUE ("liability_account")
);

-- Table: m_report_mailing_job
CREATE TABLE "fineract_barebones_db"."m_report_mailing_job" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_report_mailing_job_id_seq'::regclass),
    "name" VARCHAR(100) NOT NULL,
    "description" TEXT,
    "start_datetime" TIMESTAMP NOT NULL,
    "recurrence" VARCHAR(100) DEFAULT NULL::character varying,
    "created_date" DATE NOT NULL,
    "createdby_id" BIGINT NOT NULL,
    "lastmodified_date" DATE,
    "lastmodifiedby_id" BIGINT,
    "email_recipients" TEXT NOT NULL,
    "email_subject" VARCHAR(100) NOT NULL,
    "email_message" TEXT NOT NULL,
    "email_attachment_file_format" VARCHAR(10) NOT NULL,
    "stretchy_report_id" INTEGER NOT NULL,
    "stretchy_report_param_map" TEXT,
    "previous_run_datetime" TIMESTAMP,
    "next_run_datetime" TIMESTAMP,
    "previous_run_status" VARCHAR(10) DEFAULT NULL::character varying,
    "previous_run_error_log" TEXT,
    "previous_run_error_message" TEXT,
    "number_of_runs" INTEGER NOT NULL DEFAULT 0,
    "is_active" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "is_deleted" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "run_as_userid" BIGINT NOT NULL,
    CONSTRAINT "m_report_mailing_job_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_report_mailing_job_createdby_id_key" UNIQUE ("createdby_id"),
    CONSTRAINT "m_report_mailing_job_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id"),
    CONSTRAINT "m_report_mailing_job_name_key" UNIQUE ("name"),
    CONSTRAINT "m_report_mailing_job_run_as_userid_key" UNIQUE ("run_as_userid"),
    CONSTRAINT "m_report_mailing_job_stretchy_report_id_key" UNIQUE ("stretchy_report_id")
);

-- Table: m_report_mailing_job_configuration
CREATE TABLE "fineract_barebones_db"."m_report_mailing_job_configuration" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.m_report_mailing_job_configuration_id_seq'::regclass),
    "name" VARCHAR(50) NOT NULL,
    "value" VARCHAR(200) NOT NULL,
    CONSTRAINT "m_report_mailing_job_configuration_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_report_mailing_job_configuration_name_key" UNIQUE ("name")
);

-- Table: m_report_mailing_job_run_history
CREATE TABLE "fineract_barebones_db"."m_report_mailing_job_run_history" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_report_mailing_job_run_history_id_seq'::regclass),
    "job_id" BIGINT NOT NULL,
    "start_datetime" TIMESTAMP NOT NULL,
    "end_datetime" TIMESTAMP NOT NULL,
    "status" VARCHAR(10) NOT NULL,
    "error_message" TEXT,
    "error_log" TEXT,
    CONSTRAINT "m_report_mailing_job_run_history_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_report_mailing_job_run_history_job_id_key" UNIQUE ("job_id")
);

-- Table: m_role
CREATE TABLE "fineract_barebones_db"."m_role" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_role_id_seq'::regclass),
    "name" VARCHAR(100) NOT NULL,
    "description" VARCHAR(500) NOT NULL,
    "is_disabled" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_role_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_role_name_key" UNIQUE ("name")
);

-- Table: m_role_permission
CREATE TABLE "fineract_barebones_db"."m_role_permission" (
    "role_id" BIGINT NOT NULL,
    "permission_id" BIGINT NOT NULL,
    CONSTRAINT "m_role_permission_pkey" PRIMARY KEY ("role_id", "permission_id"),
    CONSTRAINT "m_role_permission_permission_id_key" UNIQUE ("permission_id"),
    CONSTRAINT "m_role_permission_role_id_key" UNIQUE ("role_id")
);

-- Table: m_savings_account
CREATE TABLE "fineract_barebones_db"."m_savings_account" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_savings_account_id_seq'::regclass),
    "account_no" VARCHAR(20) NOT NULL,
    "external_id" VARCHAR(100) DEFAULT NULL::character varying,
    "client_id" BIGINT,
    "group_id" BIGINT,
    "product_id" BIGINT,
    "field_officer_id" BIGINT,
    "status_enum" SMALLINT NOT NULL DEFAULT '300'::smallint,
    "sub_status_enum" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "account_type_enum" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "deposit_type_enum" SMALLINT NOT NULL DEFAULT '100'::smallint,
    "submittedon_date" DATE NOT NULL,
    "submittedon_userid" BIGINT,
    "approvedon_date" DATE,
    "approvedon_userid" BIGINT,
    "rejectedon_date" DATE,
    "rejectedon_userid" BIGINT,
    "withdrawnon_date" DATE,
    "withdrawnon_userid" BIGINT,
    "activatedon_date" DATE,
    "activatedon_userid" BIGINT,
    "closedon_date" DATE,
    "closedon_userid" BIGINT,
    "currency_code" VARCHAR(3) NOT NULL,
    "currency_digits" SMALLINT NOT NULL,
    "currency_multiplesof" SMALLINT,
    "nominal_annual_interest_rate" NUMERIC(19,6) NOT NULL,
    "interest_compounding_period_enum" SMALLINT NOT NULL,
    "interest_posting_period_enum" SMALLINT NOT NULL DEFAULT '4'::smallint,
    "interest_calculation_type_enum" SMALLINT NOT NULL,
    "interest_calculation_days_in_year_type_enum" SMALLINT NOT NULL,
    "min_required_opening_balance" NUMERIC(19,6) DEFAULT NULL::numeric,
    "lockin_period_frequency" NUMERIC(19,6) DEFAULT NULL::numeric,
    "lockin_period_frequency_enum" SMALLINT,
    "withdrawal_fee_for_transfer" SMALLINT DEFAULT '1'::smallint,
    "allow_overdraft" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "overdraft_limit" NUMERIC(19,6) DEFAULT NULL::numeric,
    "nominal_annual_interest_rate_overdraft" NUMERIC(19,6) DEFAULT 0.000000,
    "min_overdraft_for_interest_calculation" NUMERIC(19,6) DEFAULT 0.000000,
    "lockedin_until_date_derived" DATE,
    "total_deposits_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_withdrawals_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_withdrawal_fees_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_fees_charge_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_penalty_charge_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_annual_fees_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_interest_earned_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_interest_posted_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "total_overdraft_interest_derived" NUMERIC(19,6) DEFAULT 0.000000,
    "total_withhold_tax_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "account_balance_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "min_required_balance" NUMERIC(19,6) DEFAULT NULL::numeric,
    "enforce_min_required_balance" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "min_balance_for_interest_calculation" NUMERIC(19,6) DEFAULT NULL::numeric,
    "start_interest_calculation_date" DATE,
    "on_hold_funds_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "version" INTEGER NOT NULL DEFAULT 1,
    "withhold_tax" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "tax_group_id" BIGINT,
    "last_interest_calculation_date" DATE,
    CONSTRAINT "m_savings_account_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_savings_account_account_no_key" UNIQUE ("account_no"),
    CONSTRAINT "m_savings_account_client_id_key" UNIQUE ("client_id"),
    CONSTRAINT "m_savings_account_external_id_key" UNIQUE ("external_id"),
    CONSTRAINT "m_savings_account_group_id_key" UNIQUE ("group_id"),
    CONSTRAINT "m_savings_account_product_id_key" UNIQUE ("product_id"),
    CONSTRAINT "m_savings_account_tax_group_id_key" UNIQUE ("tax_group_id")
);

-- Table: m_savings_account_charge
CREATE TABLE "fineract_barebones_db"."m_savings_account_charge" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_savings_account_charge_id_seq'::regclass),
    "savings_account_id" BIGINT NOT NULL,
    "charge_id" BIGINT NOT NULL,
    "is_penalty" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "charge_time_enum" SMALLINT NOT NULL,
    "charge_due_date" DATE,
    "fee_on_month" SMALLINT,
    "fee_on_day" SMALLINT,
    "fee_interval" SMALLINT,
    "charge_calculation_enum" SMALLINT NOT NULL,
    "calculation_percentage" NUMERIC(19,6) DEFAULT NULL::numeric,
    "calculation_on_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount" NUMERIC(19,6) NOT NULL,
    "amount_paid_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_waived_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_writtenoff_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_outstanding_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "is_paid_derived" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "waived" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "is_active" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "inactivated_on_date" DATE,
    CONSTRAINT "m_savings_account_charge_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_savings_account_charge_charge_id_key" UNIQUE ("charge_id"),
    CONSTRAINT "m_savings_account_charge_savings_account_id_key" UNIQUE ("savings_account_id")
);

-- Table: m_savings_account_charge_paid_by
CREATE TABLE "fineract_barebones_db"."m_savings_account_charge_paid_by" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_savings_account_charge_paid_by_id_seq'::regclass),
    "savings_account_transaction_id" BIGINT NOT NULL,
    "savings_account_charge_id" BIGINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    CONSTRAINT "m_savings_account_charge_paid_by_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_savings_account_charge_paid_by_savings_account_charge_id_key" UNIQUE ("savings_account_charge_id"),
    CONSTRAINT "m_savings_account_charge_paid_savings_account_transaction_i_key" UNIQUE ("savings_account_transaction_id")
);

-- Table: m_savings_account_interest_rate_chart
CREATE TABLE "fineract_barebones_db"."m_savings_account_interest_rate_chart" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_savings_account_interest_rate_chart_id_seq'::regclass),
    "savings_account_id" BIGINT NOT NULL,
    "name" VARCHAR(100) DEFAULT NULL::character varying,
    "description" VARCHAR(200) DEFAULT NULL::character varying,
    "from_date" DATE NOT NULL,
    "end_date" DATE,
    "is_primary_grouping_by_amount" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_savings_account_interest_rate_chart_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_savings_account_interest_rate_chart_savings_account_id_key" UNIQUE ("savings_account_id")
);

-- Table: m_savings_account_interest_rate_slab
CREATE TABLE "fineract_barebones_db"."m_savings_account_interest_rate_slab" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_savings_account_interest_rate_slab_id_seq'::regclass),
    "savings_account_interest_rate_chart_id" BIGINT NOT NULL,
    "description" VARCHAR(200) DEFAULT NULL::character varying,
    "period_type_enum" SMALLINT,
    "from_period" INTEGER,
    "to_period" INTEGER,
    "amount_range_from" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_range_to" NUMERIC(19,6) DEFAULT NULL::numeric,
    "annual_interest_rate" NUMERIC(19,6) NOT NULL,
    "currency_code" VARCHAR(3) NOT NULL,
    CONSTRAINT "m_savings_account_interest_rate_slab_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_savings_account_interest_ra_savings_account_interest_rate_key" UNIQUE ("savings_account_interest_rate_chart_id")
);

-- Table: m_savings_account_transaction
CREATE TABLE "fineract_barebones_db"."m_savings_account_transaction" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_savings_account_transaction_id_seq'::regclass),
    "savings_account_id" BIGINT NOT NULL,
    "office_id" BIGINT NOT NULL,
    "payment_detail_id" BIGINT,
    "transaction_type_enum" SMALLINT NOT NULL,
    "is_reversed" SMALLINT NOT NULL,
    "transaction_date" DATE NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "overdraft_amount_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "balance_end_date_derived" DATE,
    "balance_number_of_days_derived" INTEGER,
    "running_balance_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "cumulative_balance_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "created_date" TIMESTAMP NOT NULL,
    "appuser_id" BIGINT,
    "is_manual" SMALLINT DEFAULT '0'::smallint,
    CONSTRAINT "m_savings_account_transaction_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_savings_account_transaction_office_id_key" UNIQUE ("office_id"),
    CONSTRAINT "m_savings_account_transaction_payment_detail_id_key" UNIQUE ("payment_detail_id"),
    CONSTRAINT "m_savings_account_transaction_savings_account_id_key" UNIQUE ("savings_account_id")
);

-- Table: m_savings_account_transaction_tax_details
CREATE TABLE "fineract_barebones_db"."m_savings_account_transaction_tax_details" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_savings_account_transaction_tax_details_id_seq'::regclass),
    "savings_transaction_id" BIGINT NOT NULL,
    "tax_component_id" BIGINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    CONSTRAINT "m_savings_account_transaction_tax_details_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_savings_account_transaction_tax_de_savings_transaction_id_key" UNIQUE ("savings_transaction_id"),
    CONSTRAINT "m_savings_account_transaction_tax_details_tax_component_id_key" UNIQUE ("tax_component_id")
);

-- Table: m_savings_interest_incentives
CREATE TABLE "fineract_barebones_db"."m_savings_interest_incentives" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_savings_interest_incentives_id_seq'::regclass),
    "deposit_account_interest_rate_slab_id" BIGINT NOT NULL,
    "entiry_type" SMALLINT NOT NULL,
    "attribute_name" SMALLINT NOT NULL,
    "condition_type" SMALLINT NOT NULL,
    "attribute_value" VARCHAR(50) NOT NULL,
    "incentive_type" SMALLINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    CONSTRAINT "m_savings_interest_incentives_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_savings_interest_incentives_deposit_account_interest_rate_key" UNIQUE ("deposit_account_interest_rate_slab_id")
);

-- Table: m_savings_officer_assignment_history
CREATE TABLE "fineract_barebones_db"."m_savings_officer_assignment_history" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_savings_officer_assignment_history_id_seq'::regclass),
    "account_id" BIGINT NOT NULL,
    "savings_officer_id" BIGINT,
    "start_date" DATE NOT NULL,
    "end_date" DATE,
    "createdby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodified_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    CONSTRAINT "m_savings_officer_assignment_history_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_savings_officer_assignment_history_account_id_key" UNIQUE ("account_id"),
    CONSTRAINT "m_savings_officer_assignment_history_savings_officer_id_key" UNIQUE ("savings_officer_id")
);

-- Table: m_savings_product
CREATE TABLE "fineract_barebones_db"."m_savings_product" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_savings_product_id_seq'::regclass),
    "name" VARCHAR(100) NOT NULL,
    "short_name" VARCHAR(4) NOT NULL,
    "description" VARCHAR(500) NOT NULL,
    "deposit_type_enum" SMALLINT NOT NULL DEFAULT '100'::smallint,
    "currency_code" VARCHAR(3) NOT NULL,
    "currency_digits" SMALLINT NOT NULL,
    "currency_multiplesof" SMALLINT,
    "nominal_annual_interest_rate" NUMERIC(19,6) NOT NULL,
    "interest_compounding_period_enum" SMALLINT NOT NULL,
    "interest_posting_period_enum" SMALLINT NOT NULL DEFAULT '4'::smallint,
    "interest_calculation_type_enum" SMALLINT NOT NULL,
    "interest_calculation_days_in_year_type_enum" SMALLINT NOT NULL,
    "min_required_opening_balance" NUMERIC(19,6) DEFAULT NULL::numeric,
    "lockin_period_frequency" NUMERIC(19,6) DEFAULT NULL::numeric,
    "lockin_period_frequency_enum" SMALLINT,
    "accounting_type" SMALLINT NOT NULL,
    "withdrawal_fee_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "withdrawal_fee_type_enum" SMALLINT,
    "withdrawal_fee_for_transfer" SMALLINT DEFAULT '1'::smallint,
    "allow_overdraft" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "overdraft_limit" NUMERIC(19,6) DEFAULT NULL::numeric,
    "nominal_annual_interest_rate_overdraft" NUMERIC(19,6) DEFAULT 0.000000,
    "min_overdraft_for_interest_calculation" NUMERIC(19,6) DEFAULT 0.000000,
    "min_required_balance" NUMERIC(19,6) DEFAULT NULL::numeric,
    "enforce_min_required_balance" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "min_balance_for_interest_calculation" NUMERIC(19,6) DEFAULT NULL::numeric,
    "withhold_tax" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "tax_group_id" BIGINT,
    "is_dormancy_tracking_active" SMALLINT,
    "days_to_inactive" INTEGER,
    "days_to_dormancy" INTEGER,
    "days_to_escheat" INTEGER,
    CONSTRAINT "m_savings_product_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_savings_product_name_key" UNIQUE ("name"),
    CONSTRAINT "m_savings_product_short_name_key" UNIQUE ("short_name"),
    CONSTRAINT "m_savings_product_tax_group_id_key" UNIQUE ("tax_group_id")
);

-- Table: m_savings_product_charge
CREATE TABLE "fineract_barebones_db"."m_savings_product_charge" (
    "savings_product_id" BIGINT NOT NULL,
    "charge_id" BIGINT NOT NULL,
    CONSTRAINT "m_savings_product_charge_pkey" PRIMARY KEY ("savings_product_id", "charge_id"),
    CONSTRAINT "m_savings_product_charge_charge_id_key" UNIQUE ("charge_id")
);

-- Table: m_selfservice_user_client_mapping
CREATE TABLE "fineract_barebones_db"."m_selfservice_user_client_mapping" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_selfservice_user_client_mapping_id_seq'::regclass),
    "appuser_id" BIGINT NOT NULL,
    "client_id" BIGINT NOT NULL,
    CONSTRAINT "m_selfservice_user_client_mapping_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_selfservice_user_client_mapping_appuser_id_client_id_key" UNIQUE ("appuser_id", "client_id"),
    CONSTRAINT "m_selfservice_user_client_mapping_client_id_key" UNIQUE ("client_id")
);

-- Table: m_share_account
CREATE TABLE "fineract_barebones_db"."m_share_account" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_share_account_id_seq'::regclass),
    "account_no" VARCHAR(50) NOT NULL,
    "product_id" BIGINT NOT NULL,
    "client_id" BIGINT NOT NULL,
    "external_id" VARCHAR(100) DEFAULT NULL::character varying,
    "status_enum" SMALLINT NOT NULL DEFAULT '300'::smallint,
    "total_approved_shares" BIGINT,
    "total_pending_shares" BIGINT,
    "submitted_date" DATE NOT NULL,
    "submitted_userid" BIGINT,
    "approved_date" DATE,
    "approved_userid" BIGINT,
    "rejected_date" DATE,
    "rejected_userid" BIGINT,
    "activated_date" DATE,
    "activated_userid" BIGINT,
    "closed_date" DATE,
    "closed_userid" BIGINT,
    "currency_code" VARCHAR(3) NOT NULL,
    "currency_digits" SMALLINT NOT NULL,
    "currency_multiplesof" SMALLINT,
    "savings_account_id" BIGINT NOT NULL,
    "minimum_active_period_frequency" NUMERIC(19,6) DEFAULT NULL::numeric,
    "minimum_active_period_frequency_enum" SMALLINT,
    "lockin_period_frequency" NUMERIC(19,6) DEFAULT NULL::numeric,
    "lockin_period_frequency_enum" SMALLINT,
    "allow_dividends_inactive_clients" SMALLINT DEFAULT '0'::smallint,
    "created_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    "lastmodified_date" TIMESTAMP,
    CONSTRAINT "m_share_account_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_share_account_activated_userid_key" UNIQUE ("activated_userid"),
    CONSTRAINT "m_share_account_approved_userid_key" UNIQUE ("approved_userid"),
    CONSTRAINT "m_share_account_client_id_key" UNIQUE ("client_id"),
    CONSTRAINT "m_share_account_closed_userid_key" UNIQUE ("closed_userid"),
    CONSTRAINT "m_share_account_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id"),
    CONSTRAINT "m_share_account_product_id_key" UNIQUE ("product_id"),
    CONSTRAINT "m_share_account_rejected_userid_key" UNIQUE ("rejected_userid"),
    CONSTRAINT "m_share_account_savings_account_id_key" UNIQUE ("savings_account_id"),
    CONSTRAINT "m_share_account_submitted_userid_key" UNIQUE ("submitted_userid")
);

-- Table: m_share_account_charge
CREATE TABLE "fineract_barebones_db"."m_share_account_charge" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_share_account_charge_id_seq'::regclass),
    "account_id" BIGINT NOT NULL,
    "charge_id" BIGINT NOT NULL,
    "charge_time_enum" SMALLINT NOT NULL,
    "charge_calculation_enum" SMALLINT NOT NULL,
    "charge_payment_mode_enum" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "calculation_percentage" NUMERIC(19,6) DEFAULT NULL::numeric,
    "calculation_on_amount" NUMERIC(19,6) DEFAULT NULL::numeric,
    "charge_amount_or_percentage" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount" NUMERIC(19,6) NOT NULL,
    "amount_paid_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_waived_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_writtenoff_derived" NUMERIC(19,6) DEFAULT NULL::numeric,
    "amount_outstanding_derived" NUMERIC(19,6) NOT NULL DEFAULT 0.000000,
    "is_paid_derived" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "waived" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "min_cap" NUMERIC(19,6) DEFAULT NULL::numeric,
    "max_cap" NUMERIC(19,6) DEFAULT NULL::numeric,
    "is_active" SMALLINT NOT NULL DEFAULT '1'::smallint,
    CONSTRAINT "m_share_account_charge_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_share_account_charge_account_id_key" UNIQUE ("account_id"),
    CONSTRAINT "m_share_account_charge_charge_id_key" UNIQUE ("charge_id")
);

-- Table: m_share_account_charge_paid_by
CREATE TABLE "fineract_barebones_db"."m_share_account_charge_paid_by" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_share_account_charge_paid_by_id_seq'::regclass),
    "share_transaction_id" BIGINT,
    "charge_transaction_id" BIGINT,
    "amount" NUMERIC(20,2) NOT NULL,
    CONSTRAINT "m_share_account_charge_paid_by_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_share_account_charge_paid_by_charge_transaction_id_key" UNIQUE ("charge_transaction_id"),
    CONSTRAINT "m_share_account_charge_paid_by_share_transaction_id_key" UNIQUE ("share_transaction_id")
);

-- Table: m_share_account_dividend_details
CREATE TABLE "fineract_barebones_db"."m_share_account_dividend_details" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_share_account_dividend_details_id_seq'::regclass),
    "dividend_pay_out_id" BIGINT NOT NULL,
    "account_id" BIGINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "status" SMALLINT NOT NULL,
    "savings_transaction_id" BIGINT,
    CONSTRAINT "m_share_account_dividend_details_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_share_account_dividend_details_account_id_key" UNIQUE ("account_id"),
    CONSTRAINT "m_share_account_dividend_details_dividend_pay_out_id_key" UNIQUE ("dividend_pay_out_id")
);

-- Table: m_share_account_transactions
CREATE TABLE "fineract_barebones_db"."m_share_account_transactions" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_share_account_transactions_id_seq'::regclass),
    "account_id" BIGINT NOT NULL,
    "transaction_date" DATE,
    "total_shares" BIGINT,
    "unit_price" NUMERIC(10,2) DEFAULT NULL::numeric,
    "amount" NUMERIC(20,2) DEFAULT NULL::numeric,
    "charge_amount" NUMERIC(20,2) DEFAULT NULL::numeric,
    "amount_paid" NUMERIC(20,2) DEFAULT NULL::numeric,
    "status_enum" SMALLINT NOT NULL DEFAULT '300'::smallint,
    "type_enum" SMALLINT,
    "is_active" SMALLINT NOT NULL DEFAULT '1'::smallint,
    CONSTRAINT "m_share_account_transactions_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_share_account_transactions_account_id_key" UNIQUE ("account_id")
);

-- Table: m_share_product
CREATE TABLE "fineract_barebones_db"."m_share_product" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_share_product_id_seq'::regclass),
    "name" VARCHAR(200) NOT NULL,
    "short_name" VARCHAR(4) NOT NULL,
    "external_id" VARCHAR(100) DEFAULT NULL::character varying,
    "description" VARCHAR(500) NOT NULL,
    "start_date" TIMESTAMP,
    "end_date" TIMESTAMP,
    "currency_code" VARCHAR(3) NOT NULL,
    "currency_digits" SMALLINT NOT NULL,
    "currency_multiplesof" SMALLINT,
    "total_shares" BIGINT NOT NULL,
    "issued_shares" BIGINT,
    "totalsubscribed_shares" BIGINT,
    "unit_price" NUMERIC(10,2) NOT NULL,
    "capital_amount" NUMERIC(20,2) NOT NULL,
    "minimum_client_shares" BIGINT,
    "nominal_client_shares" BIGINT NOT NULL,
    "maximum_client_shares" BIGINT,
    "minimum_active_period_frequency" NUMERIC(19,6) DEFAULT NULL::numeric,
    "minimum_active_period_frequency_enum" SMALLINT,
    "lockin_period_frequency" NUMERIC(19,6) DEFAULT NULL::numeric,
    "lockin_period_frequency_enum" SMALLINT,
    "allow_dividends_inactive_clients" SMALLINT DEFAULT '0'::smallint,
    "createdby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    "lastmodified_date" TIMESTAMP,
    "accounting_type" SMALLINT NOT NULL,
    CONSTRAINT "m_share_product_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_share_product_createdby_id_key" UNIQUE ("createdby_id"),
    CONSTRAINT "m_share_product_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id"),
    CONSTRAINT "m_share_product_name_key" UNIQUE ("name")
);

-- Table: m_share_product_charge
CREATE TABLE "fineract_barebones_db"."m_share_product_charge" (
    "product_id" BIGINT NOT NULL,
    "charge_id" BIGINT NOT NULL,
    CONSTRAINT "m_share_product_charge_pkey" PRIMARY KEY ("product_id", "charge_id"),
    CONSTRAINT "m_share_product_charge_charge_id_key" UNIQUE ("charge_id")
);

-- Table: m_share_product_dividend_pay_out
CREATE TABLE "fineract_barebones_db"."m_share_product_dividend_pay_out" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_share_product_dividend_pay_out_id_seq'::regclass),
    "product_id" BIGINT NOT NULL,
    "amount" NUMERIC(19,6) NOT NULL,
    "dividend_period_start_date" DATE NOT NULL,
    "dividend_period_end_date" DATE NOT NULL,
    "status" SMALLINT NOT NULL,
    "createdby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    "lastmodified_date" TIMESTAMP,
    CONSTRAINT "m_share_product_dividend_pay_out_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_share_product_dividend_pay_out_createdby_id_key" UNIQUE ("createdby_id"),
    CONSTRAINT "m_share_product_dividend_pay_out_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id"),
    CONSTRAINT "m_share_product_dividend_pay_out_product_id_key" UNIQUE ("product_id")
);

-- Table: m_share_product_market_price
CREATE TABLE "fineract_barebones_db"."m_share_product_market_price" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_share_product_market_price_id_seq'::regclass),
    "product_id" BIGINT NOT NULL,
    "from_date" DATE,
    "share_value" NUMERIC(10,2) NOT NULL,
    CONSTRAINT "m_share_product_market_price_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_share_product_market_price_product_id_key" UNIQUE ("product_id")
);

-- Table: m_staff
CREATE TABLE "fineract_barebones_db"."m_staff" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_staff_id_seq'::regclass),
    "is_loan_officer" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "office_id" BIGINT,
    "firstname" VARCHAR(50) DEFAULT NULL::character varying,
    "lastname" VARCHAR(50) DEFAULT NULL::character varying,
    "display_name" VARCHAR(102) NOT NULL,
    "mobile_no" VARCHAR(50) DEFAULT NULL::character varying,
    "external_id" VARCHAR(100) DEFAULT NULL::character varying,
    "organisational_role_enum" SMALLINT,
    "organisational_role_parent_staff_id" BIGINT,
    "is_active" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "joining_date" DATE,
    "image_id" BIGINT,
    CONSTRAINT "m_staff_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_staff_display_name_key" UNIQUE ("display_name"),
    CONSTRAINT "m_staff_external_id_key" UNIQUE ("external_id"),
    CONSTRAINT "m_staff_image_id_key" UNIQUE ("image_id"),
    CONSTRAINT "m_staff_mobile_no_key" UNIQUE ("mobile_no"),
    CONSTRAINT "m_staff_office_id_key" UNIQUE ("office_id")
);

-- Table: m_staff_assignment_history
CREATE TABLE "fineract_barebones_db"."m_staff_assignment_history" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_staff_assignment_history_id_seq'::regclass),
    "centre_id" BIGINT,
    "staff_id" BIGINT NOT NULL,
    "start_date" DATE NOT NULL,
    "end_date" DATE,
    "createdby_id" BIGINT,
    "created_date" TIMESTAMP,
    "lastmodified_date" TIMESTAMP,
    "lastmodifiedby_id" BIGINT,
    CONSTRAINT "m_staff_assignment_history_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_staff_assignment_history_centre_id_key" UNIQUE ("centre_id"),
    CONSTRAINT "m_staff_assignment_history_staff_id_key" UNIQUE ("staff_id")
);

-- Table: m_survey_components
CREATE TABLE "fineract_barebones_db"."m_survey_components" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_survey_components_id_seq'::regclass),
    "survey_id" BIGINT NOT NULL,
    "a_key" VARCHAR(32) NOT NULL,
    "a_text" VARCHAR(255) NOT NULL,
    "description" VARCHAR(4000) DEFAULT NULL::character varying,
    "sequence_no" INTEGER NOT NULL,
    CONSTRAINT "m_survey_components_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_survey_components_survey_id_key" UNIQUE ("survey_id")
);

-- Table: m_survey_lookup_tables
CREATE TABLE "fineract_barebones_db"."m_survey_lookup_tables" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_survey_lookup_tables_id_seq'::regclass),
    "survey_id" BIGINT NOT NULL,
    "a_key" VARCHAR(255) NOT NULL,
    "description" INTEGER,
    "value_from" INTEGER NOT NULL,
    "value_to" INTEGER NOT NULL,
    "score" NUMERIC(5,2) NOT NULL,
    CONSTRAINT "m_survey_lookup_tables_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_survey_lookup_tables_survey_id_key" UNIQUE ("survey_id")
);

-- Table: m_survey_questions
CREATE TABLE "fineract_barebones_db"."m_survey_questions" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_survey_questions_id_seq'::regclass),
    "survey_id" BIGINT NOT NULL,
    "component_key" VARCHAR(32) DEFAULT NULL::character varying,
    "a_key" VARCHAR(32) NOT NULL,
    "a_text" VARCHAR(255) NOT NULL,
    "description" VARCHAR(4000) DEFAULT NULL::character varying,
    "sequence_no" INTEGER NOT NULL,
    CONSTRAINT "m_survey_questions_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_survey_questions_survey_id_key" UNIQUE ("survey_id")
);

-- Table: m_survey_responses
CREATE TABLE "fineract_barebones_db"."m_survey_responses" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_survey_responses_id_seq'::regclass),
    "question_id" BIGINT NOT NULL,
    "a_text" VARCHAR(255) NOT NULL,
    "a_value" INTEGER NOT NULL,
    "sequence_no" INTEGER NOT NULL,
    CONSTRAINT "m_survey_responses_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_survey_responses_question_id_key" UNIQUE ("question_id")
);

-- Table: m_survey_scorecards
CREATE TABLE "fineract_barebones_db"."m_survey_scorecards" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_survey_scorecards_id_seq'::regclass),
    "survey_id" BIGINT NOT NULL,
    "question_id" BIGINT NOT NULL,
    "response_id" BIGINT NOT NULL,
    "user_id" BIGINT NOT NULL,
    "client_id" BIGINT NOT NULL,
    "created_on" TIMESTAMP,
    "a_value" INTEGER NOT NULL,
    CONSTRAINT "m_survey_scorecards_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_survey_scorecards_client_id_key" UNIQUE ("client_id"),
    CONSTRAINT "m_survey_scorecards_question_id_key" UNIQUE ("question_id"),
    CONSTRAINT "m_survey_scorecards_response_id_key" UNIQUE ("response_id"),
    CONSTRAINT "m_survey_scorecards_survey_id_key" UNIQUE ("survey_id"),
    CONSTRAINT "m_survey_scorecards_user_id_key" UNIQUE ("user_id")
);

-- Table: m_surveys
CREATE TABLE "fineract_barebones_db"."m_surveys" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_surveys_id_seq'::regclass),
    "a_key" VARCHAR(32) NOT NULL,
    "a_name" VARCHAR(255) NOT NULL,
    "description" VARCHAR(4000) DEFAULT NULL::character varying,
    "country_code" VARCHAR(2) NOT NULL,
    "valid_from" TIMESTAMP,
    "valid_to" TIMESTAMP,
    CONSTRAINT "m_surveys_pkey" PRIMARY KEY ("id")
);

-- Table: m_tax_component
CREATE TABLE "fineract_barebones_db"."m_tax_component" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_tax_component_id_seq'::regclass),
    "name" VARCHAR(50) NOT NULL,
    "percentage" NUMERIC(19,6) NOT NULL,
    "debit_account_type_enum" SMALLINT,
    "debit_account_id" BIGINT,
    "credit_account_type_enum" SMALLINT,
    "credit_account_id" BIGINT,
    "start_date" DATE NOT NULL,
    "createdby_id" BIGINT NOT NULL,
    "created_date" TIMESTAMP NOT NULL,
    "lastmodifiedby_id" BIGINT NOT NULL,
    "lastmodified_date" TIMESTAMP NOT NULL,
    CONSTRAINT "m_tax_component_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_tax_component_createdby_id_key" UNIQUE ("createdby_id"),
    CONSTRAINT "m_tax_component_credit_account_id_key" UNIQUE ("credit_account_id"),
    CONSTRAINT "m_tax_component_debit_account_id_key" UNIQUE ("debit_account_id"),
    CONSTRAINT "m_tax_component_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id")
);

-- Table: m_tax_component_history
CREATE TABLE "fineract_barebones_db"."m_tax_component_history" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_tax_component_history_id_seq'::regclass),
    "tax_component_id" BIGINT NOT NULL,
    "percentage" NUMERIC(19,6) NOT NULL,
    "start_date" DATE NOT NULL,
    "end_date" DATE NOT NULL,
    "createdby_id" BIGINT NOT NULL,
    "created_date" TIMESTAMP NOT NULL,
    "lastmodifiedby_id" BIGINT NOT NULL,
    "lastmodified_date" TIMESTAMP NOT NULL,
    CONSTRAINT "m_tax_component_history_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_tax_component_history_createdby_id_key" UNIQUE ("createdby_id"),
    CONSTRAINT "m_tax_component_history_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id"),
    CONSTRAINT "m_tax_component_history_tax_component_id_key" UNIQUE ("tax_component_id")
);

-- Table: m_tax_group
CREATE TABLE "fineract_barebones_db"."m_tax_group" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_tax_group_id_seq'::regclass),
    "name" VARCHAR(50) NOT NULL,
    "createdby_id" BIGINT NOT NULL,
    "created_date" TIMESTAMP NOT NULL,
    "lastmodifiedby_id" BIGINT NOT NULL,
    "lastmodified_date" TIMESTAMP NOT NULL,
    CONSTRAINT "m_tax_group_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_tax_group_createdby_id_key" UNIQUE ("createdby_id"),
    CONSTRAINT "m_tax_group_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id")
);

-- Table: m_tax_group_mappings
CREATE TABLE "fineract_barebones_db"."m_tax_group_mappings" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_tax_group_mappings_id_seq'::regclass),
    "tax_group_id" BIGINT NOT NULL,
    "tax_component_id" BIGINT NOT NULL,
    "start_date" DATE NOT NULL,
    "end_date" DATE,
    "createdby_id" BIGINT NOT NULL,
    "created_date" TIMESTAMP NOT NULL,
    "lastmodifiedby_id" BIGINT NOT NULL,
    "lastmodified_date" TIMESTAMP NOT NULL,
    CONSTRAINT "m_tax_group_mappings_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_tax_group_mappings_createdby_id_key" UNIQUE ("createdby_id"),
    CONSTRAINT "m_tax_group_mappings_lastmodifiedby_id_key" UNIQUE ("lastmodifiedby_id"),
    CONSTRAINT "m_tax_group_mappings_tax_component_id_key" UNIQUE ("tax_component_id"),
    CONSTRAINT "m_tax_group_mappings_tax_group_id_key" UNIQUE ("tax_group_id")
);

-- Table: m_tellers
CREATE TABLE "fineract_barebones_db"."m_tellers" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_tellers_id_seq'::regclass),
    "office_id" BIGINT NOT NULL,
    "debit_account_id" BIGINT,
    "credit_account_id" BIGINT,
    "name" VARCHAR(50) NOT NULL,
    "description" VARCHAR(100) DEFAULT NULL::character varying,
    "valid_from" DATE,
    "valid_to" DATE,
    "state" SMALLINT,
    CONSTRAINT "m_tellers_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_tellers_credit_account_id_key" UNIQUE ("credit_account_id"),
    CONSTRAINT "m_tellers_debit_account_id_key" UNIQUE ("debit_account_id"),
    CONSTRAINT "m_tellers_name_key" UNIQUE ("name"),
    CONSTRAINT "m_tellers_office_id_key" UNIQUE ("office_id")
);

-- Table: m_template
CREATE TABLE "fineract_barebones_db"."m_template" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_template_id_seq'::regclass),
    "name" VARCHAR(255) NOT NULL,
    "text" TEXT NOT NULL,
    "entity" INTEGER,
    "type" INTEGER,
    CONSTRAINT "m_template_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "m_template_name_key" UNIQUE ("name")
);

-- Table: m_template_m_templatemappers
CREATE TABLE "fineract_barebones_db"."m_template_m_templatemappers" (
    "m_template_id" BIGINT NOT NULL,
    "mappers_id" BIGINT NOT NULL,
    CONSTRAINT "m_template_m_templatemappers_m_template_id_key" UNIQUE ("m_template_id"),
    CONSTRAINT "m_template_m_templatemappers_mappers_id_key" UNIQUE ("mappers_id")
);

-- Table: m_templatemappers
CREATE TABLE "fineract_barebones_db"."m_templatemappers" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_templatemappers_id_seq'::regclass),
    "mapperkey" VARCHAR(255) DEFAULT NULL::character varying,
    "mapperorder" INTEGER,
    "mappervalue" VARCHAR(255) DEFAULT NULL::character varying,
    CONSTRAINT "m_templatemappers_pkey" PRIMARY KEY ("id")
);

-- Table: m_working_days
CREATE TABLE "fineract_barebones_db"."m_working_days" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.m_working_days_id_seq'::regclass),
    "recurrence" VARCHAR(100) DEFAULT NULL::character varying,
    "repayment_rescheduling_enum" SMALLINT,
    "extend_term_daily_repayments" SMALLINT DEFAULT '0'::smallint,
    "extend_term_holiday_repayment" SMALLINT NOT NULL DEFAULT '0'::smallint,
    CONSTRAINT "m_working_days_pkey" PRIMARY KEY ("id")
);

-- Table: mix_taxonomy
CREATE TABLE "fineract_barebones_db"."mix_taxonomy" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.mix_taxonomy_id_seq'::regclass),
    "name" VARCHAR(100) DEFAULT NULL::character varying,
    "namespace_id" INTEGER,
    "dimension" VARCHAR(100) DEFAULT NULL::character varying,
    "type" INTEGER,
    "description" VARCHAR(1000) DEFAULT NULL::character varying,
    "need_mapping" SMALLINT,
    CONSTRAINT "mix_taxonomy_pkey" PRIMARY KEY ("id")
);

-- Table: mix_taxonomy_mapping
CREATE TABLE "fineract_barebones_db"."mix_taxonomy_mapping" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.mix_taxonomy_mapping_id_seq'::regclass),
    "identifier" VARCHAR(50) NOT NULL DEFAULT ''::character varying,
    "config" VARCHAR(200) DEFAULT NULL::character varying,
    "last_update_date" TIMESTAMP,
    "currency" VARCHAR(11) DEFAULT NULL::character varying,
    CONSTRAINT "mix_taxonomy_mapping_pkey" PRIMARY KEY ("id")
);

-- Table: mix_xbrl_namespace
CREATE TABLE "fineract_barebones_db"."mix_xbrl_namespace" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.mix_xbrl_namespace_id_seq'::regclass),
    "prefix" VARCHAR(20) NOT NULL DEFAULT ''::character varying,
    "url" VARCHAR(100) DEFAULT NULL::character varying,
    CONSTRAINT "mix_xbrl_namespace_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "mix_xbrl_namespace_prefix_key" UNIQUE ("prefix")
);

-- Table: oauth_access_token
CREATE TABLE "fineract_barebones_db"."oauth_access_token" (
    "token_id" VARCHAR(256) DEFAULT NULL::character varying,
    "token" BYTEA,
    "authentication_id" VARCHAR(256) DEFAULT NULL::character varying,
    "user_name" VARCHAR(256) DEFAULT NULL::character varying,
    "client_id" VARCHAR(256) DEFAULT NULL::character varying,
    "authentication" BYTEA,
    "refresh_token" VARCHAR(256) DEFAULT NULL::character varying
);

-- Table: oauth_client_details
CREATE TABLE "fineract_barebones_db"."oauth_client_details" (
    "client_id" VARCHAR(128) NOT NULL,
    "resource_ids" VARCHAR(256) DEFAULT NULL::character varying,
    "client_secret" VARCHAR(256) DEFAULT NULL::character varying,
    "scope" VARCHAR(256) DEFAULT NULL::character varying,
    "authorized_grant_types" VARCHAR(256) DEFAULT NULL::character varying,
    "web_server_redirect_uri" VARCHAR(256) DEFAULT NULL::character varying,
    "authorities" VARCHAR(256) DEFAULT NULL::character varying,
    "access_token_validity" INTEGER,
    "refresh_token_validity" INTEGER,
    "additional_information" VARCHAR(4096) DEFAULT NULL::character varying,
    "autoapprove" BOOLEAN,
    CONSTRAINT "oauth_client_details_pkey" PRIMARY KEY ("client_id")
);

-- Table: oauth_refresh_token
CREATE TABLE "fineract_barebones_db"."oauth_refresh_token" (
    "token_id" VARCHAR(256) DEFAULT NULL::character varying,
    "token" BYTEA,
    "authentication" BYTEA
);

-- Table: ppi_likelihoods
CREATE TABLE "fineract_barebones_db"."ppi_likelihoods" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.ppi_likelihoods_id_seq'::regclass),
    "code" VARCHAR(100) NOT NULL,
    "name" VARCHAR(250) NOT NULL,
    CONSTRAINT "ppi_likelihoods_pkey" PRIMARY KEY ("id")
);

-- Table: ppi_likelihoods_ppi
CREATE TABLE "fineract_barebones_db"."ppi_likelihoods_ppi" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.ppi_likelihoods_ppi_id_seq'::regclass),
    "likelihood_id" BIGINT NOT NULL,
    "ppi_name" VARCHAR(250) NOT NULL,
    "enabled" INTEGER NOT NULL DEFAULT 100,
    CONSTRAINT "ppi_likelihoods_ppi_pkey" PRIMARY KEY ("id")
);

-- Table: ppi_scores
CREATE TABLE "fineract_barebones_db"."ppi_scores" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.ppi_scores_id_seq'::regclass),
    "score_from" INTEGER NOT NULL,
    "score_to" INTEGER NOT NULL,
    CONSTRAINT "ppi_scores_pkey" PRIMARY KEY ("id")
);

-- Table: r_enum_value
CREATE TABLE "fineract_barebones_db"."r_enum_value" (
    "enum_name" VARCHAR(100) NOT NULL,
    "enum_id" INTEGER NOT NULL,
    "enum_message_property" VARCHAR(100) NOT NULL,
    "enum_value" VARCHAR(100) NOT NULL,
    "enum_type" SMALLINT NOT NULL,
    CONSTRAINT "r_enum_value_pkey" PRIMARY KEY ("enum_name", "enum_id"),
    CONSTRAINT "r_enum_value_enum_name_enum_message_property_key" UNIQUE ("enum_name", "enum_message_property"),
    CONSTRAINT "r_enum_value_enum_name_enum_value_key" UNIQUE ("enum_name", "enum_value")
);

-- Table: rpt_sequence
CREATE TABLE "fineract_barebones_db"."rpt_sequence" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.rpt_sequence_id_seq'::regclass),
    CONSTRAINT "rpt_sequence_pkey" PRIMARY KEY ("id")
);

-- Table: scheduler_detail
CREATE TABLE "fineract_barebones_db"."scheduler_detail" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.scheduler_detail_id_seq'::regclass),
    "is_suspended" SMALLINT NOT NULL DEFAULT '0'::smallint,
    "execute_misfired_jobs" SMALLINT NOT NULL DEFAULT '1'::smallint,
    "reset_scheduler_on_bootup" SMALLINT NOT NULL DEFAULT '1'::smallint,
    CONSTRAINT "scheduler_detail_pkey" PRIMARY KEY ("id")
);

-- Table: schema_version
CREATE TABLE "fineract_barebones_db"."schema_version" (
    "version_rank" INTEGER NOT NULL,
    "installed_rank" INTEGER NOT NULL,
    "version" VARCHAR(50) NOT NULL,
    "description" VARCHAR(200) NOT NULL,
    "type" VARCHAR(20) NOT NULL,
    "script" VARCHAR(1000) NOT NULL,
    "checksum" INTEGER,
    "installed_by" VARCHAR(100) NOT NULL,
    "installed_on" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "execution_time" INTEGER NOT NULL,
    "success" SMALLINT NOT NULL,
    CONSTRAINT "schema_version_pkey" PRIMARY KEY ("version"),
    CONSTRAINT "schema_version_installed_rank_key" UNIQUE ("installed_rank"),
    CONSTRAINT "schema_version_success_key" UNIQUE ("success"),
    CONSTRAINT "schema_version_version_rank_key" UNIQUE ("version_rank")
);

-- Table: sms_campaign
CREATE TABLE "fineract_barebones_db"."sms_campaign" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.sms_campaign_id_seq'::regclass),
    "campaign_name" VARCHAR(100) NOT NULL,
    "campaign_type" INTEGER NOT NULL,
    "campaign_trigger_type" INTEGER NOT NULL,
    "report_id" INTEGER NOT NULL,
    "provider_id" BIGINT NOT NULL,
    "param_value" TEXT,
    "status_enum" INTEGER NOT NULL,
    "message" TEXT NOT NULL,
    "submittedon_date" DATE,
    "submittedon_userid" BIGINT,
    "approvedon_date" DATE,
    "approvedon_userid" BIGINT,
    "closedon_date" DATE,
    "closedon_userid" BIGINT,
    "recurrence" VARCHAR(100) DEFAULT NULL::character varying,
    "next_trigger_date" TIMESTAMP,
    "last_trigger_date" TIMESTAMP,
    "recurrence_start_date" TIMESTAMP,
    "is_visible" SMALLINT DEFAULT '1'::smallint,
    CONSTRAINT "sms_campaign_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "sms_campaign_report_id_key" UNIQUE ("report_id")
);

-- Table: sms_messages_outbound
CREATE TABLE "fineract_barebones_db"."sms_messages_outbound" (
    "id" BIGINT NOT NULL DEFAULT nextval('fineract_barebones_db.sms_messages_outbound_id_seq'::regclass),
    "group_id" BIGINT,
    "client_id" BIGINT,
    "staff_id" BIGINT,
    "status_enum" INTEGER NOT NULL DEFAULT 100,
    "mobile_no" VARCHAR(50) NOT NULL,
    "message" VARCHAR(1000) NOT NULL,
    "campaign_id" BIGINT NOT NULL,
    "external_id" VARCHAR(100) DEFAULT NULL::character varying,
    "submittedon_date" DATE,
    "delivered_on_date" TIMESTAMP,
    CONSTRAINT "sms_messages_outbound_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "sms_messages_outbound_campaign_id_key" UNIQUE ("campaign_id"),
    CONSTRAINT "sms_messages_outbound_client_id_key" UNIQUE ("client_id"),
    CONSTRAINT "sms_messages_outbound_group_id_key" UNIQUE ("group_id"),
    CONSTRAINT "sms_messages_outbound_staff_id_key" UNIQUE ("staff_id")
);

-- Table: stretchy_parameter
CREATE TABLE "fineract_barebones_db"."stretchy_parameter" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.stretchy_parameter_id_seq'::regclass),
    "parameter_name" VARCHAR(45) NOT NULL,
    "parameter_variable" VARCHAR(45) DEFAULT NULL::character varying,
    "parameter_label" VARCHAR(45) NOT NULL,
    "parameter_displayType" VARCHAR(45) NOT NULL,
    "parameter_FormatType" VARCHAR(10) NOT NULL,
    "parameter_default" VARCHAR(45) NOT NULL,
    "special" VARCHAR(1) DEFAULT NULL::character varying,
    "selectOne" VARCHAR(1) DEFAULT NULL::character varying,
    "selectAll" VARCHAR(1) DEFAULT NULL::character varying,
    "parameter_sql" TEXT,
    "parent_id" INTEGER,
    CONSTRAINT "stretchy_parameter_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "stretchy_parameter_parameter_name_key" UNIQUE ("parameter_name"),
    CONSTRAINT "stretchy_parameter_parent_id_key" UNIQUE ("parent_id")
);

-- Table: stretchy_report
CREATE TABLE "fineract_barebones_db"."stretchy_report" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.stretchy_report_id_seq'::regclass),
    "report_name" VARCHAR(100) NOT NULL,
    "report_type" VARCHAR(20) NOT NULL,
    "report_subtype" VARCHAR(20) DEFAULT NULL::character varying,
    "report_category" VARCHAR(45) DEFAULT NULL::character varying,
    "report_sql" TEXT,
    "description" TEXT,
    "core_report" SMALLINT DEFAULT '0'::smallint,
    "use_report" SMALLINT DEFAULT '0'::smallint,
    CONSTRAINT "stretchy_report_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "stretchy_report_report_name_key" UNIQUE ("report_name")
);

-- Table: stretchy_report_parameter
CREATE TABLE "fineract_barebones_db"."stretchy_report_parameter" (
    "id" INTEGER NOT NULL DEFAULT nextval('fineract_barebones_db.stretchy_report_parameter_id_seq'::regclass),
    "report_id" INTEGER NOT NULL,
    "parameter_id" INTEGER NOT NULL,
    "report_parameter_name" VARCHAR(45) DEFAULT NULL::character varying,
    CONSTRAINT "stretchy_report_parameter_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "stretchy_report_parameter_parameter_id_key" UNIQUE ("parameter_id"),
    CONSTRAINT "stretchy_report_parameter_report_id_key" UNIQUE ("report_id"),
    CONSTRAINT "stretchy_report_parameter_report_id_parameter_id_key" UNIQUE ("report_id", "parameter_id")
);

-- Table: x_registered_table
CREATE TABLE "fineract_barebones_db"."x_registered_table" (
    "registered_table_name" VARCHAR(50) NOT NULL,
    "application_table_name" VARCHAR(50) NOT NULL,
    "category" INTEGER NOT NULL DEFAULT 100,
    CONSTRAINT "x_registered_table_pkey" PRIMARY KEY ("registered_table_name")
);

-- Table: x_table_column_code_mappings
CREATE TABLE "fineract_barebones_db"."x_table_column_code_mappings" (
    "column_alias_name" VARCHAR(50) NOT NULL,
    "code_id" INTEGER NOT NULL,
    CONSTRAINT "x_table_column_code_mappings_pkey" PRIMARY KEY ("column_alias_name"),
    CONSTRAINT "x_table_column_code_mappings_code_id_key" UNIQUE ("code_id")
);

-- Foreign Keys
ALTER TABLE "fineract_barebones_db"."acc_accounting_rule" ADD CONSTRAINT "fk_acc_accounting_rule_0" FOREIGN KEY ("credit_account_id") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_accounting_rule" ADD CONSTRAINT "fk_acc_accounting_rule_1" FOREIGN KEY ("debit_account_id") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_accounting_rule" ADD CONSTRAINT "fk_acc_accounting_rule_2" FOREIGN KEY ("office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_account" ADD CONSTRAINT "fk_acc_gl_account_0" FOREIGN KEY ("tag_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_account" ADD CONSTRAINT "fk_acc_gl_account_1" FOREIGN KEY ("parent_id") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_closure" ADD CONSTRAINT "fk_acc_gl_closure_2" FOREIGN KEY ("office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_financial_activity_account" ADD CONSTRAINT "fk_acc_gl_financial_activity_account_0" FOREIGN KEY ("gl_account_id") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_journal_entry" ADD CONSTRAINT "fk_acc_gl_journal_entry_0" FOREIGN KEY ("account_id") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_journal_entry" ADD CONSTRAINT "fk_acc_gl_journal_entry_1" FOREIGN KEY ("reversal_id") REFERENCES "fineract_barebones_db"."acc_gl_journal_entry" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_journal_entry" ADD CONSTRAINT "fk_acc_gl_journal_entry_4" FOREIGN KEY ("client_transaction_id") REFERENCES "fineract_barebones_db"."m_client_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_journal_entry" ADD CONSTRAINT "fk_acc_gl_journal_entry_5" FOREIGN KEY ("loan_transaction_id") REFERENCES "fineract_barebones_db"."m_loan_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_journal_entry" ADD CONSTRAINT "fk_acc_gl_journal_entry_6" FOREIGN KEY ("office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_journal_entry" ADD CONSTRAINT "fk_acc_gl_journal_entry_7" FOREIGN KEY ("payment_details_id") REFERENCES "fineract_barebones_db"."m_payment_detail" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_journal_entry" ADD CONSTRAINT "fk_acc_gl_journal_entry_8" FOREIGN KEY ("savings_transaction_id") REFERENCES "fineract_barebones_db"."m_savings_account_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_gl_journal_entry" ADD CONSTRAINT "fk_acc_gl_journal_entry_9" FOREIGN KEY ("share_transaction_id") REFERENCES "fineract_barebones_db"."m_share_account_transactions" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_product_mapping" ADD CONSTRAINT "fk_acc_product_mapping_0" FOREIGN KEY ("charge_id") REFERENCES "fineract_barebones_db"."m_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_product_mapping" ADD CONSTRAINT "fk_acc_product_mapping_1" FOREIGN KEY ("payment_type") REFERENCES "fineract_barebones_db"."m_payment_type" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_rule_tags" ADD CONSTRAINT "fk_acc_rule_tags_0" FOREIGN KEY ("acc_rule_id") REFERENCES "fineract_barebones_db"."acc_accounting_rule" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."acc_rule_tags" ADD CONSTRAINT "fk_acc_rule_tags_1" FOREIGN KEY ("tag_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."c_external_service_properties" ADD CONSTRAINT "fk_c_external_service_properties_0" FOREIGN KEY ("external_service_id") REFERENCES "fineract_barebones_db"."c_external_service" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."job_run_history" ADD CONSTRAINT "fk_job_run_history_0" FOREIGN KEY ("job_id") REFERENCES "fineract_barebones_db"."job" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_details" ADD CONSTRAINT "fk_m_account_transfer_details_0" FOREIGN KEY ("from_client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_details" ADD CONSTRAINT "fk_m_account_transfer_details_2" FOREIGN KEY ("from_office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_details" ADD CONSTRAINT "fk_m_account_transfer_details_3" FOREIGN KEY ("from_savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_details" ADD CONSTRAINT "fk_m_account_transfer_details_4" FOREIGN KEY ("to_client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_details" ADD CONSTRAINT "fk_m_account_transfer_details_6" FOREIGN KEY ("to_office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_details" ADD CONSTRAINT "fk_m_account_transfer_details_7" FOREIGN KEY ("to_savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_standing_instructions" ADD CONSTRAINT "fk_m_account_transfer_standing_instructions_0" FOREIGN KEY ("account_transfer_details_id") REFERENCES "fineract_barebones_db"."m_account_transfer_details" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_standing_instructions_history" ADD CONSTRAINT "fk_m_account_transfer_standing_instructions_history_0" FOREIGN KEY ("standing_instruction_id") REFERENCES "fineract_barebones_db"."m_account_transfer_standing_instructions" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_transaction" ADD CONSTRAINT "fk_m_account_transfer_transaction_0" FOREIGN KEY ("account_transfer_details_id") REFERENCES "fineract_barebones_db"."m_account_transfer_details" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_transaction" ADD CONSTRAINT "fk_m_account_transfer_transaction_1" FOREIGN KEY ("from_loan_transaction_id") REFERENCES "fineract_barebones_db"."m_loan_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_transaction" ADD CONSTRAINT "fk_m_account_transfer_transaction_2" FOREIGN KEY ("from_savings_transaction_id") REFERENCES "fineract_barebones_db"."m_savings_account_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_transaction" ADD CONSTRAINT "fk_m_account_transfer_transaction_3" FOREIGN KEY ("to_loan_transaction_id") REFERENCES "fineract_barebones_db"."m_loan_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_account_transfer_transaction" ADD CONSTRAINT "fk_m_account_transfer_transaction_4" FOREIGN KEY ("to_savings_transaction_id") REFERENCES "fineract_barebones_db"."m_savings_account_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_address" ADD CONSTRAINT "fk_m_address_0" FOREIGN KEY ("state_province_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_address" ADD CONSTRAINT "fk_m_address_1" FOREIGN KEY ("country_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_appuser_role" ADD CONSTRAINT "fk_m_appuser_role_0" FOREIGN KEY ("role_id") REFERENCES "fineract_barebones_db"."m_role" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_calendar_history" ADD CONSTRAINT "fk_m_calendar_history_0" FOREIGN KEY ("calendar_id") REFERENCES "fineract_barebones_db"."m_calendar" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_calendar_instance" ADD CONSTRAINT "fk_m_calendar_instance_0" FOREIGN KEY ("calendar_id") REFERENCES "fineract_barebones_db"."m_calendar" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_cashier_transactions" ADD CONSTRAINT "fk_m_cashier_transactions_0" FOREIGN KEY ("cashier_id") REFERENCES "fineract_barebones_db"."m_cashiers" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_cashiers" ADD CONSTRAINT "fk_m_cashiers_0" FOREIGN KEY ("staff_id") REFERENCES "fineract_barebones_db"."m_staff" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_cashiers" ADD CONSTRAINT "fk_m_cashiers_1" FOREIGN KEY ("teller_id") REFERENCES "fineract_barebones_db"."m_tellers" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_charge" ADD CONSTRAINT "fk_m_charge_0" FOREIGN KEY ("income_or_liability_account_id") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_charge" ADD CONSTRAINT "fk_m_charge_1" FOREIGN KEY ("tax_group_id") REFERENCES "fineract_barebones_db"."m_tax_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_0" FOREIGN KEY ("gender_cv_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_1" FOREIGN KEY ("office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_10" FOREIGN KEY ("client_type_cv_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_11" FOREIGN KEY ("withdraw_reason_cv_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_12" FOREIGN KEY ("reject_reason_cv_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_2" FOREIGN KEY ("client_classification_cv_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_3" FOREIGN KEY ("closure_reason_cv_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_4" FOREIGN KEY ("image_id") REFERENCES "fineract_barebones_db"."m_image" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_5" FOREIGN KEY ("transfer_to_office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_6" FOREIGN KEY ("default_savings_account") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_7" FOREIGN KEY ("default_savings_product") REFERENCES "fineract_barebones_db"."m_savings_product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_8" FOREIGN KEY ("staff_id") REFERENCES "fineract_barebones_db"."m_staff" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client" ADD CONSTRAINT "fk_m_client_9" FOREIGN KEY ("sub_status") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_address" ADD CONSTRAINT "fk_m_client_address_0" FOREIGN KEY ("address_type_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_address" ADD CONSTRAINT "fk_m_client_address_1" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_attendance" ADD CONSTRAINT "fk_m_client_attendance_0" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_attendance" ADD CONSTRAINT "fk_m_client_attendance_1" FOREIGN KEY ("meeting_id") REFERENCES "fineract_barebones_db"."m_meeting" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_charge" ADD CONSTRAINT "fk_m_client_charge_0" FOREIGN KEY ("charge_id") REFERENCES "fineract_barebones_db"."m_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_charge" ADD CONSTRAINT "fk_m_client_charge_1" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_charge_paid_by" ADD CONSTRAINT "fk_m_client_charge_paid_by_0" FOREIGN KEY ("client_charge_id") REFERENCES "fineract_barebones_db"."m_client_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_charge_paid_by" ADD CONSTRAINT "fk_m_client_charge_paid_by_1" FOREIGN KEY ("client_transaction_id") REFERENCES "fineract_barebones_db"."m_client_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_identifier" ADD CONSTRAINT "fk_m_client_identifier_0" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_identifier" ADD CONSTRAINT "fk_m_client_identifier_1" FOREIGN KEY ("document_type_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_non_person" ADD CONSTRAINT "fk_m_client_non_person_0" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_client_transaction" ADD CONSTRAINT "fk_m_client_transaction_1" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_code_value" ADD CONSTRAINT "fk_m_code_value_0" FOREIGN KEY ("code_id") REFERENCES "fineract_barebones_db"."m_code" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_deposit_account_on_hold_transaction" ADD CONSTRAINT "fk_m_deposit_account_on_hold_transaction_0" FOREIGN KEY ("savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_deposit_account_recurring_detail" ADD CONSTRAINT "fk_m_deposit_account_recurring_detail_0" FOREIGN KEY ("savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_deposit_account_term_and_preclosure" ADD CONSTRAINT "fk_m_deposit_account_term_and_preclosure_0" FOREIGN KEY ("savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_deposit_product_interest_rate_chart" ADD CONSTRAINT "fk_m_deposit_product_interest_rate_chart_0" FOREIGN KEY ("deposit_product_id") REFERENCES "fineract_barebones_db"."m_savings_product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_deposit_product_interest_rate_chart" ADD CONSTRAINT "fk_m_deposit_product_interest_rate_chart_1" FOREIGN KEY ("interest_rate_chart_id") REFERENCES "fineract_barebones_db"."m_interest_rate_chart" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_deposit_product_recurring_detail" ADD CONSTRAINT "fk_m_deposit_product_recurring_detail_0" FOREIGN KEY ("savings_product_id") REFERENCES "fineract_barebones_db"."m_savings_product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_deposit_product_term_and_preclosure" ADD CONSTRAINT "fk_m_deposit_product_term_and_preclosure_0" FOREIGN KEY ("savings_product_id") REFERENCES "fineract_barebones_db"."m_savings_product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_entity_datatable_check" ADD CONSTRAINT "fk_m_entity_datatable_check_0" FOREIGN KEY ("x_registered_table_name") REFERENCES "fineract_barebones_db"."x_registered_table" ("registered_table_name") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_entity_to_entity_access" ADD CONSTRAINT "fk_m_entity_to_entity_access_0" FOREIGN KEY ("access_type_code_value_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_entity_to_entity_mapping" ADD CONSTRAINT "fk_m_entity_to_entity_mapping_0" FOREIGN KEY ("rel_id") REFERENCES "fineract_barebones_db"."m_entity_relation" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_group" ADD CONSTRAINT "fk_m_group_0" FOREIGN KEY ("level_id") REFERENCES "fineract_barebones_db"."m_group_level" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_group" ADD CONSTRAINT "fk_m_group_1" FOREIGN KEY ("closure_reason_cv_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_group" ADD CONSTRAINT "fk_m_group_2" FOREIGN KEY ("staff_id") REFERENCES "fineract_barebones_db"."m_staff" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_group" ADD CONSTRAINT "fk_m_group_3" FOREIGN KEY ("parent_id") REFERENCES "fineract_barebones_db"."m_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_group" ADD CONSTRAINT "fk_m_group_4" FOREIGN KEY ("office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_group_client" ADD CONSTRAINT "fk_m_group_client_0" FOREIGN KEY ("group_id") REFERENCES "fineract_barebones_db"."m_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_group_client" ADD CONSTRAINT "fk_m_group_client_1" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_group_level" ADD CONSTRAINT "fk_m_group_level_0" FOREIGN KEY ("parent_id") REFERENCES "fineract_barebones_db"."m_group_level" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_group_roles" ADD CONSTRAINT "fk_m_group_roles_0" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_group_roles" ADD CONSTRAINT "fk_m_group_roles_1" FOREIGN KEY ("group_id") REFERENCES "fineract_barebones_db"."m_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_group_roles" ADD CONSTRAINT "fk_m_group_roles_2" FOREIGN KEY ("role_cv_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_guarantor" ADD CONSTRAINT "fk_m_guarantor_0" FOREIGN KEY ("client_reln_cv_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_guarantor_funding_details" ADD CONSTRAINT "fk_m_guarantor_funding_details_0" FOREIGN KEY ("account_associations_id") REFERENCES "fineract_barebones_db"."m_portfolio_account_associations" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_guarantor_funding_details" ADD CONSTRAINT "fk_m_guarantor_funding_details_1" FOREIGN KEY ("guarantor_id") REFERENCES "fineract_barebones_db"."m_guarantor" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_guarantor_transaction" ADD CONSTRAINT "fk_m_guarantor_transaction_0" FOREIGN KEY ("guarantor_fund_detail_id") REFERENCES "fineract_barebones_db"."m_guarantor_funding_details" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_guarantor_transaction" ADD CONSTRAINT "fk_m_guarantor_transaction_1" FOREIGN KEY ("deposit_on_hold_transaction_id") REFERENCES "fineract_barebones_db"."m_deposit_account_on_hold_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_guarantor_transaction" ADD CONSTRAINT "fk_m_guarantor_transaction_2" FOREIGN KEY ("loan_transaction_id") REFERENCES "fineract_barebones_db"."m_loan_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_holiday_office" ADD CONSTRAINT "fk_m_holiday_office_0" FOREIGN KEY ("holiday_id") REFERENCES "fineract_barebones_db"."m_holiday" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_holiday_office" ADD CONSTRAINT "fk_m_holiday_office_1" FOREIGN KEY ("office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_hook" ADD CONSTRAINT "fk_m_hook_0" FOREIGN KEY ("template_id") REFERENCES "fineract_barebones_db"."m_hook_templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_hook" ADD CONSTRAINT "fk_m_hook_1" FOREIGN KEY ("ugd_template_id") REFERENCES "fineract_barebones_db"."m_template" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_hook_configuration" ADD CONSTRAINT "fk_m_hook_configuration_0" FOREIGN KEY ("hook_id") REFERENCES "fineract_barebones_db"."m_hook" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_hook_registered_events" ADD CONSTRAINT "fk_m_hook_registered_events_0" FOREIGN KEY ("hook_id") REFERENCES "fineract_barebones_db"."m_hook" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_hook_schema" ADD CONSTRAINT "fk_m_hook_schema_0" FOREIGN KEY ("hook_template_id") REFERENCES "fineract_barebones_db"."m_hook_templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_interest_incentives" ADD CONSTRAINT "fk_m_interest_incentives_0" FOREIGN KEY ("interest_rate_slab_id") REFERENCES "fineract_barebones_db"."m_interest_rate_slab" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_interest_rate_slab" ADD CONSTRAINT "fk_m_interest_rate_slab_0" FOREIGN KEY ("interest_rate_chart_id") REFERENCES "fineract_barebones_db"."m_interest_rate_chart" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_charge" ADD CONSTRAINT "fk_m_loan_charge_0" FOREIGN KEY ("charge_id") REFERENCES "fineract_barebones_db"."m_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_charge_paid_by" ADD CONSTRAINT "fk_m_loan_charge_paid_by_0" FOREIGN KEY ("loan_charge_id") REFERENCES "fineract_barebones_db"."m_loan_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_charge_paid_by" ADD CONSTRAINT "fk_m_loan_charge_paid_by_1" FOREIGN KEY ("loan_transaction_id") REFERENCES "fineract_barebones_db"."m_loan_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_collateral" ADD CONSTRAINT "fk_m_loan_collateral_0" FOREIGN KEY ("type_cv_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_installment_charge" ADD CONSTRAINT "fk_m_loan_installment_charge_0" FOREIGN KEY ("loan_charge_id") REFERENCES "fineract_barebones_db"."m_loan_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_installment_charge" ADD CONSTRAINT "fk_m_loan_installment_charge_1" FOREIGN KEY ("loan_schedule_id") REFERENCES "fineract_barebones_db"."m_loan_repayment_schedule" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_interest_recalculation_additional_details" ADD CONSTRAINT "fk_m_loan_interest_recalculation_additional_details_0" FOREIGN KEY ("loan_repayment_schedule_id") REFERENCES "fineract_barebones_db"."m_loan_repayment_schedule" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_officer_assignment_history" ADD CONSTRAINT "fk_m_loan_officer_assignment_history_1" FOREIGN KEY ("loan_officer_id") REFERENCES "fineract_barebones_db"."m_staff" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_overdue_installment_charge" ADD CONSTRAINT "fk_m_loan_overdue_installment_charge_0" FOREIGN KEY ("loan_charge_id") REFERENCES "fineract_barebones_db"."m_loan_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_overdue_installment_charge" ADD CONSTRAINT "fk_m_loan_overdue_installment_charge_1" FOREIGN KEY ("loan_schedule_id") REFERENCES "fineract_barebones_db"."m_loan_repayment_schedule" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_repayment_schedule_history" ADD CONSTRAINT "fk_m_loan_repayment_schedule_history_1" FOREIGN KEY ("loan_reschedule_request_id") REFERENCES "fineract_barebones_db"."m_loan_reschedule_request" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_reschedule_request" ADD CONSTRAINT "fk_m_loan_reschedule_request_1" FOREIGN KEY ("reschedule_reason_cv_id") REFERENCES "fineract_barebones_db"."m_code_value" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_reschedule_request_term_variations_mapping" ADD CONSTRAINT "fk_m_loan_reschedule_request_term_variations_mapping_0" FOREIGN KEY ("loan_reschedule_request_id") REFERENCES "fineract_barebones_db"."m_loan_reschedule_request" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_reschedule_request_term_variations_mapping" ADD CONSTRAINT "fk_m_loan_reschedule_request_term_variations_mapping_1" FOREIGN KEY ("loan_term_variations_id") REFERENCES "fineract_barebones_db"."m_loan_term_variations" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_topup" ADD CONSTRAINT "fk_m_loan_topup_0" FOREIGN KEY ("account_transfer_details_id") REFERENCES "fineract_barebones_db"."m_account_transfer_details" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_tranche_charges" ADD CONSTRAINT "fk_m_loan_tranche_charges_0" FOREIGN KEY ("charge_id") REFERENCES "fineract_barebones_db"."m_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_tranche_disbursement_charge" ADD CONSTRAINT "fk_m_loan_tranche_disbursement_charge_0" FOREIGN KEY ("loan_charge_id") REFERENCES "fineract_barebones_db"."m_loan_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_tranche_disbursement_charge" ADD CONSTRAINT "fk_m_loan_tranche_disbursement_charge_1" FOREIGN KEY ("disbursement_detail_id") REFERENCES "fineract_barebones_db"."m_loan_disbursement_detail" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_transaction" ADD CONSTRAINT "fk_m_loan_transaction_1" FOREIGN KEY ("office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_transaction" ADD CONSTRAINT "fk_m_loan_transaction_2" FOREIGN KEY ("payment_detail_id") REFERENCES "fineract_barebones_db"."m_payment_detail" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_transaction_repayment_schedule_mapping" ADD CONSTRAINT "fk_m_loan_transaction_repayment_schedule_mapping_0" FOREIGN KEY ("loan_repayment_schedule_id") REFERENCES "fineract_barebones_db"."m_loan_repayment_schedule" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loan_transaction_repayment_schedule_mapping" ADD CONSTRAINT "fk_m_loan_transaction_repayment_schedule_mapping_1" FOREIGN KEY ("loan_transaction_id") REFERENCES "fineract_barebones_db"."m_loan_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loanproduct_provisioning_entry" ADD CONSTRAINT "fk_m_loanproduct_provisioning_entry_1" FOREIGN KEY ("criteria_id") REFERENCES "fineract_barebones_db"."m_provisioning_criteria" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loanproduct_provisioning_entry" ADD CONSTRAINT "fk_m_loanproduct_provisioning_entry_2" FOREIGN KEY ("currency_code") REFERENCES "fineract_barebones_db"."m_currency" ("code") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loanproduct_provisioning_entry" ADD CONSTRAINT "fk_m_loanproduct_provisioning_entry_3" FOREIGN KEY ("office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loanproduct_provisioning_entry" ADD CONSTRAINT "fk_m_loanproduct_provisioning_entry_5" FOREIGN KEY ("category_id") REFERENCES "fineract_barebones_db"."m_provision_category" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loanproduct_provisioning_entry" ADD CONSTRAINT "fk_m_loanproduct_provisioning_entry_6" FOREIGN KEY ("liability_account") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loanproduct_provisioning_entry" ADD CONSTRAINT "fk_m_loanproduct_provisioning_entry_7" FOREIGN KEY ("expense_account") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_loanproduct_provisioning_mapping" ADD CONSTRAINT "fk_m_loanproduct_provisioning_mapping_1" FOREIGN KEY ("criteria_id") REFERENCES "fineract_barebones_db"."m_provisioning_criteria" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_mandatory_savings_schedule" ADD CONSTRAINT "fk_m_mandatory_savings_schedule_0" FOREIGN KEY ("savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_meeting" ADD CONSTRAINT "fk_m_meeting_0" FOREIGN KEY ("calendar_instance_id") REFERENCES "fineract_barebones_db"."m_calendar_instance" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_note" ADD CONSTRAINT "fk_m_note_0" FOREIGN KEY ("loan_transaction_id") REFERENCES "fineract_barebones_db"."m_loan_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_note" ADD CONSTRAINT "fk_m_note_3" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_note" ADD CONSTRAINT "fk_m_note_5" FOREIGN KEY ("group_id") REFERENCES "fineract_barebones_db"."m_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_note" ADD CONSTRAINT "fk_m_note_6" FOREIGN KEY ("savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_office" ADD CONSTRAINT "fk_m_office_0" FOREIGN KEY ("parent_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_office_transaction" ADD CONSTRAINT "fk_m_office_transaction_0" FOREIGN KEY ("from_office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_office_transaction" ADD CONSTRAINT "fk_m_office_transaction_1" FOREIGN KEY ("to_office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_payment_detail" ADD CONSTRAINT "fk_m_payment_detail_0" FOREIGN KEY ("payment_type_id") REFERENCES "fineract_barebones_db"."m_payment_type" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_portfolio_account_associations" ADD CONSTRAINT "fk_m_portfolio_account_associations_1" FOREIGN KEY ("savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_portfolio_account_associations" ADD CONSTRAINT "fk_m_portfolio_account_associations_3" FOREIGN KEY ("linked_savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_product_loan_charge" ADD CONSTRAINT "fk_m_product_loan_charge_0" FOREIGN KEY ("charge_id") REFERENCES "fineract_barebones_db"."m_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_provisioning_criteria_definition" ADD CONSTRAINT "fk_m_provisioning_criteria_definition_0" FOREIGN KEY ("criteria_id") REFERENCES "fineract_barebones_db"."m_provisioning_criteria" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_provisioning_criteria_definition" ADD CONSTRAINT "fk_m_provisioning_criteria_definition_1" FOREIGN KEY ("category_id") REFERENCES "fineract_barebones_db"."m_provision_category" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_provisioning_criteria_definition" ADD CONSTRAINT "fk_m_provisioning_criteria_definition_2" FOREIGN KEY ("liability_account") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_provisioning_criteria_definition" ADD CONSTRAINT "fk_m_provisioning_criteria_definition_3" FOREIGN KEY ("expense_account") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_report_mailing_job" ADD CONSTRAINT "fk_m_report_mailing_job_2" FOREIGN KEY ("stretchy_report_id") REFERENCES "fineract_barebones_db"."stretchy_report" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_report_mailing_job_run_history" ADD CONSTRAINT "fk_m_report_mailing_job_run_history_0" FOREIGN KEY ("job_id") REFERENCES "fineract_barebones_db"."m_report_mailing_job" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_role_permission" ADD CONSTRAINT "fk_m_role_permission_0" FOREIGN KEY ("permission_id") REFERENCES "fineract_barebones_db"."m_permission" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_role_permission" ADD CONSTRAINT "fk_m_role_permission_1" FOREIGN KEY ("role_id") REFERENCES "fineract_barebones_db"."m_role" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account" ADD CONSTRAINT "fk_m_savings_account_0" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account" ADD CONSTRAINT "fk_m_savings_account_1" FOREIGN KEY ("group_id") REFERENCES "fineract_barebones_db"."m_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account" ADD CONSTRAINT "fk_m_savings_account_2" FOREIGN KEY ("product_id") REFERENCES "fineract_barebones_db"."m_savings_product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account" ADD CONSTRAINT "fk_m_savings_account_3" FOREIGN KEY ("tax_group_id") REFERENCES "fineract_barebones_db"."m_tax_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account_charge" ADD CONSTRAINT "fk_m_savings_account_charge_0" FOREIGN KEY ("charge_id") REFERENCES "fineract_barebones_db"."m_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account_charge" ADD CONSTRAINT "fk_m_savings_account_charge_1" FOREIGN KEY ("savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account_charge_paid_by" ADD CONSTRAINT "fk_m_savings_account_charge_paid_by_0" FOREIGN KEY ("savings_account_charge_id") REFERENCES "fineract_barebones_db"."m_savings_account_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account_charge_paid_by" ADD CONSTRAINT "fk_m_savings_account_charge_paid_by_1" FOREIGN KEY ("savings_account_transaction_id") REFERENCES "fineract_barebones_db"."m_savings_account_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account_interest_rate_chart" ADD CONSTRAINT "fk_m_savings_account_interest_rate_chart_0" FOREIGN KEY ("savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account_interest_rate_slab" ADD CONSTRAINT "fk_m_savings_account_interest_rate_slab_0" FOREIGN KEY ("savings_account_interest_rate_chart_id") REFERENCES "fineract_barebones_db"."m_savings_account_interest_rate_chart" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account_transaction" ADD CONSTRAINT "fk_m_savings_account_transaction_0" FOREIGN KEY ("savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account_transaction" ADD CONSTRAINT "fk_m_savings_account_transaction_1" FOREIGN KEY ("office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account_transaction" ADD CONSTRAINT "fk_m_savings_account_transaction_2" FOREIGN KEY ("payment_detail_id") REFERENCES "fineract_barebones_db"."m_payment_detail" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account_transaction_tax_details" ADD CONSTRAINT "fk_m_savings_account_transaction_tax_details_0" FOREIGN KEY ("savings_transaction_id") REFERENCES "fineract_barebones_db"."m_savings_account_transaction" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_account_transaction_tax_details" ADD CONSTRAINT "fk_m_savings_account_transaction_tax_details_1" FOREIGN KEY ("tax_component_id") REFERENCES "fineract_barebones_db"."m_tax_component" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_interest_incentives" ADD CONSTRAINT "fk_m_savings_interest_incentives_0" FOREIGN KEY ("deposit_account_interest_rate_slab_id") REFERENCES "fineract_barebones_db"."m_savings_account_interest_rate_slab" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_officer_assignment_history" ADD CONSTRAINT "fk_m_savings_officer_assignment_history_0" FOREIGN KEY ("account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_officer_assignment_history" ADD CONSTRAINT "fk_m_savings_officer_assignment_history_1" FOREIGN KEY ("savings_officer_id") REFERENCES "fineract_barebones_db"."m_staff" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_product" ADD CONSTRAINT "fk_m_savings_product_0" FOREIGN KEY ("tax_group_id") REFERENCES "fineract_barebones_db"."m_tax_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_product_charge" ADD CONSTRAINT "fk_m_savings_product_charge_0" FOREIGN KEY ("charge_id") REFERENCES "fineract_barebones_db"."m_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_savings_product_charge" ADD CONSTRAINT "fk_m_savings_product_charge_1" FOREIGN KEY ("savings_product_id") REFERENCES "fineract_barebones_db"."m_savings_product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_selfservice_user_client_mapping" ADD CONSTRAINT "fk_m_selfservice_user_client_mapping_1" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_account" ADD CONSTRAINT "fk_m_share_account_0" FOREIGN KEY ("product_id") REFERENCES "fineract_barebones_db"."m_share_product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_account" ADD CONSTRAINT "fk_m_share_account_1" FOREIGN KEY ("savings_account_id") REFERENCES "fineract_barebones_db"."m_savings_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_account" ADD CONSTRAINT "fk_m_share_account_8" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_account_charge" ADD CONSTRAINT "fk_m_share_account_charge_0" FOREIGN KEY ("charge_id") REFERENCES "fineract_barebones_db"."m_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_account_charge" ADD CONSTRAINT "fk_m_share_account_charge_1" FOREIGN KEY ("account_id") REFERENCES "fineract_barebones_db"."m_share_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_account_charge_paid_by" ADD CONSTRAINT "fk_m_share_account_charge_paid_by_0" FOREIGN KEY ("share_transaction_id") REFERENCES "fineract_barebones_db"."m_share_account_transactions" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_account_charge_paid_by" ADD CONSTRAINT "fk_m_share_account_charge_paid_by_1" FOREIGN KEY ("charge_transaction_id") REFERENCES "fineract_barebones_db"."m_share_account_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_account_dividend_details" ADD CONSTRAINT "fk_m_share_account_dividend_details_0" FOREIGN KEY ("account_id") REFERENCES "fineract_barebones_db"."m_share_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_account_dividend_details" ADD CONSTRAINT "fk_m_share_account_dividend_details_1" FOREIGN KEY ("dividend_pay_out_id") REFERENCES "fineract_barebones_db"."m_share_product_dividend_pay_out" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_account_transactions" ADD CONSTRAINT "fk_m_share_account_transactions_0" FOREIGN KEY ("account_id") REFERENCES "fineract_barebones_db"."m_share_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_product_charge" ADD CONSTRAINT "fk_m_share_product_charge_0" FOREIGN KEY ("charge_id") REFERENCES "fineract_barebones_db"."m_charge" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_product_charge" ADD CONSTRAINT "fk_m_share_product_charge_1" FOREIGN KEY ("product_id") REFERENCES "fineract_barebones_db"."m_share_product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_product_dividend_pay_out" ADD CONSTRAINT "fk_m_share_product_dividend_pay_out_2" FOREIGN KEY ("product_id") REFERENCES "fineract_barebones_db"."m_share_product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_share_product_market_price" ADD CONSTRAINT "fk_m_share_product_market_price_0" FOREIGN KEY ("product_id") REFERENCES "fineract_barebones_db"."m_share_product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_staff" ADD CONSTRAINT "fk_m_staff_0" FOREIGN KEY ("image_id") REFERENCES "fineract_barebones_db"."m_image" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_staff" ADD CONSTRAINT "fk_m_staff_1" FOREIGN KEY ("office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_staff_assignment_history" ADD CONSTRAINT "fk_m_staff_assignment_history_0" FOREIGN KEY ("centre_id") REFERENCES "fineract_barebones_db"."m_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_staff_assignment_history" ADD CONSTRAINT "fk_m_staff_assignment_history_1" FOREIGN KEY ("staff_id") REFERENCES "fineract_barebones_db"."m_staff" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_survey_components" ADD CONSTRAINT "fk_m_survey_components_0" FOREIGN KEY ("survey_id") REFERENCES "fineract_barebones_db"."m_surveys" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_survey_lookup_tables" ADD CONSTRAINT "fk_m_survey_lookup_tables_0" FOREIGN KEY ("survey_id") REFERENCES "fineract_barebones_db"."m_surveys" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_survey_questions" ADD CONSTRAINT "fk_m_survey_questions_0" FOREIGN KEY ("survey_id") REFERENCES "fineract_barebones_db"."m_surveys" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_survey_responses" ADD CONSTRAINT "fk_m_survey_responses_0" FOREIGN KEY ("question_id") REFERENCES "fineract_barebones_db"."m_survey_questions" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_survey_scorecards" ADD CONSTRAINT "fk_m_survey_scorecards_0" FOREIGN KEY ("survey_id") REFERENCES "fineract_barebones_db"."m_surveys" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_survey_scorecards" ADD CONSTRAINT "fk_m_survey_scorecards_1" FOREIGN KEY ("question_id") REFERENCES "fineract_barebones_db"."m_survey_questions" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_survey_scorecards" ADD CONSTRAINT "fk_m_survey_scorecards_2" FOREIGN KEY ("response_id") REFERENCES "fineract_barebones_db"."m_survey_responses" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_survey_scorecards" ADD CONSTRAINT "fk_m_survey_scorecards_4" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_tax_component" ADD CONSTRAINT "fk_m_tax_component_1" FOREIGN KEY ("credit_account_id") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_tax_component" ADD CONSTRAINT "fk_m_tax_component_2" FOREIGN KEY ("debit_account_id") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_tax_component_history" ADD CONSTRAINT "fk_m_tax_component_history_2" FOREIGN KEY ("tax_component_id") REFERENCES "fineract_barebones_db"."m_tax_component" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_tax_group_mappings" ADD CONSTRAINT "fk_m_tax_group_mappings_2" FOREIGN KEY ("tax_component_id") REFERENCES "fineract_barebones_db"."m_tax_component" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_tax_group_mappings" ADD CONSTRAINT "fk_m_tax_group_mappings_3" FOREIGN KEY ("tax_group_id") REFERENCES "fineract_barebones_db"."m_tax_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_tellers" ADD CONSTRAINT "fk_m_tellers_0" FOREIGN KEY ("credit_account_id") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_tellers" ADD CONSTRAINT "fk_m_tellers_1" FOREIGN KEY ("debit_account_id") REFERENCES "fineract_barebones_db"."acc_gl_account" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."m_tellers" ADD CONSTRAINT "fk_m_tellers_2" FOREIGN KEY ("office_id") REFERENCES "fineract_barebones_db"."m_office" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."sms_campaign" ADD CONSTRAINT "fk_sms_campaign_0" FOREIGN KEY ("report_id") REFERENCES "fineract_barebones_db"."stretchy_report" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."sms_messages_outbound" ADD CONSTRAINT "fk_sms_messages_outbound_0" FOREIGN KEY ("campaign_id") REFERENCES "fineract_barebones_db"."sms_campaign" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."sms_messages_outbound" ADD CONSTRAINT "fk_sms_messages_outbound_1" FOREIGN KEY ("client_id") REFERENCES "fineract_barebones_db"."m_client" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."sms_messages_outbound" ADD CONSTRAINT "fk_sms_messages_outbound_2" FOREIGN KEY ("group_id") REFERENCES "fineract_barebones_db"."m_group" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."sms_messages_outbound" ADD CONSTRAINT "fk_sms_messages_outbound_3" FOREIGN KEY ("staff_id") REFERENCES "fineract_barebones_db"."m_staff" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."stretchy_parameter" ADD CONSTRAINT "fk_stretchy_parameter_0" FOREIGN KEY ("parent_id") REFERENCES "fineract_barebones_db"."stretchy_parameter" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."stretchy_report_parameter" ADD CONSTRAINT "fk_stretchy_report_parameter_0" FOREIGN KEY ("report_id") REFERENCES "fineract_barebones_db"."stretchy_report" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."stretchy_report_parameter" ADD CONSTRAINT "fk_stretchy_report_parameter_1" FOREIGN KEY ("parameter_id") REFERENCES "fineract_barebones_db"."stretchy_parameter" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "fineract_barebones_db"."x_table_column_code_mappings" ADD CONSTRAINT "fk_x_table_column_code_mappings_0" FOREIGN KEY ("code_id") REFERENCES "fineract_barebones_db"."m_code" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
