Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DynamicPricing) - Add precise_total_amount_cents to Event #2594

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,28 @@ def subscription
#
# Table name: events
#
# id :uuid not null, primary key
# code :string not null
# deleted_at :datetime
# metadata :jsonb not null
# properties :jsonb not null
# timestamp :datetime
# created_at :datetime not null
# updated_at :datetime not null
# customer_id :uuid
# external_customer_id :string
# external_subscription_id :string
# organization_id :uuid not null
# subscription_id :uuid
# transaction_id :string not null
# id :uuid not null, primary key
# code :string not null
# deleted_at :datetime
# metadata :jsonb not null
# precise_total_amount_cents :decimal(40, 15)
# properties :jsonb not null
# timestamp :datetime
# created_at :datetime not null
# updated_at :datetime not null
# customer_id :uuid
# external_customer_id :string
# external_subscription_id :string
# organization_id :uuid not null
# subscription_id :uuid
# transaction_id :string not null
#
# Indexes
#
# index_events_on_customer_id (customer_id)
# index_events_on_deleted_at (deleted_at)
# index_events_on_external_subscription_id_and_code_and_timestamp (organization_id,external_subscription_id,code,timestamp) WHERE (deleted_at IS NULL)
# index_events_on_external_subscription_id_precise_amount (external_subscription_id,code,timestamp) WHERE ((deleted_at IS NULL) AND (precise_total_amount_cents IS NOT NULL))
# index_events_on_external_subscription_id_with_included (external_subscription_id,code,timestamp) WHERE (deleted_at IS NULL)
# index_events_on_organization_id (organization_id)
# index_events_on_organization_id_and_code (organization_id,code)
Expand Down
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
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
4 changes: 3 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading