Skip to content

Shares Hybrid DB Rollout Checklist

Audit date: June 11, 2026

This checklist captures the exact gap between:

  • local backend source of truth in pinkapple-advance
  • deployed runtime routes on staging
  • deployed database objects on stat-solutions-networkDbX

Summary

As of June 11, 2026:

  • share workflow integration is already deployed on the live database
  • share import, share catch-up, share reconciliation, and hybrid distribution HTTP routes are mounted on the deployed staging runtime
  • the hybrid share plus deposit distribution database tranche is still missing on the live database

That means the main remaining deployment work is the hybrid database rollout, not the route wiring.

Local Source Of Truth

The missing live objects already exist locally in pinkapple-advance.

Primary source files:

  • /home/usamaidrsk/dev/stat-solutions/pinkapple-advance/shared/DB/tables/dividend__tables.sql
  • /home/usamaidrsk/dev/stat-solutions/pinkapple-advance/shared/DB/procedures/dividend_procedures.sql
  • /home/usamaidrsk/dev/stat-solutions/pinkapple-advance/shared/DB/seeds/share-flag-catalog.yaml
  • /home/usamaidrsk/dev/stat-solutions/pinkapple-advance/shared/DB/seeds/share-type-default-flag-profile.yaml
  • /home/usamaidrsk/dev/stat-solutions/pinkapple-advance/shared/DB/seeds/permissions.yaml

Relevant local runtime files:

  • /home/usamaidrsk/dev/stat-solutions/pinkapple-advance/app.ts
  • /home/usamaidrsk/dev/stat-solutions/pinkapple-advance/business/shares/import/routes.ts
  • /home/usamaidrsk/dev/stat-solutions/pinkapple-advance/business/shares/import/services/share-import.service.ts
  • /home/usamaidrsk/dev/stat-solutions/pinkapple-advance/business/migration/routes.ts
  • /home/usamaidrsk/dev/stat-solutions/pinkapple-advance/business/migration/services/migration-catchup.service.ts
  • /home/usamaidrsk/dev/stat-solutions/pinkapple-advance/business/migration/services/migration-reconciliation.service.ts

What Is Already Live

Workflow DB Objects

The following workflow templates are already present on the live database:

  • SHARE.ACCOUNT.ONBOARDING
  • SHARE.WITHDRAWAL.REQUEST
  • SHARE.DIVIDEND.EVENT

Observed live workflow counts:

  • SHARE.ACCOUNT.ONBOARDING: 6 stages, 5 transitions
  • SHARE.WITHDRAWAL.REQUEST: 6 stages, 5 transitions
  • SHARE.DIVIDEND.EVENT: 7 stages, 6 transitions

Observed live workflow instance usage:

  • SHARE_ACCOUNT: 1 instance
  • DIVIDEND_EVENT: 2 instances
  • SHARE_WITHDRAWAL_REQUEST: 0 instances

Workflow State Exposure

The live retrieval procedures already expose workflow fields:

  • get_share_accounts
  • get_share_withdrawal_requests
  • get_dividend_events

Migration Runtime Prerequisites

The live database already contains:

  • IMPORT_SHARE_ACCOUNTS
  • MIGRATION_OPENING_BALANCE_CONTRA

Deployed Runtime Routes

The following staging endpoints returned 401 Unauthorized rather than 404, which confirms the routes are mounted:

  • POST /api/shares/import/template
  • POST /api/migration/catchup/share/validate
  • GET /api/migration/reconciliation/shares
  • GET /api/shares/operations/dividends/member-distribution-runs

What Is Still Missing On The Live DB

1. Hybrid Table DDL

Missing hybrid tables:

  • member_distribution_policy
  • member_distribution_run
  • member_distribution_segment
  • member_distribution_allocation

These are defined locally in:

  • shared/DB/tables/dividend__tables.sql at the member_distribution_* table section

The same local file also extends dividend_event.calculation_basis to include:

  • HYBRID_SHARE_DEPOSIT_DAYS

See:

  • shared/DB/tables/dividend__tables.sql at the dividend_event.calculation_basis definition

2. Hybrid Procedures

Missing hybrid procedures:

  • get_member_distribution_policies
  • upsert_member_distribution_policy
  • sync_member_distribution_run_to_dividend_allocations
  • create_member_distribution_run
  • get_member_distribution_runs
  • get_member_distribution_run_allocations
  • get_member_distribution_run_segments
  • post_member_distribution_run

These are defined locally in:

  • shared/DB/procedures/dividend_procedures.sql at the member distribution procedure section

3. Updated Dividend Procedures

The live DB still has the older dividend procedures. It does not yet contain hybrid-aware logic inside:

  • declare_dividend_event
  • get_dividend_events
  • calculate_dividend_allocations
  • process_dividend_payments

The local hybrid-aware versions are in:

  • shared/DB/procedures/dividend_procedures.sql at the hybrid-aware dividend procedure section

4. Share Flag Catalog Update

Live DIVIDEND_COMPUTATION_METHOD still stops at HYBRID.

It must include:

  • HYBRID_SHARE_DEPOSIT_DAYS

Local source:

  • shared/DB/seeds/share-flag-catalog.yaml at the DIVIDEND_COMPUTATION_METHOD flag entry

5. Share Type Default Profile Update

Live PREFERENCE_SHARES / PREFERENCE_PARTICIPATING still defaults to:

  • "HYBRID"

It must be updated to:

  • "HYBRID_SHARE_DEPOSIT_DAYS"

Local source:

  • shared/DB/seeds/share-type-default-flag-profile.yaml at the PREFERENCE_SHARES / PREFERENCE_PARTICIPATING default entry

6. Hybrid Permissions

Missing live permissions:

  • VIEW_MEMBER_DISTRIBUTION_POLICY
  • MANAGE_MEMBER_DISTRIBUTION_POLICY
  • VIEW_MEMBER_DISTRIBUTION_RUN
  • CREATE_MEMBER_DISTRIBUTION_RUN
  • POST_MEMBER_DISTRIBUTION_RUN

Local source:

  • shared/DB/seeds/permissions.yaml at the member distribution permission entries

Apply in this order:

  1. Back up the live database objects related to dividends and permissions.
  2. Apply table DDL from dividend__tables.sql.
  3. Refresh dividend procedures from dividend_procedures.sql.
  4. Apply seed updates for:
    • share_flag_catalog
    • share_type_default_flag_profile
    • permission
  5. Regenerate or reapply any permission cache / auth bootstrap layer if your deployment process uses one.
  6. Run the verification SQL below.
  7. Smoke test the hybrid runtime endpoints with an authenticated request.

Verification SQL

A. Hybrid Table Presence

sql
SELECT TABLE_NAME
FROM information_schema.tables
WHERE table_schema = 'stat-solutions-networkDbX'
  AND TABLE_NAME IN (
    'member_distribution_policy',
    'member_distribution_run',
    'member_distribution_segment',
    'member_distribution_allocation'
  )
ORDER BY TABLE_NAME;

Expected: 4 rows.

B. Hybrid Procedure Presence

sql
SELECT ROUTINE_NAME
FROM information_schema.routines
WHERE routine_schema = 'stat-solutions-networkDbX'
  AND ROUTINE_NAME IN (
    'get_member_distribution_policies',
    'upsert_member_distribution_policy',
    'sync_member_distribution_run_to_dividend_allocations',
    'create_member_distribution_run',
    'get_member_distribution_runs',
    'get_member_distribution_run_allocations',
    'get_member_distribution_run_segments',
    'post_member_distribution_run'
  )
ORDER BY ROUTINE_NAME;

Expected: 8 rows.

C. Dividend Event Calculation Basis

sql
SELECT COLUMN_TYPE
FROM information_schema.columns
WHERE table_schema = 'stat-solutions-networkDbX'
  AND table_name = 'dividend_event'
  AND column_name = 'calculation_basis';

Expected: includes HYBRID_SHARE_DEPOSIT_DAYS.

D. Dividend Computation Method Seed

sql
SELECT flag_code, allowed_values_json
FROM share_flag_catalog
WHERE flag_code = 'DIVIDEND_COMPUTATION_METHOD';

Expected: allowed_values_json includes HYBRID_SHARE_DEPOSIT_DAYS.

E. Participating Preference Share Default

sql
SELECT profile.product_group, profile.product_type, profile.flag_value_json
FROM share_type_default_flag_profile profile
JOIN share_flag_catalog flag
  ON flag.share_flag_id = profile.share_flag_id
WHERE flag.flag_code = 'DIVIDEND_COMPUTATION_METHOD'
  AND profile.product_group = 'PREFERENCE_SHARES'
  AND profile.product_type = 'PREFERENCE_PARTICIPATING';

Expected: flag_value_json = "HYBRID_SHARE_DEPOSIT_DAYS".

F. Hybrid Permission Rows

sql
SELECT permissions_name
FROM permission
WHERE permissions_name IN (
  'VIEW_MEMBER_DISTRIBUTION_POLICY',
  'MANAGE_MEMBER_DISTRIBUTION_POLICY',
  'VIEW_MEMBER_DISTRIBUTION_RUN',
  'CREATE_MEMBER_DISTRIBUTION_RUN',
  'POST_MEMBER_DISTRIBUTION_RUN'
)
ORDER BY permissions_name;

Expected: 5 rows.

G. Workflow Templates Still Present

sql
SELECT template_code, template_name, status, version
FROM workflow_template
WHERE template_code IN (
  'SHARE.ACCOUNT.ONBOARDING',
  'SHARE.WITHDRAWAL.REQUEST',
  'SHARE.DIVIDEND.EVENT'
)
ORDER BY template_code;

Expected: 3 rows, all ACTIVE.

H. Runtime Prerequisites For Share Import

sql
SELECT permissions_name
FROM permission
WHERE permissions_name = 'IMPORT_SHARE_ACCOUNTS';

SELECT tag_key
FROM sys_tag
WHERE tag_key = 'MIGRATION_OPENING_BALANCE_CONTRA';

Expected: both rows exist.

Runtime Smoke Checks

The staging runtime already proved the routes are mounted by returning 401 without auth. After DB deployment, run the same probes with a valid token and company alias:

bash
curl -i -X POST https://app.staging.pinkapple-erp.com/api/shares/import/template
curl -i -X POST https://app.staging.pinkapple-erp.com/api/migration/catchup/share/validate
curl -i https://app.staging.pinkapple-erp.com/api/migration/reconciliation/shares
curl -i https://app.staging.pinkapple-erp.com/api/shares/operations/dividends/member-distribution-runs

Expected after authentication:

  • no 404
  • no SQL object missing errors
  • hybrid distribution endpoints should proceed to normal auth and business validation

Important Interpretation

The current drift is not “feature absent everywhere.”

The actual state is:

  • routes are deployed
  • workflow DB objects are deployed
  • hybrid DB objects are not deployed

So the highest-priority remaining item is the hybrid database rollout, not another frontend or route registration change.

PinkApple ERP by Stat Solutions Network