Skip to main content

Migration Importer

Bulk-import institution data from the 17-sheet migration template.

Overview

The migration tooling consists of:

  1. institution_migration_template.sql — creates migration.* staging tables (17 sheets)
  2. institution_migration_convert.sql — validates and inserts into live tables
  3. CoreWave_Import_Template.xlsx — human-readable workbook for data collection

Prerequisites

  • Institution must be pre-onboarded via the Admin portal (the migration does NOT create the institution)
  • Base currency (e.g., NGN) must exist in Currencies
  • Interests rows referenced by loan products must be seeded
  • pgcrypto extension must be available (staff password hashing)

Import Flow

  1. Generate the template: python3 generate_import_template.py
  2. Fill the workbook: Institution fills all 17 sheets
  3. Load to staging: Export each sheet to CSV, \copy into migration.* tables
  4. Create staging tables: psql -f institution_migration_template.sql
  5. Run conversion: psql -f institution_migration_convert.sql

Branch Code Mapping

The template uses migration-local branch codes. During sheet 2 import, a migration._branch_map is built (code → ID). All downstream sheets resolve branches through this map.

Export (Live → Template)

python3 export_institution_to_template.py \
--dump "institution_2_MyBank.sql" \
--template "CoreWave_Import_Template.xlsx" \
--out "CoreWave_Import_MyBank.xlsx" \
--institution-name "MyBank"