Skip to content

Commit

Permalink
misc(devex) - Add annotations to model files (#2349)
Browse files Browse the repository at this point in the history
## Description

Add annotations to model files and setup Rails to automatically annotate
when running a migration.
  • Loading branch information
nudded authored Aug 20, 2024
1 parent ed0daa1 commit abd7434
Show file tree
Hide file tree
Showing 91 changed files with 2,427 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ group :development do
gem 'rubocop-thread_safety', require: false
gem "standard", require: false

gem 'annotate'

gem 'sass-rails'
gem 'uglifier'

Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ GEM
activerecord (>= 4.2)
activesupport
analytics-ruby (2.4.0)
annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
ast (2.4.2)
awesome_print (1.9.2)
aws-eventstream (1.2.0)
Expand Down Expand Up @@ -871,6 +874,7 @@ DEPENDENCIES
adyen-ruby-api-library
after_commit_everywhere
analytics-ruby (~> 2.4.0)
annotate
awesome_print
aws-sdk-s3
bcrypt
Expand Down
27 changes: 27 additions & 0 deletions app/models/add_on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,30 @@ def invoice_name
invoice_display_name.presence || name
end
end

# == Schema Information
#
# Table name: add_ons
#
# id :uuid not null, primary key
# amount_cents :bigint not null
# amount_currency :string not null
# code :string not null
# deleted_at :datetime
# description :string
# invoice_display_name :string
# name :string not null
# created_at :datetime not null
# updated_at :datetime not null
# organization_id :uuid not null
#
# Indexes
#
# index_add_ons_on_deleted_at (deleted_at)
# index_add_ons_on_organization_id (organization_id)
# index_add_ons_on_organization_id_and_code (organization_id,code) UNIQUE WHERE (deleted_at IS NULL)
#
# Foreign Keys
#
# fk_rails_... (organization_id => organizations.id)
#
22 changes: 22 additions & 0 deletions app/models/add_on/applied_tax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,25 @@ class AppliedTax < ApplicationRecord
belongs_to :tax
end
end

# == Schema Information
#
# Table name: add_ons_taxes
#
# id :uuid not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# add_on_id :uuid not null
# tax_id :uuid not null
#
# Indexes
#
# index_add_ons_taxes_on_add_on_id (add_on_id)
# index_add_ons_taxes_on_add_on_id_and_tax_id (add_on_id,tax_id) UNIQUE
# index_add_ons_taxes_on_tax_id (tax_id)
#
# Foreign Keys
#
# fk_rails_... (add_on_id => add_ons.id)
# fk_rails_... (tax_id => taxes.id)
#
40 changes: 40 additions & 0 deletions app/models/adjusted_fee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,43 @@ def adjusted_display_name?
adjusted_units.blank? && adjusted_amount.blank?
end
end

# == Schema Information
#
# Table name: adjusted_fees
#
# id :uuid not null, primary key
# adjusted_amount :boolean default(FALSE), not null
# adjusted_units :boolean default(FALSE), not null
# fee_type :integer
# grouped_by :jsonb not null
# invoice_display_name :string
# properties :jsonb not null
# unit_amount_cents :bigint default(0), not null
# units :decimal(, ) default(0.0), not null
# created_at :datetime not null
# updated_at :datetime not null
# charge_filter_id :uuid
# charge_id :uuid
# fee_id :uuid
# group_id :uuid
# invoice_id :uuid not null
# subscription_id :uuid
#
# Indexes
#
# index_adjusted_fees_on_charge_filter_id (charge_filter_id)
# index_adjusted_fees_on_charge_id (charge_id)
# index_adjusted_fees_on_fee_id (fee_id)
# index_adjusted_fees_on_group_id (group_id)
# index_adjusted_fees_on_invoice_id (invoice_id)
# index_adjusted_fees_on_subscription_id (subscription_id)
#
# Foreign Keys
#
# fk_rails_... (charge_id => charges.id)
# fk_rails_... (fee_id => fees.id)
# fk_rails_... (group_id => groups.id)
# fk_rails_... (invoice_id => invoices.id)
# fk_rails_... (subscription_id => subscriptions.id)
#
24 changes: 24 additions & 0 deletions app/models/applied_add_on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,27 @@ class AppliedAddOn < ApplicationRecord
validates :amount_cents, numericality: {greater_than: 0}
validates :amount_currency, inclusion: {in: currency_list}
end

# == Schema Information
#
# Table name: applied_add_ons
#
# id :uuid not null, primary key
# amount_cents :bigint not null
# amount_currency :string not null
# created_at :datetime not null
# updated_at :datetime not null
# add_on_id :uuid not null
# customer_id :uuid not null
#
# Indexes
#
# index_applied_add_ons_on_add_on_id (add_on_id)
# index_applied_add_ons_on_add_on_id_and_customer_id (add_on_id,customer_id)
# index_applied_add_ons_on_customer_id (customer_id)
#
# Foreign Keys
#
# fk_rails_... (add_on_id => add_ons.id)
# fk_rails_... (customer_id => customers.id)
#
24 changes: 24 additions & 0 deletions app/models/applied_coupon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,27 @@ def mark_as_terminated!(timestamp = Time.zone.now)
terminated!
end
end

# == Schema Information
#
# Table name: applied_coupons
#
# id :uuid not null, primary key
# amount_cents :bigint
# amount_currency :string
# frequency :integer default("once"), not null
# frequency_duration :integer
# frequency_duration_remaining :integer
# percentage_rate :decimal(10, 5)
# status :integer default("active"), not null
# terminated_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# coupon_id :uuid not null
# customer_id :uuid not null
#
# Indexes
#
# index_applied_coupons_on_coupon_id (coupon_id)
# index_applied_coupons_on_customer_id (customer_id)
#
30 changes: 30 additions & 0 deletions app/models/billable_metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,33 @@ def validate_recurring
errors.add(:recurring, :not_compatible_with_aggregation_type)
end
end

# == Schema Information
#
# Table name: billable_metrics
#
# id :uuid not null, primary key
# aggregation_type :integer not null
# code :string not null
# custom_aggregator :text
# deleted_at :datetime
# description :string
# field_name :string
# name :string not null
# properties :jsonb
# recurring :boolean default(FALSE), not null
# weighted_interval :enum
# created_at :datetime not null
# updated_at :datetime not null
# organization_id :uuid not null
#
# Indexes
#
# index_billable_metrics_on_deleted_at (deleted_at)
# index_billable_metrics_on_organization_id (organization_id)
# index_billable_metrics_on_organization_id_and_code (organization_id,code) UNIQUE WHERE (deleted_at IS NULL)
#
# Foreign Keys
#
# fk_rails_... (organization_id => organizations.id)
#
23 changes: 23 additions & 0 deletions app/models/billable_metric_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,26 @@ class BillableMetricFilter < ApplicationRecord

default_scope -> { kept }
end

# == Schema Information
#
# Table name: billable_metric_filters
#
# id :uuid not null, primary key
# deleted_at :datetime
# key :string not null
# values :string default([]), not null, is an Array
# created_at :datetime not null
# updated_at :datetime not null
# billable_metric_id :uuid not null
#
# Indexes
#
# index_active_metric_filters (billable_metric_id) WHERE (deleted_at IS NULL)
# index_billable_metric_filters_on_billable_metric_id (billable_metric_id)
# index_billable_metric_filters_on_deleted_at (deleted_at)
#
# Foreign Keys
#
# fk_rails_... (billable_metric_id => billable_metrics.id)
#
38 changes: 38 additions & 0 deletions app/models/cached_aggregation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,41 @@ class CachedAggregation < ApplicationRecord
scope :from_datetime, ->(from_datetime) { where('cached_aggregations.timestamp::timestamp(0) >= ?', from_datetime) }
scope :to_datetime, ->(to_datetime) { where('cached_aggregations.timestamp::timestamp(0) <= ?', to_datetime) }
end

# == Schema Information
#
# Table name: cached_aggregations
#
# id :uuid not null, primary key
# current_aggregation :decimal(, )
# current_amount :decimal(, )
# grouped_by :jsonb not null
# max_aggregation :decimal(, )
# max_aggregation_with_proration :decimal(, )
# timestamp :datetime not null
# created_at :datetime not null
# updated_at :datetime not null
# charge_filter_id :uuid
# charge_id :uuid not null
# event_id :uuid
# event_transaction_id :string
# external_subscription_id :string not null
# group_id :uuid
# organization_id :uuid not null
#
# Indexes
#
# index_cached_aggregations_on_charge_id (charge_id)
# index_cached_aggregations_on_event_id (event_id)
# index_cached_aggregations_on_event_transaction_id (organization_id,event_transaction_id)
# index_cached_aggregations_on_external_subscription_id (external_subscription_id)
# index_cached_aggregations_on_group_id (group_id)
# index_cached_aggregations_on_organization_id (organization_id)
# index_timestamp_filter_lookup (organization_id,timestamp,charge_id,charge_filter_id)
# index_timestamp_group_lookup (organization_id,timestamp,charge_id,group_id)
# index_timestamp_lookup (organization_id,timestamp,charge_id)
#
# Foreign Keys
#
# fk_rails_... (group_id => groups.id)
#
32 changes: 32 additions & 0 deletions app/models/charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,35 @@ def validate_custom_model
errors.add(:charge_model, :invalid_aggregation_type_or_charge_model)
end
end

# == Schema Information
#
# Table name: charges
#
# id :uuid not null, primary key
# amount_currency :string
# charge_model :integer default("standard"), not null
# deleted_at :datetime
# invoice_display_name :string
# invoiceable :boolean default(TRUE), not null
# min_amount_cents :bigint default(0), not null
# pay_in_advance :boolean default(FALSE), not null
# properties :jsonb not null
# prorated :boolean default(FALSE), not null
# regroup_paid_fees :integer
# created_at :datetime not null
# updated_at :datetime not null
# billable_metric_id :uuid
# plan_id :uuid
#
# Indexes
#
# index_charges_on_billable_metric_id (billable_metric_id)
# index_charges_on_deleted_at (deleted_at)
# index_charges_on_plan_id (plan_id)
#
# Foreign Keys
#
# fk_rails_... (billable_metric_id => billable_metrics.id)
# fk_rails_... (plan_id => plans.id)
#
22 changes: 22 additions & 0 deletions app/models/charge/applied_tax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,25 @@ class AppliedTax < ApplicationRecord
belongs_to :tax
end
end

# == Schema Information
#
# Table name: charges_taxes
#
# id :uuid not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# charge_id :uuid not null
# tax_id :uuid not null
#
# Indexes
#
# index_charges_taxes_on_charge_id (charge_id)
# index_charges_taxes_on_charge_id_and_tax_id (charge_id,tax_id) UNIQUE
# index_charges_taxes_on_tax_id (tax_id)
#
# Foreign Keys
#
# fk_rails_... (charge_id => charges.id)
# fk_rails_... (tax_id => taxes.id)
#
23 changes: 23 additions & 0 deletions app/models/charge_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,26 @@ def validate_charge_model(validator)
.each { |code| errors.add(:properties, code) }
end
end

# == Schema Information
#
# Table name: charge_filters
#
# id :uuid not null, primary key
# deleted_at :datetime
# invoice_display_name :string
# properties :jsonb not null
# created_at :datetime not null
# updated_at :datetime not null
# charge_id :uuid not null
#
# Indexes
#
# index_active_charge_filters (charge_id) WHERE (deleted_at IS NULL)
# index_charge_filters_on_charge_id (charge_id)
# index_charge_filters_on_deleted_at (deleted_at)
#
# Foreign Keys
#
# fk_rails_... (charge_id => charges.id)
#
Loading

0 comments on commit abd7434

Please sign in to comment.