From cc7d1395055a4c8e1839f614e786d03549c7ffe0 Mon Sep 17 00:00:00 2001 From: Toon Willems Date: Wed, 31 Jul 2024 11:15:51 +0200 Subject: [PATCH] Add annotations --- Gemfile | 2 + Gemfile.lock | 4 ++ app/models/add_on.rb | 27 +++++++ app/models/add_on/applied_tax.rb | 22 ++++++ app/models/adjusted_fee.rb | 40 +++++++++++ app/models/applied_add_on.rb | 24 +++++++ app/models/applied_coupon.rb | 24 +++++++ app/models/billable_metric.rb | 30 ++++++++ app/models/billable_metric_filter.rb | 23 ++++++ app/models/cached_aggregation.rb | 38 ++++++++++ app/models/charge.rb | 32 +++++++++ app/models/charge/applied_tax.rb | 22 ++++++ app/models/charge_filter.rb | 23 ++++++ app/models/charge_filter_value.rb | 25 +++++++ app/models/clickhouse/events_count_agg.rb | 14 ++++ app/models/clickhouse/events_enriched.rb | 17 +++++ app/models/clickhouse/events_max_agg.rb | 14 ++++ app/models/clickhouse/events_raw.rb | 13 ++++ app/models/clickhouse/events_sum_agg.rb | 14 ++++ app/models/commitment.rb | 22 ++++++ app/models/commitment/applied_tax.rb | 21 ++++++ app/models/coupon.rb | 33 +++++++++ app/models/coupon_target.rb | 26 +++++++ app/models/credit.rb | 27 +++++++ app/models/credit_note.rb | 45 ++++++++++++ app/models/credit_note/applied_tax.rb | 29 ++++++++ app/models/credit_note_item.rb | 24 +++++++ app/models/customer.rb | 53 ++++++++++++++ app/models/customer/applied_tax.rb | 22 ++++++ app/models/data_export.rb | 28 ++++++++ app/models/error_detail.rb | 26 +++++++ app/models/event.rb | 35 +++++++++ app/models/events/last_hour_mv.rb | 16 +++++ app/models/fee.rb | 71 +++++++++++++++++++ app/models/fee/applied_tax.rb | 28 ++++++++ app/models/group.rb | 26 +++++++ app/models/group_property.rb | 26 +++++++ .../anrok_collection_mapping.rb | 22 ++++++ .../base_collection_mapping.rb | 22 ++++++ .../netsuite_collection_mapping.rb | 22 ++++++ .../xero_collection_mapping.rb | 22 ++++++ .../integration_customers/anrok_customer.rb | 26 +++++++ .../integration_customers/base_customer.rb | 26 +++++++ .../netsuite_customer.rb | 26 +++++++ .../integration_customers/xero_customer.rb | 26 +++++++ app/models/integration_item.rb | 23 ++++++ .../integration_mappings/anrok_mapping.rb | 23 ++++++ .../integration_mappings/base_mapping.rb | 23 ++++++ .../integration_mappings/netsuite_mapping.rb | 23 ++++++ .../integration_mappings/xero_mapping.rb | 23 ++++++ app/models/integration_resource.rb | 23 ++++++ app/models/integrations/anrok_integration.rb | 24 +++++++ app/models/integrations/base_integration.rb | 24 +++++++ .../integrations/netsuite_integration.rb | 24 +++++++ app/models/integrations/okta_integration.rb | 24 +++++++ app/models/integrations/xero_integration.rb | 24 +++++++ app/models/invite.rb | 28 ++++++++ app/models/invoice.rb | 58 +++++++++++++++ app/models/invoice/applied_tax.rb | 29 ++++++++ app/models/invoice_subscription.rb | 33 +++++++++ app/models/lifetime_usage.rb | 30 ++++++++ app/models/membership.rb | 25 +++++++ app/models/metadata/customer_metadata.rb | 22 ++++++ app/models/metadata/invoice_metadata.rb | 21 ++++++ app/models/organization.rb | 41 +++++++++++ app/models/password_reset.rb | 21 ++++++ app/models/payable_group.rb | 22 ++++++ app/models/payment.rb | 33 +++++++++ .../adyen_customer.rb | 25 +++++++ .../base_customer.rb | 25 +++++++ .../gocardless_customer.rb | 25 +++++++ .../stripe_customer.rb | 25 +++++++ .../payment_providers/adyen_provider.rb | 24 +++++++ app/models/payment_providers/base_provider.rb | 24 +++++++ .../payment_providers/gocardless_provider.rb | 24 +++++++ .../payment_providers/stripe_provider.rb | 24 +++++++ app/models/payment_request.rb | 27 +++++++ app/models/plan.rb | 36 ++++++++++ app/models/plan/applied_tax.rb | 22 ++++++ app/models/quantified_event.rb | 35 +++++++++ app/models/recurring_transaction_rule.rb | 29 ++++++++ app/models/refund.rb | 31 ++++++++ app/models/subscription.rb | 37 ++++++++++ app/models/tax.rb | 25 +++++++ app/models/usage_threshold.rb | 24 +++++++ app/models/user.rb | 11 +++ app/models/wallet.rb | 37 ++++++++++ app/models/wallet_transaction.rb | 30 ++++++++ app/models/webhook.rb | 28 ++++++++ app/models/webhook_endpoint.rb | 21 ++++++ lib/tasks/auto_annotate_models.rake | 59 +++++++++++++++ 91 files changed, 2427 insertions(+) create mode 100644 lib/tasks/auto_annotate_models.rake diff --git a/Gemfile b/Gemfile index e899787ea3b..86a90db68f7 100644 --- a/Gemfile +++ b/Gemfile @@ -122,6 +122,8 @@ group :development do gem 'rubocop-thread_safety', require: false gem "standard", require: false + gem 'annotate' + gem 'sass-rails' gem 'uglifier' diff --git a/Gemfile.lock b/Gemfile.lock index 0ff11a6c2b9..4819dcc1a06 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -871,6 +874,7 @@ DEPENDENCIES adyen-ruby-api-library after_commit_everywhere analytics-ruby (~> 2.4.0) + annotate awesome_print aws-sdk-s3 bcrypt diff --git a/app/models/add_on.rb b/app/models/add_on.rb index 893bc1ad383..9129b3e78a5 100644 --- a/app/models/add_on.rb +++ b/app/models/add_on.rb @@ -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) +# diff --git a/app/models/add_on/applied_tax.rb b/app/models/add_on/applied_tax.rb index e5b1dcc91f0..2021b6d5438 100644 --- a/app/models/add_on/applied_tax.rb +++ b/app/models/add_on/applied_tax.rb @@ -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) +# diff --git a/app/models/adjusted_fee.rb b/app/models/adjusted_fee.rb index a0213c0f7cf..19687cbcf09 100644 --- a/app/models/adjusted_fee.rb +++ b/app/models/adjusted_fee.rb @@ -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) +# diff --git a/app/models/applied_add_on.rb b/app/models/applied_add_on.rb index 460cf0d15b0..505186a56a3 100644 --- a/app/models/applied_add_on.rb +++ b/app/models/applied_add_on.rb @@ -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) +# diff --git a/app/models/applied_coupon.rb b/app/models/applied_coupon.rb index 3186a0f9ded..755e7dd845a 100644 --- a/app/models/applied_coupon.rb +++ b/app/models/applied_coupon.rb @@ -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) +# diff --git a/app/models/billable_metric.rb b/app/models/billable_metric.rb index 47fc4616966..6cf6a0d3ab5 100644 --- a/app/models/billable_metric.rb +++ b/app/models/billable_metric.rb @@ -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) +# diff --git a/app/models/billable_metric_filter.rb b/app/models/billable_metric_filter.rb index b57f3a8e3df..4a373c44dc5 100644 --- a/app/models/billable_metric_filter.rb +++ b/app/models/billable_metric_filter.rb @@ -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) +# diff --git a/app/models/cached_aggregation.rb b/app/models/cached_aggregation.rb index baf41047888..e004e7754b8 100644 --- a/app/models/cached_aggregation.rb +++ b/app/models/cached_aggregation.rb @@ -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) +# diff --git a/app/models/charge.rb b/app/models/charge.rb index a45dfd75b19..ebb9e300f1b 100644 --- a/app/models/charge.rb +++ b/app/models/charge.rb @@ -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) +# diff --git a/app/models/charge/applied_tax.rb b/app/models/charge/applied_tax.rb index 51ac66fe010..2e265de1628 100644 --- a/app/models/charge/applied_tax.rb +++ b/app/models/charge/applied_tax.rb @@ -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) +# diff --git a/app/models/charge_filter.rb b/app/models/charge_filter.rb index ec76541828c..7feeb3cc20e 100644 --- a/app/models/charge_filter.rb +++ b/app/models/charge_filter.rb @@ -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) +# diff --git a/app/models/charge_filter_value.rb b/app/models/charge_filter_value.rb index 33363c6326d..09737dd939c 100644 --- a/app/models/charge_filter_value.rb +++ b/app/models/charge_filter_value.rb @@ -29,3 +29,28 @@ def validate_values errors.add(:values, :inclusion) end end + +# == Schema Information +# +# Table name: charge_filter_values +# +# id :uuid not null, primary key +# deleted_at :datetime +# values :string default([]), not null, is an Array +# created_at :datetime not null +# updated_at :datetime not null +# billable_metric_filter_id :uuid not null +# charge_filter_id :uuid not null +# +# Indexes +# +# index_active_charge_filter_values (charge_filter_id) WHERE (deleted_at IS NULL) +# index_charge_filter_values_on_billable_metric_filter_id (billable_metric_filter_id) +# index_charge_filter_values_on_charge_filter_id (charge_filter_id) +# index_charge_filter_values_on_deleted_at (deleted_at) +# +# Foreign Keys +# +# fk_rails_... (billable_metric_filter_id => billable_metric_filters.id) +# fk_rails_... (charge_filter_id => charge_filters.id) +# diff --git a/app/models/clickhouse/events_count_agg.rb b/app/models/clickhouse/events_count_agg.rb index c9b4258619c..3f05ff382b0 100644 --- a/app/models/clickhouse/events_count_agg.rb +++ b/app/models/clickhouse/events_count_agg.rb @@ -5,3 +5,17 @@ class EventsCountAgg < BaseRecord self.table_name = 'events_count_agg' end end + +# == Schema Information +# +# Table name: events_count_agg +# +# code :string not null +# filters :map not null +# grouped_by :map not null +# timestamp :datetime not null +# value :decimal(26, ) +# charge_id :string not null +# external_subscription_id :string not null +# organization_id :string not null +# diff --git a/app/models/clickhouse/events_enriched.rb b/app/models/clickhouse/events_enriched.rb index b3afba570b0..6668b53ea70 100644 --- a/app/models/clickhouse/events_enriched.rb +++ b/app/models/clickhouse/events_enriched.rb @@ -5,3 +5,20 @@ class EventsEnriched < BaseRecord self.table_name = 'events_enriched' end end + +# == Schema Information +# +# Table name: events_enriched +# +# aggregation_type :string +# code :string not null +# filters :map not null +# grouped_by :map not null +# properties :map not null +# timestamp :datetime not null +# value :string +# charge_id :string not null +# external_subscription_id :string not null +# organization_id :string not null +# transaction_id :string not null +# diff --git a/app/models/clickhouse/events_max_agg.rb b/app/models/clickhouse/events_max_agg.rb index 89c435594af..fe832957f46 100644 --- a/app/models/clickhouse/events_max_agg.rb +++ b/app/models/clickhouse/events_max_agg.rb @@ -5,3 +5,17 @@ class EventsMaxAgg < BaseRecord self.table_name = 'events_max_agg' end end + +# == Schema Information +# +# Table name: events_max_agg +# +# code :string not null +# filters :map not null +# grouped_by :map not null +# timestamp :datetime not null +# value :decimal(38, 26) not null +# charge_id :string not null +# external_subscription_id :string not null +# organization_id :string not null +# diff --git a/app/models/clickhouse/events_raw.rb b/app/models/clickhouse/events_raw.rb index 58d469f2992..d184955b492 100644 --- a/app/models/clickhouse/events_raw.rb +++ b/app/models/clickhouse/events_raw.rb @@ -5,3 +5,16 @@ class EventsRaw < BaseRecord self.table_name = 'events_raw' end end + +# == Schema Information +# +# Table name: events_raw +# +# code :string not null +# properties :map not null +# timestamp :datetime not null +# external_customer_id :string not null +# external_subscription_id :string not null +# organization_id :string not null +# transaction_id :string not null +# diff --git a/app/models/clickhouse/events_sum_agg.rb b/app/models/clickhouse/events_sum_agg.rb index 84a4207ff2f..c6e48ea314a 100644 --- a/app/models/clickhouse/events_sum_agg.rb +++ b/app/models/clickhouse/events_sum_agg.rb @@ -5,3 +5,17 @@ class EventsSumAgg < BaseRecord self.table_name = 'events_sum_agg' end end + +# == Schema Information +# +# Table name: events_sum_agg +# +# code :string not null +# filters :map not null +# grouped_by :map not null +# timestamp :datetime not null +# value :decimal(26, ) +# charge_id :string not null +# external_subscription_id :string not null +# organization_id :string not null +# diff --git a/app/models/commitment.rb b/app/models/commitment.rb index fcaa49c1c15..4d9d2f11f2a 100644 --- a/app/models/commitment.rb +++ b/app/models/commitment.rb @@ -20,3 +20,25 @@ def invoice_name invoice_display_name.presence || I18n.t('commitment.minimum.name') end end + +# == Schema Information +# +# Table name: commitments +# +# id :uuid not null, primary key +# amount_cents :bigint not null +# commitment_type :integer not null +# invoice_display_name :string +# created_at :datetime not null +# updated_at :datetime not null +# plan_id :uuid not null +# +# Indexes +# +# index_commitments_on_commitment_type_and_plan_id (commitment_type,plan_id) UNIQUE +# index_commitments_on_plan_id (plan_id) +# +# Foreign Keys +# +# fk_rails_... (plan_id => plans.id) +# diff --git a/app/models/commitment/applied_tax.rb b/app/models/commitment/applied_tax.rb index 34683e21ba1..5dbe0b4042a 100644 --- a/app/models/commitment/applied_tax.rb +++ b/app/models/commitment/applied_tax.rb @@ -8,3 +8,24 @@ class AppliedTax < ApplicationRecord belongs_to :tax end end + +# == Schema Information +# +# Table name: commitments_taxes +# +# id :uuid not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# commitment_id :uuid not null +# tax_id :uuid not null +# +# Indexes +# +# index_commitments_taxes_on_commitment_id (commitment_id) +# index_commitments_taxes_on_tax_id (tax_id) +# +# Foreign Keys +# +# fk_rails_... (commitment_id => commitments.id) +# fk_rails_... (tax_id => taxes.id) +# diff --git a/app/models/coupon.rb b/app/models/coupon.rb index 33eec20af48..5f648586f40 100644 --- a/app/models/coupon.rb +++ b/app/models/coupon.rb @@ -82,3 +82,36 @@ def parent_and_overriden_plans (plans + plans.map(&:children)).flatten end end + +# == Schema Information +# +# Table name: coupons +# +# id :uuid not null, primary key +# amount_cents :bigint +# amount_currency :string +# code :string +# coupon_type :integer default("fixed_amount"), not null +# deleted_at :datetime +# description :text +# expiration :integer not null +# expiration_at :datetime +# frequency :integer default("once"), not null +# frequency_duration :integer +# limited_billable_metrics :boolean default(FALSE), not null +# limited_plans :boolean default(FALSE), not null +# name :string not null +# percentage_rate :decimal(10, 5) +# reusable :boolean default(TRUE), not null +# status :integer default("active"), not null +# terminated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_coupons_on_deleted_at (deleted_at) +# index_coupons_on_organization_id (organization_id) +# index_coupons_on_organization_id_and_code (organization_id,code) UNIQUE WHERE (deleted_at IS NULL) +# diff --git a/app/models/coupon_target.rb b/app/models/coupon_target.rb index 4c36ee98aaa..89f9a80003c 100644 --- a/app/models/coupon_target.rb +++ b/app/models/coupon_target.rb @@ -11,3 +11,29 @@ class CouponTarget < ApplicationRecord default_scope -> { kept } end + +# == Schema Information +# +# Table name: coupon_targets +# +# id :uuid not null, primary key +# deleted_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# billable_metric_id :uuid +# coupon_id :uuid not null +# plan_id :uuid +# +# Indexes +# +# index_coupon_targets_on_billable_metric_id (billable_metric_id) +# index_coupon_targets_on_coupon_id (coupon_id) +# index_coupon_targets_on_deleted_at (deleted_at) +# index_coupon_targets_on_plan_id (plan_id) +# +# Foreign Keys +# +# fk_rails_... (billable_metric_id => billable_metrics.id) +# fk_rails_... (coupon_id => coupons.id) +# fk_rails_... (plan_id => plans.id) +# diff --git a/app/models/credit.rb b/app/models/credit.rb index 71b40e55058..7a05521705c 100644 --- a/app/models/credit.rb +++ b/app/models/credit.rb @@ -57,3 +57,30 @@ def invoice_coupon_display_name "#{coupon.name} (#{suffix})" end end + +# == Schema Information +# +# Table name: credits +# +# id :uuid not null, primary key +# amount_cents :bigint not null +# amount_currency :string not null +# before_taxes :boolean default(FALSE), not null +# created_at :datetime not null +# updated_at :datetime not null +# applied_coupon_id :uuid +# credit_note_id :uuid +# invoice_id :uuid +# +# Indexes +# +# index_credits_on_applied_coupon_id (applied_coupon_id) +# index_credits_on_credit_note_id (credit_note_id) +# index_credits_on_invoice_id (invoice_id) +# +# Foreign Keys +# +# fk_rails_... (applied_coupon_id => applied_coupons.id) +# fk_rails_... (credit_note_id => credit_notes.id) +# fk_rails_... (invoice_id => invoices.id) +# diff --git a/app/models/credit_note.rb b/app/models/credit_note.rb index e8c8796b724..8e57a9ee520 100644 --- a/app/models/credit_note.rb +++ b/app/models/credit_note.rb @@ -138,3 +138,48 @@ def ensure_number self.number = "#{invoice.number}-CN#{formatted_sequential_id}" end end + +# == Schema Information +# +# Table name: credit_notes +# +# id :uuid not null, primary key +# balance_amount_cents :bigint default(0), not null +# balance_amount_currency :string default("0"), not null +# coupons_adjustment_amount_cents :bigint default(0), not null +# credit_amount_cents :bigint default(0), not null +# credit_amount_currency :string not null +# credit_status :integer +# description :text +# file :string +# issuing_date :date not null +# number :string not null +# precise_coupons_adjustment_amount_cents :decimal(30, 5) default(0.0), not null +# precise_taxes_amount_cents :decimal(30, 5) default(0.0), not null +# reason :integer not null +# refund_amount_cents :bigint default(0), not null +# refund_amount_currency :string +# refund_status :integer +# refunded_at :datetime +# status :integer default("finalized"), not null +# taxes_amount_cents :bigint default(0), not null +# taxes_rate :float default(0.0), not null +# total_amount_cents :bigint default(0), not null +# total_amount_currency :string not null +# voided_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# invoice_id :uuid not null +# sequential_id :integer not null +# +# Indexes +# +# index_credit_notes_on_customer_id (customer_id) +# index_credit_notes_on_invoice_id (invoice_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (invoice_id => invoices.id) +# diff --git a/app/models/credit_note/applied_tax.rb b/app/models/credit_note/applied_tax.rb index 344a3e38d01..e98212becd1 100644 --- a/app/models/credit_note/applied_tax.rb +++ b/app/models/credit_note/applied_tax.rb @@ -13,3 +13,32 @@ class AppliedTax < ApplicationRecord monetize :base_amount_cents, with_model_currency: :amount_currency end end + +# == Schema Information +# +# Table name: credit_notes_taxes +# +# id :uuid not null, primary key +# amount_cents :bigint default(0), not null +# amount_currency :string not null +# base_amount_cents :bigint default(0), not null +# tax_code :string not null +# tax_description :string +# tax_name :string not null +# tax_rate :float default(0.0), not null +# created_at :datetime not null +# updated_at :datetime not null +# credit_note_id :uuid not null +# tax_id :uuid not null +# +# Indexes +# +# index_credit_notes_taxes_on_credit_note_id (credit_note_id) +# index_credit_notes_taxes_on_credit_note_id_and_tax_id (credit_note_id,tax_id) UNIQUE +# index_credit_notes_taxes_on_tax_id (tax_id) +# +# Foreign Keys +# +# fk_rails_... (credit_note_id => credit_notes.id) +# fk_rails_... (tax_id => taxes.id) +# diff --git a/app/models/credit_note_item.rb b/app/models/credit_note_item.rb index dd2b39756d9..1b229e57577 100644 --- a/app/models/credit_note_item.rb +++ b/app/models/credit_note_item.rb @@ -12,3 +12,27 @@ def applied_taxes credit_note.applied_taxes.where(tax_id: fee.applied_taxes.select('fees_taxes.tax_id')) end end + +# == Schema Information +# +# Table name: credit_note_items +# +# id :uuid not null, primary key +# amount_cents :bigint default(0), not null +# amount_currency :string not null +# precise_amount_cents :decimal(30, 5) not null +# created_at :datetime not null +# updated_at :datetime not null +# credit_note_id :uuid not null +# fee_id :uuid +# +# Indexes +# +# index_credit_note_items_on_credit_note_id (credit_note_id) +# index_credit_note_items_on_fee_id (fee_id) +# +# Foreign Keys +# +# fk_rails_... (credit_note_id => credit_notes.id) +# fk_rails_... (fee_id => fees.id) +# diff --git a/app/models/customer.rb b/app/models/customer.rb index ec4198069e9..d1e44b1d71a 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -138,3 +138,56 @@ def ensure_slug self.slug = "#{organization.document_number_prefix}-#{formatted_sequential_id}" end end + +# == Schema Information +# +# Table name: customers +# +# id :uuid not null, primary key +# address_line1 :string +# address_line2 :string +# city :string +# country :string +# currency :string +# deleted_at :datetime +# document_locale :string +# email :string +# invoice_grace_period :integer +# legal_name :string +# legal_number :string +# logo_url :string +# name :string +# net_payment_term :integer +# payment_provider :string +# payment_provider_code :string +# phone :string +# shipping_address_line1 :string +# shipping_address_line2 :string +# shipping_city :string +# shipping_country :string +# shipping_state :string +# shipping_zipcode :string +# slug :string +# state :string +# tax_identification_number :string +# timezone :string +# url :string +# vat_rate :float +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# external_id :string not null +# external_salesforce_id :string +# organization_id :uuid not null +# sequential_id :bigint +# +# Indexes +# +# index_customers_on_deleted_at (deleted_at) +# index_customers_on_external_id_and_organization_id (external_id,organization_id) UNIQUE WHERE (deleted_at IS NULL) +# index_customers_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/customer/applied_tax.rb b/app/models/customer/applied_tax.rb index 1982f9d017b..0ab2d4f63ff 100644 --- a/app/models/customer/applied_tax.rb +++ b/app/models/customer/applied_tax.rb @@ -10,3 +10,25 @@ class AppliedTax < ApplicationRecord belongs_to :tax end end + +# == Schema Information +# +# Table name: customers_taxes +# +# id :uuid not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# tax_id :uuid not null +# +# Indexes +# +# index_customers_taxes_on_customer_id (customer_id) +# index_customers_taxes_on_customer_id_and_tax_id (customer_id,tax_id) UNIQUE +# index_customers_taxes_on_tax_id (tax_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (tax_id => taxes.id) +# diff --git a/app/models/data_export.rb b/app/models/data_export.rb index 99e61a73e39..47e3d4948a2 100644 --- a/app/models/data_export.rb +++ b/app/models/data_export.rb @@ -55,3 +55,31 @@ def file_url File.join(ENV['LAGO_API_URL'], blob_path) end end + +# == Schema Information +# +# Table name: data_exports +# +# id :uuid not null, primary key +# completed_at :datetime +# expires_at :datetime +# format :integer +# resource_query :jsonb +# resource_type :string not null +# started_at :datetime +# status :integer default("pending"), not null +# created_at :datetime not null +# updated_at :datetime not null +# membership_id :uuid +# organization_id :uuid +# +# Indexes +# +# index_data_exports_on_membership_id (membership_id) +# index_data_exports_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (membership_id => memberships.id) +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/error_detail.rb b/app/models/error_detail.rb index d0565d2b8c3..ff1040c670f 100644 --- a/app/models/error_detail.rb +++ b/app/models/error_detail.rb @@ -11,3 +11,29 @@ class ErrorDetail < ApplicationRecord ERROR_CODES = %w[not_provided tax_error tax_voiding_error] enum error_code: ERROR_CODES end + +# == Schema Information +# +# Table name: error_details +# +# id :uuid not null, primary key +# deleted_at :datetime +# details :jsonb not null +# error_code :integer default("not_provided"), not null +# owner_type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# owner_id :uuid not null +# +# Indexes +# +# index_error_details_on_deleted_at (deleted_at) +# index_error_details_on_error_code (error_code) +# index_error_details_on_organization_id (organization_id) +# index_error_details_on_owner (owner_type,owner_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/event.rb b/app/models/event.rb index 393eb1a48c9..d8e9e25e59b 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -59,3 +59,38 @@ def subscription .first end end + +# == Schema Information +# +# 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 +# +# 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_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) +# index_events_on_organization_id_and_code_and_created_at (organization_id,code,created_at) WHERE (deleted_at IS NULL) +# index_events_on_organization_id_and_timestamp (organization_id,timestamp) WHERE (deleted_at IS NULL) +# index_events_on_properties (properties) USING gin +# index_events_on_subscription_id (subscription_id) +# index_events_on_subscription_id_and_code_and_timestamp (subscription_id,code,timestamp) WHERE (deleted_at IS NULL) +# index_unique_transaction_id (organization_id,external_subscription_id,transaction_id) UNIQUE +# diff --git a/app/models/events/last_hour_mv.rb b/app/models/events/last_hour_mv.rb index 8d7c624670b..b633f3b1b25 100644 --- a/app/models/events/last_hour_mv.rb +++ b/app/models/events/last_hour_mv.rb @@ -9,3 +9,19 @@ def readonly? end end end + +# == Schema Information +# +# Table name: last_hour_events_mv +# +# billable_metric_code :string +# field_name_mandatory :boolean +# field_value :text +# has_filter_keys :boolean +# has_valid_filter_values :boolean +# is_numeric_field_value :boolean +# numeric_field_mandatory :boolean +# properties :jsonb +# organization_id :uuid +# transaction_id :string +# diff --git a/app/models/fee.rb b/app/models/fee.rb index e3bab4517f5..fe8600c2774 100644 --- a/app/models/fee.rb +++ b/app/models/fee.rb @@ -157,3 +157,74 @@ def has_charge_filters? charge&.filters&.any? end end + +# == Schema Information +# +# Table name: fees +# +# id :uuid not null, primary key +# amount_cents :bigint not null +# amount_currency :string not null +# amount_details :jsonb not null +# deleted_at :datetime +# description :string +# events_count :integer +# failed_at :datetime +# fee_type :integer +# grouped_by :jsonb not null +# invoice_display_name :string +# invoiceable_type :string +# pay_in_advance :boolean default(FALSE), not null +# payment_status :integer default("pending"), not null +# precise_coupons_amount_cents :decimal(30, 5) default(0.0), not null +# precise_unit_amount :decimal(30, 15) default(0.0), not null +# properties :jsonb not null +# refunded_at :datetime +# succeeded_at :datetime +# taxes_amount_cents :bigint not null +# taxes_rate :float default(0.0), not null +# total_aggregated_units :decimal(, ) +# 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 +# add_on_id :uuid +# applied_add_on_id :uuid +# charge_filter_id :uuid +# charge_id :uuid +# group_id :uuid +# invoice_id :uuid +# invoiceable_id :uuid +# pay_in_advance_event_id :uuid +# pay_in_advance_event_transaction_id :string +# subscription_id :uuid +# true_up_parent_fee_id :uuid +# usage_threshold_id :uuid +# +# Indexes +# +# index_fees_on_add_on_id (add_on_id) +# index_fees_on_applied_add_on_id (applied_add_on_id) +# index_fees_on_charge_filter_id (charge_filter_id) +# index_fees_on_charge_id (charge_id) +# index_fees_on_charge_id_and_invoice_id (charge_id,invoice_id) WHERE (deleted_at IS NULL) +# index_fees_on_deleted_at (deleted_at) +# index_fees_on_group_id (group_id) +# index_fees_on_invoice_id (invoice_id) +# index_fees_on_invoiceable (invoiceable_type,invoiceable_id) +# index_fees_on_pay_in_advance_event_transaction_id (pay_in_advance_event_transaction_id) WHERE (deleted_at IS NULL) +# index_fees_on_subscription_id (subscription_id) +# index_fees_on_true_up_parent_fee_id (true_up_parent_fee_id) +# index_fees_on_usage_threshold_id (usage_threshold_id) +# +# Foreign Keys +# +# fk_rails_... (add_on_id => add_ons.id) +# fk_rails_... (applied_add_on_id => applied_add_ons.id) +# fk_rails_... (charge_id => charges.id) +# fk_rails_... (group_id => groups.id) +# fk_rails_... (invoice_id => invoices.id) +# fk_rails_... (subscription_id => subscriptions.id) +# fk_rails_... (true_up_parent_fee_id => fees.id) +# fk_rails_... (usage_threshold_id => usage_thresholds.id) +# diff --git a/app/models/fee/applied_tax.rb b/app/models/fee/applied_tax.rb index d73bb3392cf..9dc2b61c6ba 100644 --- a/app/models/fee/applied_tax.rb +++ b/app/models/fee/applied_tax.rb @@ -10,3 +10,31 @@ class AppliedTax < ApplicationRecord belongs_to :tax, optional: true end end + +# == Schema Information +# +# Table name: fees_taxes +# +# id :uuid not null, primary key +# amount_cents :bigint default(0), not null +# amount_currency :string not null +# tax_code :string not null +# tax_description :string +# tax_name :string not null +# tax_rate :float default(0.0), not null +# created_at :datetime not null +# updated_at :datetime not null +# fee_id :uuid not null +# tax_id :uuid +# +# Indexes +# +# index_fees_taxes_on_fee_id (fee_id) +# index_fees_taxes_on_fee_id_and_tax_id (fee_id,tax_id) UNIQUE WHERE ((tax_id IS NOT NULL) AND (created_at >= '2023-09-12 00:00:00'::timestamp without time zone)) +# index_fees_taxes_on_tax_id (tax_id) +# +# Foreign Keys +# +# fk_rails_... (fee_id => fees.id) +# fk_rails_... (tax_id => taxes.id) +# diff --git a/app/models/group.rb b/app/models/group.rb index 63fc724cb2d..92bf985565a 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -26,3 +26,29 @@ def discard_with_properties! children.each { |c| c.properties&.discard_all && c.discard! } && properties.discard_all && discard! end end + +# == Schema Information +# +# Table name: groups +# +# id :uuid not null, primary key +# deleted_at :datetime +# key :string not null +# value :string not null +# created_at :datetime not null +# updated_at :datetime not null +# billable_metric_id :uuid not null +# parent_group_id :uuid +# +# Indexes +# +# index_groups_on_billable_metric_id (billable_metric_id) +# index_groups_on_billable_metric_id_and_parent_group_id (billable_metric_id,parent_group_id) +# index_groups_on_deleted_at (deleted_at) +# index_groups_on_parent_group_id (parent_group_id) +# +# Foreign Keys +# +# fk_rails_... (billable_metric_id => billable_metrics.id) ON DELETE => cascade +# fk_rails_... (parent_group_id => groups.id) +# diff --git a/app/models/group_property.rb b/app/models/group_property.rb index 107930b98bd..1c24d2c075c 100644 --- a/app/models/group_property.rb +++ b/app/models/group_property.rb @@ -12,3 +12,29 @@ class GroupProperty < ApplicationRecord default_scope -> { kept } end + +# == Schema Information +# +# Table name: group_properties +# +# id :uuid not null, primary key +# deleted_at :datetime +# invoice_display_name :string +# values :jsonb not null +# created_at :datetime not null +# updated_at :datetime not null +# charge_id :uuid not null +# group_id :uuid not null +# +# Indexes +# +# index_group_properties_on_charge_id (charge_id) +# index_group_properties_on_charge_id_and_group_id (charge_id,group_id) UNIQUE +# index_group_properties_on_deleted_at (deleted_at) +# index_group_properties_on_group_id (group_id) +# +# Foreign Keys +# +# fk_rails_... (charge_id => charges.id) ON DELETE => cascade +# fk_rails_... (group_id => groups.id) ON DELETE => cascade +# diff --git a/app/models/integration_collection_mappings/anrok_collection_mapping.rb b/app/models/integration_collection_mappings/anrok_collection_mapping.rb index 341fb1688f8..eeeaa797300 100644 --- a/app/models/integration_collection_mappings/anrok_collection_mapping.rb +++ b/app/models/integration_collection_mappings/anrok_collection_mapping.rb @@ -4,3 +4,25 @@ module IntegrationCollectionMappings class AnrokCollectionMapping < BaseCollectionMapping end end + +# == Schema Information +# +# Table name: integration_collection_mappings +# +# id :uuid not null, primary key +# mapping_type :integer not null +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# integration_id :uuid not null +# +# Indexes +# +# index_int_collection_mappings_on_mapping_type_and_int_id (mapping_type,integration_id) UNIQUE +# index_integration_collection_mappings_on_integration_id (integration_id) +# +# Foreign Keys +# +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_collection_mappings/base_collection_mapping.rb b/app/models/integration_collection_mappings/base_collection_mapping.rb index 1062ded1a95..d6a6f97d635 100644 --- a/app/models/integration_collection_mappings/base_collection_mapping.rb +++ b/app/models/integration_collection_mappings/base_collection_mapping.rb @@ -20,3 +20,25 @@ class BaseCollectionMapping < ApplicationRecord settings_accessors :external_id, :external_account_code, :external_name end end + +# == Schema Information +# +# Table name: integration_collection_mappings +# +# id :uuid not null, primary key +# mapping_type :integer not null +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# integration_id :uuid not null +# +# Indexes +# +# index_int_collection_mappings_on_mapping_type_and_int_id (mapping_type,integration_id) UNIQUE +# index_integration_collection_mappings_on_integration_id (integration_id) +# +# Foreign Keys +# +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_collection_mappings/netsuite_collection_mapping.rb b/app/models/integration_collection_mappings/netsuite_collection_mapping.rb index a5e34e744ac..9c469f7e0bc 100644 --- a/app/models/integration_collection_mappings/netsuite_collection_mapping.rb +++ b/app/models/integration_collection_mappings/netsuite_collection_mapping.rb @@ -4,3 +4,25 @@ module IntegrationCollectionMappings class NetsuiteCollectionMapping < BaseCollectionMapping end end + +# == Schema Information +# +# Table name: integration_collection_mappings +# +# id :uuid not null, primary key +# mapping_type :integer not null +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# integration_id :uuid not null +# +# Indexes +# +# index_int_collection_mappings_on_mapping_type_and_int_id (mapping_type,integration_id) UNIQUE +# index_integration_collection_mappings_on_integration_id (integration_id) +# +# Foreign Keys +# +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_collection_mappings/xero_collection_mapping.rb b/app/models/integration_collection_mappings/xero_collection_mapping.rb index 42c5fa65b56..457f4f0a253 100644 --- a/app/models/integration_collection_mappings/xero_collection_mapping.rb +++ b/app/models/integration_collection_mappings/xero_collection_mapping.rb @@ -4,3 +4,25 @@ module IntegrationCollectionMappings class XeroCollectionMapping < BaseCollectionMapping end end + +# == Schema Information +# +# Table name: integration_collection_mappings +# +# id :uuid not null, primary key +# mapping_type :integer not null +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# integration_id :uuid not null +# +# Indexes +# +# index_int_collection_mappings_on_mapping_type_and_int_id (mapping_type,integration_id) UNIQUE +# index_integration_collection_mappings_on_integration_id (integration_id) +# +# Foreign Keys +# +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_customers/anrok_customer.rb b/app/models/integration_customers/anrok_customer.rb index 2455ef07e1b..1bbacef4912 100644 --- a/app/models/integration_customers/anrok_customer.rb +++ b/app/models/integration_customers/anrok_customer.rb @@ -4,3 +4,29 @@ module IntegrationCustomers class AnrokCustomer < BaseCustomer end end + +# == Schema Information +# +# Table name: integration_customers +# +# id :uuid not null, primary key +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# external_customer_id :string +# integration_id :uuid not null +# +# Indexes +# +# index_integration_customers_on_customer_id (customer_id) +# index_integration_customers_on_customer_id_and_type (customer_id,type) UNIQUE +# index_integration_customers_on_external_customer_id (external_customer_id) +# index_integration_customers_on_integration_id (integration_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_customers/base_customer.rb b/app/models/integration_customers/base_customer.rb index dceaa841fe0..25c7e23eef3 100644 --- a/app/models/integration_customers/base_customer.rb +++ b/app/models/integration_customers/base_customer.rb @@ -34,3 +34,29 @@ def self.customer_type(type) end end end + +# == Schema Information +# +# Table name: integration_customers +# +# id :uuid not null, primary key +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# external_customer_id :string +# integration_id :uuid not null +# +# Indexes +# +# index_integration_customers_on_customer_id (customer_id) +# index_integration_customers_on_customer_id_and_type (customer_id,type) UNIQUE +# index_integration_customers_on_external_customer_id (external_customer_id) +# index_integration_customers_on_integration_id (integration_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_customers/netsuite_customer.rb b/app/models/integration_customers/netsuite_customer.rb index 50490a9cfd3..9ae0c38568b 100644 --- a/app/models/integration_customers/netsuite_customer.rb +++ b/app/models/integration_customers/netsuite_customer.rb @@ -5,3 +5,29 @@ class NetsuiteCustomer < BaseCustomer settings_accessors :subsidiary_id end end + +# == Schema Information +# +# Table name: integration_customers +# +# id :uuid not null, primary key +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# external_customer_id :string +# integration_id :uuid not null +# +# Indexes +# +# index_integration_customers_on_customer_id (customer_id) +# index_integration_customers_on_customer_id_and_type (customer_id,type) UNIQUE +# index_integration_customers_on_external_customer_id (external_customer_id) +# index_integration_customers_on_integration_id (integration_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_customers/xero_customer.rb b/app/models/integration_customers/xero_customer.rb index cde1061f46c..4b2481abe11 100644 --- a/app/models/integration_customers/xero_customer.rb +++ b/app/models/integration_customers/xero_customer.rb @@ -4,3 +4,29 @@ module IntegrationCustomers class XeroCustomer < BaseCustomer end end + +# == Schema Information +# +# Table name: integration_customers +# +# id :uuid not null, primary key +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# external_customer_id :string +# integration_id :uuid not null +# +# Indexes +# +# index_integration_customers_on_customer_id (customer_id) +# index_integration_customers_on_customer_id_and_type (customer_id,type) UNIQUE +# index_integration_customers_on_external_customer_id (external_customer_id) +# index_integration_customers_on_integration_id (integration_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_item.rb b/app/models/integration_item.rb index 7bb1d98b3ec..62ad5953b78 100644 --- a/app/models/integration_item.rb +++ b/app/models/integration_item.rb @@ -19,3 +19,26 @@ def self.ransackable_attributes(_auth_object = nil) %w[external_account_code external_id external_name] end end + +# == Schema Information +# +# Table name: integration_items +# +# id :uuid not null, primary key +# external_account_code :string +# external_name :string +# item_type :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# external_id :string not null +# integration_id :uuid not null +# +# Indexes +# +# index_int_items_on_external_id_and_int_id_and_type (external_id,integration_id,item_type) UNIQUE +# index_integration_items_on_integration_id (integration_id) +# +# Foreign Keys +# +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_mappings/anrok_mapping.rb b/app/models/integration_mappings/anrok_mapping.rb index 79090636ade..1a5d1942a96 100644 --- a/app/models/integration_mappings/anrok_mapping.rb +++ b/app/models/integration_mappings/anrok_mapping.rb @@ -4,3 +4,26 @@ module IntegrationMappings class AnrokMapping < BaseMapping end end + +# == Schema Information +# +# Table name: integration_mappings +# +# id :uuid not null, primary key +# mappable_type :string not null +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# integration_id :uuid not null +# mappable_id :uuid not null +# +# Indexes +# +# index_integration_mappings_on_integration_id (integration_id) +# index_integration_mappings_on_mappable (mappable_type,mappable_id) +# +# Foreign Keys +# +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_mappings/base_mapping.rb b/app/models/integration_mappings/base_mapping.rb index 99e7dcfe15b..ef3235f0911 100644 --- a/app/models/integration_mappings/base_mapping.rb +++ b/app/models/integration_mappings/base_mapping.rb @@ -15,3 +15,26 @@ class BaseMapping < ApplicationRecord settings_accessors :external_id, :external_account_code, :external_name end end + +# == Schema Information +# +# Table name: integration_mappings +# +# id :uuid not null, primary key +# mappable_type :string not null +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# integration_id :uuid not null +# mappable_id :uuid not null +# +# Indexes +# +# index_integration_mappings_on_integration_id (integration_id) +# index_integration_mappings_on_mappable (mappable_type,mappable_id) +# +# Foreign Keys +# +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_mappings/netsuite_mapping.rb b/app/models/integration_mappings/netsuite_mapping.rb index 63e2a148e88..b08d1dc0a86 100644 --- a/app/models/integration_mappings/netsuite_mapping.rb +++ b/app/models/integration_mappings/netsuite_mapping.rb @@ -4,3 +4,26 @@ module IntegrationMappings class NetsuiteMapping < BaseMapping end end + +# == Schema Information +# +# Table name: integration_mappings +# +# id :uuid not null, primary key +# mappable_type :string not null +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# integration_id :uuid not null +# mappable_id :uuid not null +# +# Indexes +# +# index_integration_mappings_on_integration_id (integration_id) +# index_integration_mappings_on_mappable (mappable_type,mappable_id) +# +# Foreign Keys +# +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_mappings/xero_mapping.rb b/app/models/integration_mappings/xero_mapping.rb index f8c72438584..190d7db650b 100644 --- a/app/models/integration_mappings/xero_mapping.rb +++ b/app/models/integration_mappings/xero_mapping.rb @@ -4,3 +4,26 @@ module IntegrationMappings class XeroMapping < BaseMapping end end + +# == Schema Information +# +# Table name: integration_mappings +# +# id :uuid not null, primary key +# mappable_type :string not null +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# integration_id :uuid not null +# mappable_id :uuid not null +# +# Indexes +# +# index_integration_mappings_on_integration_id (integration_id) +# index_integration_mappings_on_mappable (mappable_type,mappable_id) +# +# Foreign Keys +# +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integration_resource.rb b/app/models/integration_resource.rb index 03864f46ea7..49fc644cc9c 100644 --- a/app/models/integration_resource.rb +++ b/app/models/integration_resource.rb @@ -8,3 +8,26 @@ class IntegrationResource < ApplicationRecord enum resource_type: RESOURCE_TYPES end + +# == Schema Information +# +# Table name: integration_resources +# +# id :uuid not null, primary key +# resource_type :integer default("invoice"), not null +# syncable_type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# external_id :string +# integration_id :uuid +# syncable_id :uuid not null +# +# Indexes +# +# index_integration_resources_on_integration_id (integration_id) +# index_integration_resources_on_syncable (syncable_type,syncable_id) +# +# Foreign Keys +# +# fk_rails_... (integration_id => integrations.id) +# diff --git a/app/models/integrations/anrok_integration.rb b/app/models/integrations/anrok_integration.rb index 73fb45022fd..770101d75d6 100644 --- a/app/models/integrations/anrok_integration.rb +++ b/app/models/integrations/anrok_integration.rb @@ -11,3 +11,27 @@ class AnrokIntegration < BaseIntegration secrets_accessors :connection_id, :api_key end end + +# == Schema Information +# +# Table name: integrations +# +# id :uuid not null, primary key +# code :string not null +# name :string not null +# secrets :string +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_integrations_on_code_and_organization_id (code,organization_id) UNIQUE +# index_integrations_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/integrations/base_integration.rb b/app/models/integrations/base_integration.rb index 5d184003041..ea8f4234654 100644 --- a/app/models/integrations/base_integration.rb +++ b/app/models/integrations/base_integration.rb @@ -44,3 +44,27 @@ def self.integration_type(type) end end end + +# == Schema Information +# +# Table name: integrations +# +# id :uuid not null, primary key +# code :string not null +# name :string not null +# secrets :string +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_integrations_on_code_and_organization_id (code,organization_id) UNIQUE +# index_integrations_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/integrations/netsuite_integration.rb b/app/models/integrations/netsuite_integration.rb index d174e96da13..7abe98e8794 100644 --- a/app/models/integrations/netsuite_integration.rb +++ b/app/models/integrations/netsuite_integration.rb @@ -22,3 +22,27 @@ def account_id end end end + +# == Schema Information +# +# Table name: integrations +# +# id :uuid not null, primary key +# code :string not null +# name :string not null +# secrets :string +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_integrations_on_code_and_organization_id (code,organization_id) UNIQUE +# index_integrations_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/integrations/okta_integration.rb b/app/models/integrations/okta_integration.rb index 0c0c2ee844a..b146c37eb0e 100644 --- a/app/models/integrations/okta_integration.rb +++ b/app/models/integrations/okta_integration.rb @@ -20,3 +20,27 @@ def domain_uniqueness end end end + +# == Schema Information +# +# Table name: integrations +# +# id :uuid not null, primary key +# code :string not null +# name :string not null +# secrets :string +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_integrations_on_code_and_organization_id (code,organization_id) UNIQUE +# index_integrations_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/integrations/xero_integration.rb b/app/models/integrations/xero_integration.rb index a420d5d4af5..fd0c5296dce 100644 --- a/app/models/integrations/xero_integration.rb +++ b/app/models/integrations/xero_integration.rb @@ -8,3 +8,27 @@ class XeroIntegration < BaseIntegration secrets_accessors :connection_id end end + +# == Schema Information +# +# Table name: integrations +# +# id :uuid not null, primary key +# code :string not null +# name :string not null +# secrets :string +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_integrations_on_code_and_organization_id (code,organization_id) UNIQUE +# index_integrations_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/invite.rb b/app/models/invite.rb index 672c7b03fa2..6a3337476ec 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -28,3 +28,31 @@ def mark_as_accepted!(timestamp = Time.current) accepted! end end + +# == Schema Information +# +# Table name: invites +# +# id :uuid not null, primary key +# accepted_at :datetime +# email :string not null +# revoked_at :datetime +# role :integer default("admin"), not null +# status :integer default("pending"), not null +# token :string not null +# created_at :datetime not null +# updated_at :datetime not null +# membership_id :uuid +# organization_id :uuid not null +# +# Indexes +# +# index_invites_on_membership_id (membership_id) +# index_invites_on_organization_id (organization_id) +# index_invites_on_token (token) UNIQUE +# +# Foreign Keys +# +# fk_rails_... (membership_id => memberships.id) +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 3e4b7fbab6a..eacd0840f36 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -397,3 +397,61 @@ def status_changed_to_finalized? status_changed?(from: 'failed', to: 'finalized') end end + +# == Schema Information +# +# Table name: invoices +# +# id :uuid not null, primary key +# coupons_amount_cents :bigint default(0), not null +# credit_notes_amount_cents :bigint default(0), not null +# currency :string +# fees_amount_cents :bigint default(0), not null +# file :string +# invoice_type :integer default("subscription"), not null +# issuing_date :date +# negative_amount_cents :bigint default(0), not null +# net_payment_term :integer default(0), not null +# number :string default(""), not null +# payment_attempts :integer default(0), not null +# payment_dispute_lost_at :datetime +# payment_due_date :date +# payment_overdue :boolean default(FALSE) +# payment_status :integer default("pending"), not null +# prepaid_credit_amount_cents :bigint default(0), not null +# ready_for_payment_processing :boolean default(TRUE), not null +# ready_to_be_refreshed :boolean default(FALSE), not null +# skip_charges :boolean default(FALSE), not null +# status :integer default("finalized"), not null +# sub_total_excluding_taxes_amount_cents :bigint default(0), not null +# sub_total_including_taxes_amount_cents :bigint default(0), not null +# taxes_amount_cents :bigint default(0), not null +# taxes_rate :float default(0.0), not null +# timezone :string default("UTC"), not null +# total_amount_cents :bigint default(0), not null +# version_number :integer default(4), not null +# voided_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid +# organization_id :uuid not null +# organization_sequential_id :integer default(0), not null +# payable_group_id :uuid +# sequential_id :integer +# +# Indexes +# +# index_invoices_on_customer_id (customer_id) +# index_invoices_on_customer_id_and_sequential_id (customer_id,sequential_id) UNIQUE +# index_invoices_on_number (number) +# index_invoices_on_organization_id (organization_id) +# index_invoices_on_payable_group_id (payable_group_id) +# index_invoices_on_payment_overdue (payment_overdue) +# index_invoices_on_sequential_id (sequential_id) +# index_invoices_on_status (status) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/invoice/applied_tax.rb b/app/models/invoice/applied_tax.rb index 1a1b6f9d257..abdc286aebc 100644 --- a/app/models/invoice/applied_tax.rb +++ b/app/models/invoice/applied_tax.rb @@ -16,3 +16,32 @@ class AppliedTax < ApplicationRecord validates :amount_cents, numericality: {greater_than_or_equal_to: 0} end end + +# == Schema Information +# +# Table name: invoices_taxes +# +# id :uuid not null, primary key +# amount_cents :bigint default(0), not null +# amount_currency :string not null +# fees_amount_cents :bigint default(0), not null +# tax_code :string not null +# tax_description :string +# tax_name :string not null +# tax_rate :float default(0.0), not null +# created_at :datetime not null +# updated_at :datetime not null +# invoice_id :uuid not null +# tax_id :uuid +# +# Indexes +# +# index_invoices_taxes_on_invoice_id (invoice_id) +# index_invoices_taxes_on_invoice_id_and_tax_id (invoice_id,tax_id) UNIQUE WHERE ((tax_id IS NOT NULL) AND (created_at >= '2023-09-12 00:00:00'::timestamp without time zone)) +# index_invoices_taxes_on_tax_id (tax_id) +# +# Foreign Keys +# +# fk_rails_... (invoice_id => invoices.id) +# fk_rails_... (tax_id => taxes.id) +# diff --git a/app/models/invoice_subscription.rb b/app/models/invoice_subscription.rb index ca0258d5625..3c1c38348c2 100644 --- a/app/models/invoice_subscription.rb +++ b/app/models/invoice_subscription.rb @@ -97,3 +97,36 @@ def total_amount_currency alias_method :charge_amount_currency, :total_amount_currency alias_method :subscription_amount_currency, :total_amount_currency end + +# == Schema Information +# +# Table name: invoice_subscriptions +# +# id :uuid not null, primary key +# charges_from_datetime :datetime +# charges_to_datetime :datetime +# from_datetime :datetime +# invoicing_reason :enum +# recurring :boolean +# timestamp :datetime +# to_datetime :datetime +# created_at :datetime not null +# updated_at :datetime not null +# invoice_id :uuid not null +# subscription_id :uuid not null +# +# Indexes +# +# index_invoice_subscriptions_boundaries (subscription_id,from_datetime,to_datetime) +# index_invoice_subscriptions_on_charges_from_and_to_datetime (subscription_id,charges_from_datetime,charges_to_datetime) UNIQUE WHERE ((created_at >= '2023-06-09 00:00:00'::timestamp without time zone) AND (recurring IS TRUE)) +# index_invoice_subscriptions_on_invoice_id (invoice_id) +# index_invoice_subscriptions_on_invoice_id_and_subscription_id (invoice_id,subscription_id) UNIQUE WHERE (created_at >= '2023-11-23 00:00:00'::timestamp without time zone) +# index_invoice_subscriptions_on_subscription_id (subscription_id) +# index_unique_starting_subscription_invoice (subscription_id,invoicing_reason) UNIQUE WHERE (invoicing_reason = 'subscription_starting'::subscription_invoicing_reason) +# index_unique_terminating_subscription_invoice (subscription_id,invoicing_reason) UNIQUE WHERE (invoicing_reason = 'subscription_terminating'::subscription_invoicing_reason) +# +# Foreign Keys +# +# fk_rails_... (invoice_id => invoices.id) +# fk_rails_... (subscription_id => subscriptions.id) +# diff --git a/app/models/lifetime_usage.rb b/app/models/lifetime_usage.rb index df72700e2a4..a54742e8fe8 100644 --- a/app/models/lifetime_usage.rb +++ b/app/models/lifetime_usage.rb @@ -17,3 +17,33 @@ class LifetimeUsage < ApplicationRecord default_scope -> { kept } end + +# == Schema Information +# +# Table name: lifetime_usages +# +# id :uuid not null, primary key +# current_usage_amount_cents :bigint default(0), not null +# current_usage_amount_refreshed_at :datetime +# deleted_at :datetime +# invoiced_usage_amount_cents :bigint default(0), not null +# invoiced_usage_amount_refreshed_at :datetime +# recalculate_current_usage :boolean default(FALSE), not null +# recalculate_invoiced_usage :boolean default(FALSE), not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# subscription_id :uuid not null +# +# Indexes +# +# index_lifetime_usages_on_organization_id (organization_id) +# index_lifetime_usages_on_recalculate_current_usage (recalculate_current_usage) WHERE ((deleted_at IS NULL) AND (recalculate_current_usage = true)) +# index_lifetime_usages_on_recalculate_invoiced_usage (recalculate_invoiced_usage) WHERE ((deleted_at IS NULL) AND (recalculate_invoiced_usage = true)) +# index_lifetime_usages_on_subscription_id (subscription_id) UNIQUE +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# fk_rails_... (subscription_id => subscriptions.id) +# diff --git a/app/models/membership.rb b/app/models/membership.rb index 85e15640f0c..cc0b8e5be84 100644 --- a/app/models/membership.rb +++ b/app/models/membership.rb @@ -46,3 +46,28 @@ def permissions_hash end end end + +# == Schema Information +# +# Table name: memberships +# +# id :uuid not null, primary key +# revoked_at :datetime +# role :integer default("admin"), not null +# status :integer default("active"), not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# user_id :uuid not null +# +# Indexes +# +# index_memberships_on_organization_id (organization_id) +# index_memberships_on_user_id (user_id) +# index_memberships_on_user_id_and_organization_id (user_id,organization_id) UNIQUE WHERE (revoked_at IS NULL) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# fk_rails_... (user_id => users.id) +# diff --git a/app/models/metadata/customer_metadata.rb b/app/models/metadata/customer_metadata.rb index 9b989349165..07e868d888a 100644 --- a/app/models/metadata/customer_metadata.rb +++ b/app/models/metadata/customer_metadata.rb @@ -12,3 +12,25 @@ class CustomerMetadata < ApplicationRecord scope :displayable, -> { where(display_in_invoice: true) } end end + +# == Schema Information +# +# Table name: customer_metadata +# +# id :uuid not null, primary key +# display_in_invoice :boolean default(FALSE), not null +# key :string not null +# value :string not null +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# +# Indexes +# +# index_customer_metadata_on_customer_id (customer_id) +# index_customer_metadata_on_customer_id_and_key (customer_id,key) UNIQUE +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# diff --git a/app/models/metadata/invoice_metadata.rb b/app/models/metadata/invoice_metadata.rb index 71294a5d5f3..c649ae8c179 100644 --- a/app/models/metadata/invoice_metadata.rb +++ b/app/models/metadata/invoice_metadata.rb @@ -10,3 +10,24 @@ class InvoiceMetadata < ApplicationRecord validates :value, presence: true end end + +# == Schema Information +# +# Table name: invoice_metadata +# +# id :uuid not null, primary key +# key :string not null +# value :string not null +# created_at :datetime not null +# updated_at :datetime not null +# invoice_id :uuid not null +# +# Indexes +# +# index_invoice_metadata_on_invoice_id (invoice_id) +# index_invoice_metadata_on_invoice_id_and_key (invoice_id,key) UNIQUE +# +# Foreign Keys +# +# fk_rails_... (invoice_id => invoices.id) +# diff --git a/app/models/organization.rb b/app/models/organization.rb index e1e954342d3..165b76c304f 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -133,3 +133,44 @@ def validate_email_settings errors.add(:email_settings, :unsupported_value) end end + +# == Schema Information +# +# Table name: organizations +# +# id :uuid not null, primary key +# address_line1 :string +# address_line2 :string +# api_key :string +# city :string +# clickhouse_aggregation :boolean default(FALSE), not null +# country :string +# custom_aggregation :boolean default(FALSE) +# default_currency :string default("USD"), not null +# document_locale :string default("en"), not null +# document_number_prefix :string +# document_numbering :integer default("per_customer"), not null +# email :string +# email_settings :string default([]), not null, is an Array +# eu_tax_management :boolean default(FALSE) +# invoice_footer :text +# invoice_grace_period :integer default(0), not null +# legal_name :string +# legal_number :string +# logo :string +# name :string not null +# net_payment_term :integer default(0), not null +# premium_integrations :string default([]), not null, is an Array +# state :string +# tax_identification_number :string +# timezone :string default("UTC"), not null +# vat_rate :float default(0.0), not null +# webhook_url :string +# zipcode :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_organizations_on_api_key (api_key) UNIQUE +# diff --git a/app/models/password_reset.rb b/app/models/password_reset.rb index cf9aba33d4c..ec201d64524 100644 --- a/app/models/password_reset.rb +++ b/app/models/password_reset.rb @@ -6,3 +6,24 @@ class PasswordReset < ApplicationRecord validates :token, presence: true, uniqueness: true validates :expire_at, presence: true end + +# == Schema Information +# +# Table name: password_resets +# +# id :uuid not null, primary key +# expire_at :datetime not null +# token :string not null +# created_at :datetime not null +# updated_at :datetime not null +# user_id :uuid not null +# +# Indexes +# +# index_password_resets_on_token (token) UNIQUE +# index_password_resets_on_user_id (user_id) +# +# Foreign Keys +# +# fk_rails_... (user_id => users.id) +# diff --git a/app/models/payable_group.rb b/app/models/payable_group.rb index e6508e48c0c..56ec776a4a6 100644 --- a/app/models/payable_group.rb +++ b/app/models/payable_group.rb @@ -14,3 +14,25 @@ class PayableGroup < ApplicationRecord enum payment_status: PAYMENT_STATUS, _prefix: :payment end + +# == Schema Information +# +# Table name: payable_groups +# +# id :uuid not null, primary key +# payment_status :integer default("pending"), not null +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# organization_id :uuid not null +# +# Indexes +# +# index_payable_groups_on_customer_id (customer_id) +# index_payable_groups_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/payment.rb b/app/models/payment.rb index 9f810d33491..4ddbe1475c3 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -19,3 +19,36 @@ def should_sync_payment? payable.finalized? && customer.integration_customers.accounting_kind.any? { |c| c.integration.sync_payments } end end + +# == Schema Information +# +# Table name: payments +# +# id :uuid not null, primary key +# amount_cents :bigint not null +# amount_currency :string not null +# payable_type :string default("Invoice"), not null +# status :string not null +# created_at :datetime not null +# updated_at :datetime not null +# invoice_id :uuid +# payable_id :uuid +# payment_provider_customer_id :uuid +# payment_provider_id :uuid +# payment_request_id :uuid +# provider_payment_id :string not null +# +# Indexes +# +# index_payments_on_invoice_id (invoice_id) +# index_payments_on_payable_type_and_payable_id (payable_type,payable_id) +# index_payments_on_payment_provider_customer_id (payment_provider_customer_id) +# index_payments_on_payment_provider_id (payment_provider_id) +# index_payments_on_payment_request_id (payment_request_id) +# +# Foreign Keys +# +# fk_rails_... (invoice_id => invoices.id) +# fk_rails_... (payment_provider_id => payment_providers.id) +# fk_rails_... (payment_request_id => payment_requests.id) +# diff --git a/app/models/payment_provider_customers/adyen_customer.rb b/app/models/payment_provider_customers/adyen_customer.rb index d5d955831f5..491c105aa02 100644 --- a/app/models/payment_provider_customers/adyen_customer.rb +++ b/app/models/payment_provider_customers/adyen_customer.rb @@ -5,3 +5,28 @@ class AdyenCustomer < BaseCustomer settings_accessors :payment_method_id end end + +# == Schema Information +# +# Table name: payment_provider_customers +# +# id :uuid not null, primary key +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# payment_provider_id :uuid +# provider_customer_id :string +# +# Indexes +# +# index_payment_provider_customers_on_customer_id_and_type (customer_id,type) UNIQUE +# index_payment_provider_customers_on_payment_provider_id (payment_provider_id) +# index_payment_provider_customers_on_provider_customer_id (provider_customer_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (payment_provider_id => payment_providers.id) +# diff --git a/app/models/payment_provider_customers/base_customer.rb b/app/models/payment_provider_customers/base_customer.rb index c0928b8b168..7852f98742d 100644 --- a/app/models/payment_provider_customers/base_customer.rb +++ b/app/models/payment_provider_customers/base_customer.rb @@ -22,3 +22,28 @@ def provider_payment_methods end end end + +# == Schema Information +# +# Table name: payment_provider_customers +# +# id :uuid not null, primary key +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# payment_provider_id :uuid +# provider_customer_id :string +# +# Indexes +# +# index_payment_provider_customers_on_customer_id_and_type (customer_id,type) UNIQUE +# index_payment_provider_customers_on_payment_provider_id (payment_provider_id) +# index_payment_provider_customers_on_provider_customer_id (provider_customer_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (payment_provider_id => payment_providers.id) +# diff --git a/app/models/payment_provider_customers/gocardless_customer.rb b/app/models/payment_provider_customers/gocardless_customer.rb index 2479fc89db9..742d4db395d 100644 --- a/app/models/payment_provider_customers/gocardless_customer.rb +++ b/app/models/payment_provider_customers/gocardless_customer.rb @@ -4,3 +4,28 @@ module PaymentProviderCustomers class GocardlessCustomer < BaseCustomer end end + +# == Schema Information +# +# Table name: payment_provider_customers +# +# id :uuid not null, primary key +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# payment_provider_id :uuid +# provider_customer_id :string +# +# Indexes +# +# index_payment_provider_customers_on_customer_id_and_type (customer_id,type) UNIQUE +# index_payment_provider_customers_on_payment_provider_id (payment_provider_id) +# index_payment_provider_customers_on_provider_customer_id (provider_customer_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (payment_provider_id => payment_providers.id) +# diff --git a/app/models/payment_provider_customers/stripe_customer.rb b/app/models/payment_provider_customers/stripe_customer.rb index b94302378d1..820328252d8 100644 --- a/app/models/payment_provider_customers/stripe_customer.rb +++ b/app/models/payment_provider_customers/stripe_customer.rb @@ -33,3 +33,28 @@ def link_payment_method_can_exist_only_with_card end end end + +# == Schema Information +# +# Table name: payment_provider_customers +# +# id :uuid not null, primary key +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# payment_provider_id :uuid +# provider_customer_id :string +# +# Indexes +# +# index_payment_provider_customers_on_customer_id_and_type (customer_id,type) UNIQUE +# index_payment_provider_customers_on_payment_provider_id (payment_provider_id) +# index_payment_provider_customers_on_provider_customer_id (provider_customer_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (payment_provider_id => payment_providers.id) +# diff --git a/app/models/payment_providers/adyen_provider.rb b/app/models/payment_providers/adyen_provider.rb index 1a522ca10a7..f2336cd3e14 100644 --- a/app/models/payment_providers/adyen_provider.rb +++ b/app/models/payment_providers/adyen_provider.rb @@ -19,3 +19,27 @@ def environment end end end + +# == Schema Information +# +# Table name: payment_providers +# +# id :uuid not null, primary key +# code :string not null +# name :string not null +# secrets :string +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_payment_providers_on_code_and_organization_id (code,organization_id) UNIQUE +# index_payment_providers_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/payment_providers/base_provider.rb b/app/models/payment_providers/base_provider.rb index dba09f0f27b..66c296314c5 100644 --- a/app/models/payment_providers/base_provider.rb +++ b/app/models/payment_providers/base_provider.rb @@ -24,3 +24,27 @@ class BaseProvider < ApplicationRecord settings_accessors :webhook_secret, :success_redirect_url end end + +# == Schema Information +# +# Table name: payment_providers +# +# id :uuid not null, primary key +# code :string not null +# name :string not null +# secrets :string +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_payment_providers_on_code_and_organization_id (code,organization_id) UNIQUE +# index_payment_providers_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/payment_providers/gocardless_provider.rb b/app/models/payment_providers/gocardless_provider.rb index 805200b1ba4..89a2ce03c31 100644 --- a/app/models/payment_providers/gocardless_provider.rb +++ b/app/models/payment_providers/gocardless_provider.rb @@ -26,3 +26,27 @@ def environment end end end + +# == Schema Information +# +# Table name: payment_providers +# +# id :uuid not null, primary key +# code :string not null +# name :string not null +# secrets :string +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_payment_providers_on_code_and_organization_id (code,organization_id) UNIQUE +# index_payment_providers_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/payment_providers/stripe_provider.rb b/app/models/payment_providers/stripe_provider.rb index 0e00ef33b8d..6ac54807703 100644 --- a/app/models/payment_providers/stripe_provider.rb +++ b/app/models/payment_providers/stripe_provider.rb @@ -23,3 +23,27 @@ class StripeProvider < BaseProvider secrets_accessors :secret_key end end + +# == Schema Information +# +# Table name: payment_providers +# +# id :uuid not null, primary key +# code :string not null +# name :string not null +# secrets :string +# settings :jsonb not null +# type :string not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_payment_providers_on_code_and_organization_id (code,organization_id) UNIQUE +# index_payment_providers_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/payment_request.rb b/app/models/payment_request.rb index eb6aeb18264..a25140596d9 100644 --- a/app/models/payment_request.rb +++ b/app/models/payment_request.rb @@ -16,3 +16,30 @@ def invoices payment_requestable.is_a?(Invoice) ? [payment_requestable] : payment_requestable.invoices end end + +# == Schema Information +# +# Table name: payment_requests +# +# id :uuid not null, primary key +# amount_cents :bigint default(0), not null +# amount_currency :string not null +# email :string not null +# payment_requestable_type :string default("Invoice"), not null +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# organization_id :uuid not null +# payment_requestable_id :uuid not null +# +# Indexes +# +# idx_on_payment_requestable_type_payment_requestable_b151968780 (payment_requestable_type,payment_requestable_id) +# index_payment_requests_on_customer_id (customer_id) +# index_payment_requests_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/plan.rb b/app/models/plan.rb index e39b1651c9f..f5fb46514c4 100644 --- a/app/models/plan.rb +++ b/app/models/plan.rb @@ -106,3 +106,39 @@ def validate_code_unique errors.add(:code, :taken) if plan && plan != self end end + +# == Schema Information +# +# Table name: plans +# +# id :uuid not null, primary key +# amount_cents :bigint not null +# amount_currency :string not null +# bill_charges_monthly :boolean +# code :string not null +# deleted_at :datetime +# description :string +# interval :integer not null +# invoice_display_name :string +# name :string not null +# pay_in_advance :boolean default(FALSE), not null +# pending_deletion :boolean default(FALSE), not null +# trial_period :float +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# parent_id :uuid +# +# Indexes +# +# index_plans_on_created_at (created_at) +# index_plans_on_deleted_at (deleted_at) +# index_plans_on_organization_id (organization_id) +# index_plans_on_organization_id_and_code (organization_id,code) UNIQUE WHERE ((deleted_at IS NULL) AND (parent_id IS NULL)) +# index_plans_on_parent_id (parent_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# fk_rails_... (parent_id => plans.id) +# diff --git a/app/models/plan/applied_tax.rb b/app/models/plan/applied_tax.rb index b30b77751cb..c7a0a9ee152 100644 --- a/app/models/plan/applied_tax.rb +++ b/app/models/plan/applied_tax.rb @@ -10,3 +10,25 @@ class AppliedTax < ApplicationRecord belongs_to :tax end end + +# == Schema Information +# +# Table name: plans_taxes +# +# id :uuid not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# plan_id :uuid not null +# tax_id :uuid not null +# +# Indexes +# +# index_plans_taxes_on_plan_id (plan_id) +# index_plans_taxes_on_plan_id_and_tax_id (plan_id,tax_id) UNIQUE +# index_plans_taxes_on_tax_id (tax_id) +# +# Foreign Keys +# +# fk_rails_... (plan_id => plans.id) +# fk_rails_... (tax_id => taxes.id) +# diff --git a/app/models/quantified_event.rb b/app/models/quantified_event.rb index 7331c29f8d7..dace6208db6 100644 --- a/app/models/quantified_event.rb +++ b/app/models/quantified_event.rb @@ -18,3 +18,38 @@ class QuantifiedEvent < ApplicationRecord default_scope -> { kept } end + +# == Schema Information +# +# Table name: quantified_events +# +# id :uuid not null, primary key +# added_at :datetime not null +# deleted_at :datetime +# grouped_by :jsonb not null +# properties :jsonb not null +# removed_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# billable_metric_id :uuid +# charge_filter_id :uuid +# external_id :string +# external_subscription_id :string not null +# group_id :uuid +# organization_id :uuid not null +# +# Indexes +# +# index_quantified_events_on_billable_metric_id (billable_metric_id) +# index_quantified_events_on_charge_filter_id (charge_filter_id) +# index_quantified_events_on_deleted_at (deleted_at) +# index_quantified_events_on_external_id (external_id) +# index_quantified_events_on_group_id (group_id) +# index_quantified_events_on_organization_id (organization_id) +# index_search_quantified_events (organization_id,external_subscription_id,billable_metric_id) +# +# Foreign Keys +# +# fk_rails_... (group_id => groups.id) +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/recurring_transaction_rule.rb b/app/models/recurring_transaction_rule.rb index 9f2993f7cf5..66dff41bd2e 100644 --- a/app/models/recurring_transaction_rule.rb +++ b/app/models/recurring_transaction_rule.rb @@ -26,3 +26,32 @@ class RecurringTransactionRule < ApplicationRecord enum method: METHODS enum trigger: TRIGGERS end + +# == Schema Information +# +# Table name: recurring_transaction_rules +# +# id :uuid not null, primary key +# granted_credits :decimal(30, 5) default(0.0), not null +# interval :integer default("weekly") +# invoice_requires_successful_payment :boolean default(FALSE), not null +# method :integer default("fixed"), not null +# paid_credits :decimal(30, 5) default(0.0), not null +# started_at :datetime +# target_ongoing_balance :decimal(30, 5) +# threshold_credits :decimal(30, 5) default(0.0) +# transaction_metadata :jsonb +# trigger :integer default("interval"), not null +# created_at :datetime not null +# updated_at :datetime not null +# wallet_id :uuid not null +# +# Indexes +# +# index_recurring_transaction_rules_on_started_at (started_at) +# index_recurring_transaction_rules_on_wallet_id (wallet_id) +# +# Foreign Keys +# +# fk_rails_... (wallet_id => wallets.id) +# diff --git a/app/models/refund.rb b/app/models/refund.rb index 00d094e4813..ea85816cf15 100644 --- a/app/models/refund.rb +++ b/app/models/refund.rb @@ -8,3 +8,34 @@ class Refund < ApplicationRecord belongs_to :payment_provider, optional: true, class_name: 'PaymentProviders::BaseProvider' belongs_to :payment_provider_customer, class_name: 'PaymentProviderCustomers::BaseCustomer' end + +# == Schema Information +# +# Table name: refunds +# +# id :uuid not null, primary key +# amount_cents :bigint default(0), not null +# amount_currency :string not null +# status :string not null +# created_at :datetime not null +# updated_at :datetime not null +# credit_note_id :uuid not null +# payment_id :uuid not null +# payment_provider_customer_id :uuid not null +# payment_provider_id :uuid +# provider_refund_id :string not null +# +# Indexes +# +# index_refunds_on_credit_note_id (credit_note_id) +# index_refunds_on_payment_id (payment_id) +# index_refunds_on_payment_provider_customer_id (payment_provider_customer_id) +# index_refunds_on_payment_provider_id (payment_provider_id) +# +# Foreign Keys +# +# fk_rails_... (credit_note_id => credit_notes.id) +# fk_rails_... (payment_id => payments.id) +# fk_rails_... (payment_provider_customer_id => payment_provider_customers.id) +# fk_rails_... (payment_provider_id => payment_providers.id) +# diff --git a/app/models/subscription.rb b/app/models/subscription.rb index 9564dfa4cb8..8532002d0b0 100644 --- a/app/models/subscription.rb +++ b/app/models/subscription.rb @@ -165,3 +165,40 @@ def date_diff_with_timezone(from_datetime, to_datetime) number_od_days.negative? ? 0 : number_od_days end end + +# == Schema Information +# +# Table name: subscriptions +# +# id :uuid not null, primary key +# billing_time :integer default("calendar"), not null +# canceled_at :datetime +# ending_at :datetime +# name :string +# started_at :datetime +# status :integer not null +# subscription_at :datetime +# terminated_at :datetime +# trial_ended_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# external_id :string not null +# plan_id :uuid not null +# previous_subscription_id :uuid +# +# Indexes +# +# index_subscriptions_on_customer_id (customer_id) +# index_subscriptions_on_external_id (external_id) +# index_subscriptions_on_plan_id (plan_id) +# index_subscriptions_on_previous_subscription_id_and_status (previous_subscription_id,status) +# index_subscriptions_on_started_at (started_at) +# index_subscriptions_on_started_at_and_ending_at (started_at,ending_at) +# index_subscriptions_on_status (status) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# fk_rails_... (plan_id => plans.id) +# diff --git a/app/models/tax.rb b/app/models/tax.rb index 18907c21dc3..f643a97381d 100644 --- a/app/models/tax.rb +++ b/app/models/tax.rb @@ -51,3 +51,28 @@ def applicable_customers .or(organization.customers.where(id: customers.select(:id))) end end + +# == Schema Information +# +# Table name: taxes +# +# id :uuid not null, primary key +# applied_to_organization :boolean default(FALSE), not null +# auto_generated :boolean default(FALSE), not null +# code :string not null +# description :string +# name :string not null +# rate :float default(0.0), not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_taxes_on_code_and_organization_id (code,organization_id) UNIQUE +# index_taxes_on_organization_id (organization_id) +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/app/models/usage_threshold.rb b/app/models/usage_threshold.rb index 915834a7c29..2366d5f8775 100644 --- a/app/models/usage_threshold.rb +++ b/app/models/usage_threshold.rb @@ -19,3 +19,27 @@ class UsageThreshold < ApplicationRecord default_scope -> { kept } end + +# == Schema Information +# +# Table name: usage_thresholds +# +# id :uuid not null, primary key +# amount_cents :bigint not null +# deleted_at :datetime +# recurring :boolean default(FALSE), not null +# threshold_display_name :string +# created_at :datetime not null +# updated_at :datetime not null +# plan_id :uuid not null +# +# Indexes +# +# idx_on_amount_cents_plan_id_recurring_888044d66b (amount_cents,plan_id,recurring) UNIQUE WHERE (deleted_at IS NULL) +# index_usage_thresholds_on_plan_id (plan_id) +# index_usage_thresholds_on_plan_id_and_recurring (plan_id,recurring) UNIQUE WHERE ((recurring IS TRUE) AND (deleted_at IS NULL)) +# +# Foreign Keys +# +# fk_rails_... (plan_id => plans.id) +# diff --git a/app/models/user.rb b/app/models/user.rb index ea6ec8a7816..f986f2ceb80 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,3 +25,14 @@ def can?(permission, organization:) memberships.find { |m| m.organization_id == organization.id }&.can?(permission) end end + +# == Schema Information +# +# Table name: users +# +# id :uuid not null, primary key +# email :string +# password_digest :string +# created_at :datetime not null +# updated_at :datetime not null +# diff --git a/app/models/wallet.rb b/app/models/wallet.rb index d099a495973..d9a8165e154 100644 --- a/app/models/wallet.rb +++ b/app/models/wallet.rb @@ -36,3 +36,40 @@ def currency balance_currency end end + +# == Schema Information +# +# Table name: wallets +# +# id :uuid not null, primary key +# balance_cents :bigint default(0), not null +# balance_currency :string not null +# consumed_amount_cents :bigint default(0), not null +# consumed_amount_currency :string not null +# consumed_credits :decimal(30, 5) default(0.0), not null +# credits_balance :decimal(30, 5) default(0.0), not null +# credits_ongoing_balance :decimal(30, 5) default(0.0), not null +# credits_ongoing_usage_balance :decimal(30, 5) default(0.0), not null +# depleted_ongoing_balance :boolean default(FALSE), not null +# expiration_at :datetime +# invoice_requires_successful_payment :boolean default(FALSE), not null +# last_balance_sync_at :datetime +# last_consumed_credit_at :datetime +# name :string +# ongoing_balance_cents :bigint default(0), not null +# ongoing_usage_balance_cents :bigint default(0), not null +# rate_amount :decimal(30, 5) default(0.0), not null +# status :integer not null +# terminated_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# customer_id :uuid not null +# +# Indexes +# +# index_wallets_on_customer_id (customer_id) +# +# Foreign Keys +# +# fk_rails_... (customer_id => customers.id) +# diff --git a/app/models/wallet_transaction.rb b/app/models/wallet_transaction.rb index 29a0b9219c5..6cacaa4cf68 100644 --- a/app/models/wallet_transaction.rb +++ b/app/models/wallet_transaction.rb @@ -36,3 +36,33 @@ class WalletTransaction < ApplicationRecord scope :pending, -> { where(status: :pending) } end + +# == Schema Information +# +# Table name: wallet_transactions +# +# id :uuid not null, primary key +# amount :decimal(30, 5) default(0.0), not null +# credit_amount :decimal(30, 5) default(0.0), not null +# invoice_requires_successful_payment :boolean default(FALSE), not null +# metadata :jsonb +# settled_at :datetime +# source :integer default("manual"), not null +# status :integer not null +# transaction_status :integer default("purchased"), not null +# transaction_type :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# invoice_id :uuid +# wallet_id :uuid not null +# +# Indexes +# +# index_wallet_transactions_on_invoice_id (invoice_id) +# index_wallet_transactions_on_wallet_id (wallet_id) +# +# Foreign Keys +# +# fk_rails_... (invoice_id => invoices.id) +# fk_rails_... (wallet_id => wallets.id) +# diff --git a/app/models/webhook.rb b/app/models/webhook.rb index 747c24c61a9..b3ab9ac128e 100644 --- a/app/models/webhook.rb +++ b/app/models/webhook.rb @@ -65,3 +65,31 @@ def issuer ENV['LAGO_API_URL'] end end + +# == Schema Information +# +# Table name: webhooks +# +# id :uuid not null, primary key +# endpoint :string +# http_status :integer +# last_retried_at :datetime +# object_type :string +# payload :json +# response :json +# retries :integer default(0), not null +# status :integer default("pending"), not null +# webhook_type :string +# created_at :datetime not null +# updated_at :datetime not null +# object_id :uuid +# webhook_endpoint_id :uuid +# +# Indexes +# +# index_webhooks_on_webhook_endpoint_id (webhook_endpoint_id) +# +# Foreign Keys +# +# fk_rails_... (webhook_endpoint_id => webhook_endpoints.id) +# diff --git a/app/models/webhook_endpoint.rb b/app/models/webhook_endpoint.rb index c6605245a76..f3474ab2b85 100644 --- a/app/models/webhook_endpoint.rb +++ b/app/models/webhook_endpoint.rb @@ -28,3 +28,24 @@ def max_webhook_endpoints organization.webhook_endpoints.reload.count >= LIMIT end end + +# == Schema Information +# +# Table name: webhook_endpoints +# +# id :uuid not null, primary key +# signature_algo :integer default("jwt"), not null +# webhook_url :string not null +# created_at :datetime not null +# updated_at :datetime not null +# organization_id :uuid not null +# +# Indexes +# +# index_webhook_endpoints_on_organization_id (organization_id) +# index_webhook_endpoints_on_webhook_url_and_organization_id (webhook_url,organization_id) UNIQUE +# +# Foreign Keys +# +# fk_rails_... (organization_id => organizations.id) +# diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake new file mode 100644 index 00000000000..56890dadbf6 --- /dev/null +++ b/lib/tasks/auto_annotate_models.rake @@ -0,0 +1,59 @@ +# NOTE: only doing this in development as some production environments (Heroku) +# NOTE: are sensitive to local FS writes, and besides -- it's just not proper +# NOTE: to have a dev-mode tool do its thing in production. +if Rails.env.development? + require 'annotate' + task :set_annotation_options do + # You can override any of these by setting an environment variable of the + # same name. + Annotate.set_defaults( + 'active_admin' => 'false', + 'additional_file_patterns' => [], + 'routes' => 'false', + 'models' => 'true', + 'position_in_routes' => 'bottom', + 'position_in_class' => 'bottom', + 'position_in_test' => 'bottom', + 'position_in_fixture' => 'bottom', + 'position_in_factory' => 'bottom', + 'position_in_serializer' => 'bottom', + 'show_foreign_keys' => 'true', + 'show_complete_foreign_keys' => 'false', + 'show_indexes' => 'true', + 'simple_indexes' => 'false', + 'model_dir' => 'app/models', + 'root_dir' => '', + 'include_version' => 'false', + 'require' => '', + 'exclude_tests' => 'true', + 'exclude_fixtures' => 'false', + 'exclude_factories' => 'true', + 'exclude_serializers' => 'true', + 'exclude_scaffolds' => 'true', + 'exclude_controllers' => 'true', + 'exclude_helpers' => 'true', + 'exclude_sti_subclasses' => 'false', + 'ignore_model_sub_dir' => 'false', + 'ignore_columns' => nil, + 'ignore_routes' => nil, + 'ignore_unknown_models' => 'false', + 'hide_limit_column_types' => 'integer,bigint,boolean', + 'hide_default_column_types' => 'json,jsonb,hstore', + 'skip_on_db_migrate' => 'false', + 'format_bare' => 'true', + 'format_rdoc' => 'false', + 'format_yard' => 'false', + 'format_markdown' => 'false', + 'sort' => 'false', + 'force' => 'false', + 'frozen' => 'false', + 'classified_sort' => 'true', + 'trace' => 'false', + 'wrapper_open' => nil, + 'wrapper_close' => nil, + 'with_comment' => 'true' + ) + end + + Annotate.load_tasks +end