Skip to content

Migrate businesses altered from (BC, ULC,CC) to BEN #27342

Open

Description

@vysakh-menon-aot

These businesses are active in Lear and users are filing new filings in Lear (missing oldest filings)

Find all businesses altered from (BC, ULC, CC, C, CUL, CCC) -> (BEN, CBEN) - (filed through notebook)

-- Query in lear db
select b.identifier, f.*
from public.filings f
	join businesses b on b.id = f.business_id
where
	filing_type='alteration'
	and meta_data->'alteration'->>'fromLegalType' in ('BC', 'ULC', 'CC', 'C', 'CUL', 'CCC')
	and meta_data->'alteration'->>'toLegalType' in ('BEN', 'CBEN')
	and b.id in (
		select b.id from public.filings f
			join businesses b on b.id=f.business_id
		where
			filing_type='lear_epoch'
			and b.legal_type in ('BEN','BC', 'ULC', 'CC', 'CBEN','C', 'CUL', 'CCC')
			and filing_json->'filing'->'business'->>'legalType' <> 'BEN')

Approach to migrate BC -> BEN

Load previous filings with version data (no changes to primary table), while loading transaction_id for the previous filings should be smaller. Lear require previous filings should have smaller transaction_id, which is used to identify the order of filings

  • Option 1: Find all missing transaction ids from the transaction table. (if it takes too long to execute this query then dump the whole missing transaction_id's into a temporary table and use this transaction id to load previous filings)
    -- Query to find missing transaction_id
    SELECT gs.i AS missing_transaction_id
	FROM generate_series(1, <first filing id in the business>) AS gs(i)
	LEFT JOIN public.transaction t ON t.id = gs.i
	WHERE t.id IS NULL and NOT EXISTS (select * from (
		SELECT 'filings' as table_name, count(1) FROM public.filings WHERE transaction_id=gs.i UNION
		SELECT 'addresses' as table_name, count(1) FROM public.addresses_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'aliases' as table_name, count(1) FROM public.aliases_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'amalgamating_businesses' as table_name, count(1) FROM public.amalgamating_businesses_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'amalgamations' as table_name, count(1) FROM public.amalgamations_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'businesses' as table_name, count(1) FROM public.businesses_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'jurisdictions' as table_name, count(1) FROM public.jurisdictions_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'offices_held' as table_name, count(1) FROM public.offices_held_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'offices' as table_name, count(1) FROM public.offices_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'parties' as table_name, count(1) FROM public.parties_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'party_roles' as table_name, count(1) FROM public.party_roles_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'resolutions' as table_name, count(1) FROM public.resolutions_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'share_classes' as table_name, count(1) FROM public.share_classes_version WHERE transaction_id=gs.i or end_transaction_id=gs.i UNION
		SELECT 'share_series' as table_name, count(1) FROM public.share_series_version WHERE transaction_id=gs.i or end_transaction_id=gs.i
	) t2 WHERE count > 0)
	ORDER BY gs.i DESC;

  - Option 2: Update all the existing filing with new transaction id which is greater than the newly loaded filings

Note: Businesses involved in multiple conversion (BC1255957, BC0460007) from BC -> BEN and then BEN -> BC - (Before Directed Launch) - Need to include in both migration scenario

Activity

  1. added
    Entities - Data Migration
    on Apr 23, 2025
  2. changed the title [-]Migrate businesses altered from (BC, ULC,CC) to BEN - Before Directed Launch[/-] [+]Migrate businesses altered from (BC, ULC,CC) to BEN[/+] on Apr 23, 2025
  3. argush3 commented on Apr 24, 2025

    @argush3
    Contributor

    Need decision whether we need to provide the placeholder filings for the filings that were created in COLIN @dylan644

  4. argush3 commented on May 13, 2025

    @argush3
    Contributor

    We can likely migrate this after tombstone migration. @dylan644 will confirm with business.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Entities - Data Migration

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions