Why are we doing this?
We are making these changes to:- Improve performance by populating the existing
organization_id
field on fees for historical data, which will optimize database queries - Enable new features by adding
billing_entity_id
to fees, which will support upcoming functionality
What are the changes?
1. Populating organization_id
on fees
While the organization_id
field already exists on fees, we need to populate it for historical data to improve query performance and prepare for upcoming features. This change requires a data migration to populate the field for existing fees.
2. Adding billing_entity_id
to fees
We’re introducing the billing_entity_id
field to fees to support new features in the pipeline. This change also requires a data migration to populate the field for existing fees.
What should self-hosted users do?
Cloud users do not need to follow these instructions, as the migration will be performed by the Lago Team.
If you’re upgrading to v1.25.0, you must complete all the migration steps below to ensure data consistency and proper functionality.If you’re upgrading to v1.25.1 or newer, you must first:
- Upgrade to v1.25.0
- Complete all the migration steps below
- Only then proceed with upgrading to v1.25.1 or newer
Migration Steps
- Install the new version of Lago (v1.25.0)
-
Open the Rails console on your API server:
-
Run the following commands in sequence:
a. Populate organization_id from invoices:All fees are processed in background jobs, with 1000 fees per batch. You can monitor the progress in the Sidekiq console by checking the batch number argument in the job details.Wait for all jobs in Sidekiq to be executed.You can verify that the job is fully executed by running:Expected processing speed is at least 15 minutes per 1M fees. The actual time may vary depending on your system’s resources and database size.This should return 0 when all fees have been processed. b. Populate organization_id from subscriptions:Wait for all jobs in Sidekiq to be executed.You can verify that the job is fully executed by running:Expected processing speed is at least 20 minutes per 1M fees. The actual time may vary depending on your system’s resources and database size.This should return 0 when all fees have been processed. c. Verify that all fees have organization_id:This should return 0. d. Populate billing_entity_id:Wait for all jobs in Sidekiq to be executed.e. Verify that all fees have billing_entity_id:Expected processing speed is at least 15 minutes per 1M fees. The actual time may vary depending on your system’s resources and database size.This should return 0.