-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DynamicPricing) - Add precise_total_amount_cents to Event (#2594)
## Context AI, CPaaS and Fintech customers can apply a price to a unit that fluctuates over time. Currently Lago does not support this usecase. ## Description Adds `precise_total_amount_cents` to Event. Includes an index similar to the one added recently for quick calculations
- Loading branch information
Showing
4 changed files
with
39 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
db/migrate/20240917144243_add_precise_total_amount_cents_to_event.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddPreciseTotalAmountCentsToEvent < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :events, :precise_total_amount_cents, :decimal, precision: 40, scale: 15 | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
db/migrate/20240917145042_add_index_on_precise_total_amount_cents.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddIndexOnPreciseTotalAmountCents < ActiveRecord::Migration[7.1] | ||
disable_ddl_transaction! | ||
def change | ||
add_index :events, %i[external_subscription_id code timestamp], | ||
name: 'index_events_on_external_subscription_id_precise_amount', | ||
where: 'deleted_at IS NULL AND precise_total_amount_cents IS NOT NULL', | ||
algorithm: :concurrently, | ||
if_not_exists: true, | ||
include: %i[organization_id precise_total_amount_cents] | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.