From 2e3315aac671ffb2fc8853abbf91cd5f0e644b2e Mon Sep 17 00:00:00 2001 From: Seth Herr Date: Thu, 6 Feb 2025 08:19:56 -0800 Subject: [PATCH] Update annotations --- app/models/alert_image.rb | 4 ++++ app/models/ambassador.rb | 7 ++++++- app/models/ambassador_task.rb | 4 ++++ app/models/ambassador_task_assignment.rb | 5 +++++ app/models/b_param.rb | 4 ++++ app/models/banned_email_domain.rb | 4 ++++ app/models/bike.rb | 20 +++++++++++++++++++ app/models/bike_organization.rb | 6 ++++++ app/models/bike_sticker.rb | 6 ++++++ app/models/bike_sticker_batch.rb | 5 +++++ app/models/bike_sticker_update.rb | 9 +++++++++ app/models/bike_version.rb | 14 +++++++++++++ app/models/blog_content_tag.rb | 5 +++++ app/models/component.rb | 6 ++++++ app/models/exchange_rate.rb | 4 ++++ app/models/export.rb | 5 +++++ app/models/external_registry_bike.rb | 7 +++++++ .../external_registry_bike/project529_bike.rb | 7 +++++++ .../stop_heling_bike.rb | 7 +++++++ .../verloren_of_gevonden_bike.rb | 7 +++++++ app/models/external_registry_credential.rb | 4 ++++ .../project529_credential.rb | 4 ++++ .../stop_heling_credential.rb | 4 ++++ app/models/feedback.rb | 5 +++++ app/models/graduated_notification.rb | 10 ++++++++++ app/models/hot_sheet.rb | 4 ++++ app/models/hot_sheet_configuration.rb | 4 ++++ app/models/impound_claim.rb | 9 +++++++++ app/models/impound_configuration.rb | 4 ++++ app/models/impound_record.rb | 9 +++++++++ app/models/impound_record_update.rb | 7 +++++++ app/models/integration.rb | 4 ++++ app/models/invoice.rb | 5 +++++ app/models/invoice_organization_feature.rb | 5 +++++ app/models/lock.rb | 4 ++++ app/models/mail_snippet.rb | 6 ++++++ app/models/mailchimp_datum.rb | 4 ++++ app/models/model_attestation.rb | 6 ++++++ app/models/model_audit.rb | 4 ++++ app/models/normalized_serial_segment.rb | 5 +++++ app/models/notification.rb | 6 ++++++ app/models/organization.rb | 7 +++++++ app/models/organization_manufacturer.rb | 5 +++++ app/models/organization_model_audit.rb | 5 +++++ app/models/organization_stolen_message.rb | 5 +++++ app/models/ownership.rb | 9 +++++++++ app/models/parking_notification.rb | 11 ++++++++++ app/models/payment.rb | 4 ++++ app/models/public_image.rb | 4 ++++ app/models/recovery_display.rb | 4 ++++ app/models/state.rb | 4 ++++ app/models/stolen_bike_listing.rb | 9 +++++++++ app/models/stolen_notification.rb | 4 ++++ app/models/stolen_record.rb | 7 +++++++ app/models/superuser_ability.rb | 4 ++++ app/models/theft_alert.rb | 8 ++++++++ app/models/tweet.rb | 6 ++++++ app/models/twitter_account.rb | 7 +++++++ app/models/user.rb | 7 ++++++- app/models/user_alert.rb | 8 ++++++++ app/models/user_ban.rb | 5 +++++ app/models/user_email.rb | 4 ++++ app/models/user_phone.rb | 4 ++++ app/models/user_registration_organization.rb | 5 +++++ 64 files changed, 383 insertions(+), 2 deletions(-) diff --git a/app/models/alert_image.rb b/app/models/alert_image.rb index 64be6e1944..904c4a83f7 100644 --- a/app/models/alert_image.rb +++ b/app/models/alert_image.rb @@ -8,6 +8,10 @@ # updated_at :datetime not null # stolen_record_id :integer not null # +# Indexes +# +# index_alert_images_on_stolen_record_id (stolen_record_id) +# # Foreign Keys # # fk_rails_... (stolen_record_id => stolen_records.id) diff --git a/app/models/ambassador.rb b/app/models/ambassador.rb index a3032bea24..ca982f472b 100644 --- a/app/models/ambassador.rb +++ b/app/models/ambassador.rb @@ -33,7 +33,6 @@ # partner_data :jsonb # password :text # password_digest :string(255) -# token_for_password_reset :text # phone :string(255) # preferred_language :string # show_bikes :boolean default(FALSE), not null @@ -46,6 +45,7 @@ # terms_of_service :boolean default(FALSE), not null # time_single_format :boolean default(FALSE) # title :text +# token_for_password_reset :text # twitter :string(255) # username :string(255) # vendor_terms_of_service :boolean @@ -57,6 +57,11 @@ # state_id :integer # stripe_id :string(255) # +# Indexes +# +# index_users_on_auth_token (auth_token) +# index_users_on_token_for_password_reset (token_for_password_reset) +# class Ambassador < User default_scope -> { ambassadors } diff --git a/app/models/ambassador_task.rb b/app/models/ambassador_task.rb index c4414ec00e..623b24b31e 100644 --- a/app/models/ambassador_task.rb +++ b/app/models/ambassador_task.rb @@ -8,6 +8,10 @@ # created_at :datetime not null # updated_at :datetime not null # +# Indexes +# +# index_ambassador_tasks_on_title (title) UNIQUE +# class AmbassadorTask < ApplicationRecord has_many :ambassador_task_assignments has_many :ambassadors, through: :ambassador_task_assignments diff --git a/app/models/ambassador_task_assignment.rb b/app/models/ambassador_task_assignment.rb index 97ae892c37..170232d022 100644 --- a/app/models/ambassador_task_assignment.rb +++ b/app/models/ambassador_task_assignment.rb @@ -9,6 +9,11 @@ # ambassador_task_id :integer not null # user_id :integer not null # +# Indexes +# +# index_ambassador_task_assignments_on_ambassador_task_id (ambassador_task_id) +# unique_assignment_to_ambassador (user_id,ambassador_task_id) UNIQUE +# # Foreign Keys # # fk_rails_... (ambassador_task_id => ambassador_tasks.id) ON DELETE => cascade diff --git a/app/models/b_param.rb b/app/models/b_param.rb index 35606a1990..6edb2d05d8 100644 --- a/app/models/b_param.rb +++ b/app/models/b_param.rb @@ -18,6 +18,10 @@ # creator_id :integer # organization_id :integer # +# Indexes +# +# index_b_params_on_organization_id (organization_id) +# # b_param stands for Bike param class BParam < ApplicationRecord diff --git a/app/models/banned_email_domain.rb b/app/models/banned_email_domain.rb index 723c8111cb..60a3d15587 100644 --- a/app/models/banned_email_domain.rb +++ b/app/models/banned_email_domain.rb @@ -11,6 +11,10 @@ # updated_at :datetime not null # creator_id :bigint # +# Indexes +# +# index_banned_email_domains_on_creator_id (creator_id) +# class BannedEmailDomain < ApplicationRecord BIKE_MAX_COUNT = 2 EMAIL_MIN_COUNT = 500 diff --git a/app/models/bike.rb b/app/models/bike.rb index 0b642e711a..99be5ec9f9 100644 --- a/app/models/bike.rb +++ b/app/models/bike.rb @@ -73,6 +73,26 @@ # tertiary_frame_color_id :integer # updator_id :integer # +# Indexes +# +# index_bikes_on_current_impound_record_id (current_impound_record_id) +# index_bikes_on_current_ownership_id (current_ownership_id) +# index_bikes_on_current_stolen_record_id (current_stolen_record_id) +# index_bikes_on_deleted_at (deleted_at) +# index_bikes_on_example (example) +# index_bikes_on_latitude_and_longitude (latitude,longitude) +# index_bikes_on_listing_order (listing_order) +# index_bikes_on_manufacturer_id (manufacturer_id) +# index_bikes_on_model_audit_id (model_audit_id) +# index_bikes_on_organization_id (creation_organization_id) +# index_bikes_on_paint_id (paint_id) +# index_bikes_on_primary_frame_color_id (primary_frame_color_id) +# index_bikes_on_secondary_frame_color_id (secondary_frame_color_id) +# index_bikes_on_state_id (state_id) +# index_bikes_on_status (status) +# index_bikes_on_tertiary_frame_color_id (tertiary_frame_color_id) +# index_bikes_on_user_hidden (user_hidden) +# class Bike < ApplicationRecord include ActiveModel::Dirty include BikeSearchable diff --git a/app/models/bike_organization.rb b/app/models/bike_organization.rb index 87a5d01616..d8fa06a462 100644 --- a/app/models/bike_organization.rb +++ b/app/models/bike_organization.rb @@ -10,6 +10,12 @@ # bike_id :integer # organization_id :integer # +# Indexes +# +# index_bike_organizations_on_bike_id (bike_id) +# index_bike_organizations_on_deleted_at (deleted_at) +# index_bike_organizations_on_organization_id (organization_id) +# class BikeOrganization < ApplicationRecord acts_as_paranoid diff --git a/app/models/bike_sticker.rb b/app/models/bike_sticker.rb index eb18ad280f..6db0354691 100644 --- a/app/models/bike_sticker.rb +++ b/app/models/bike_sticker.rb @@ -20,6 +20,12 @@ # secondary_organization_id :bigint # user_id :integer # +# Indexes +# +# index_bike_stickers_on_bike_id (bike_id) +# index_bike_stickers_on_bike_sticker_batch_id (bike_sticker_batch_id) +# index_bike_stickers_on_secondary_organization_id (secondary_organization_id) +# class BikeSticker < ApplicationRecord KIND_ENUM = {sticker: 0, spokecard: 1}.freeze MAX_UNORGANIZED = 20 diff --git a/app/models/bike_sticker_batch.rb b/app/models/bike_sticker_batch.rb index 7ed60b111a..0d4c854c67 100644 --- a/app/models/bike_sticker_batch.rb +++ b/app/models/bike_sticker_batch.rb @@ -11,6 +11,11 @@ # organization_id :integer # user_id :integer # +# Indexes +# +# index_bike_sticker_batches_on_organization_id (organization_id) +# index_bike_sticker_batches_on_user_id (user_id) +# class BikeStickerBatch < ApplicationRecord belongs_to :user # Creator of the batch belongs_to :organization diff --git a/app/models/bike_sticker_update.rb b/app/models/bike_sticker_update.rb index e666b54d7f..af683a792f 100644 --- a/app/models/bike_sticker_update.rb +++ b/app/models/bike_sticker_update.rb @@ -17,6 +17,15 @@ # organization_id :bigint # user_id :bigint # +# Indexes +# +# index_bike_sticker_updates_on_bike_id (bike_id) +# index_bike_sticker_updates_on_bike_sticker_id (bike_sticker_id) +# index_bike_sticker_updates_on_bulk_import_id (bulk_import_id) +# index_bike_sticker_updates_on_export_id (export_id) +# index_bike_sticker_updates_on_organization_id (organization_id) +# index_bike_sticker_updates_on_user_id (user_id) +# class BikeStickerUpdate < ApplicationRecord KIND_ENUM = {initial_claim: 0, re_claim: 1, un_claim: 2, failed_claim: 3, admin_reassign: 4}.freeze CREATOR_KIND_ENUM = {creator_user: 0, creator_export: 1, creator_pos: 2, creator_bike_creation: 3, creator_import: 4}.freeze diff --git a/app/models/bike_version.rb b/app/models/bike_version.rb index d3a0fe6ca5..87dc3f42c8 100644 --- a/app/models/bike_version.rb +++ b/app/models/bike_version.rb @@ -45,6 +45,20 @@ # secondary_frame_color_id :bigint # tertiary_frame_color_id :bigint # +# Indexes +# +# index_bike_versions_on_bike_id (bike_id) +# index_bike_versions_on_front_gear_type_id (front_gear_type_id) +# index_bike_versions_on_front_wheel_size_id (front_wheel_size_id) +# index_bike_versions_on_manufacturer_id (manufacturer_id) +# index_bike_versions_on_owner_id (owner_id) +# index_bike_versions_on_paint_id (paint_id) +# index_bike_versions_on_primary_frame_color_id (primary_frame_color_id) +# index_bike_versions_on_rear_gear_type_id (rear_gear_type_id) +# index_bike_versions_on_rear_wheel_size_id (rear_wheel_size_id) +# index_bike_versions_on_secondary_frame_color_id (secondary_frame_color_id) +# index_bike_versions_on_tertiary_frame_color_id (tertiary_frame_color_id) +# class BikeVersion < ApplicationRecord include BikeSearchable include BikeAttributable diff --git a/app/models/blog_content_tag.rb b/app/models/blog_content_tag.rb index acfe679d2d..db136e1e0a 100644 --- a/app/models/blog_content_tag.rb +++ b/app/models/blog_content_tag.rb @@ -8,6 +8,11 @@ # blog_id :bigint # content_tag_id :bigint # +# Indexes +# +# index_blog_content_tags_on_blog_id (blog_id) +# index_blog_content_tags_on_content_tag_id (content_tag_id) +# class BlogContentTag < ApplicationRecord belongs_to :blog belongs_to :content_tag diff --git a/app/models/component.rb b/app/models/component.rb index 3db84ed399..4bb0038073 100644 --- a/app/models/component.rb +++ b/app/models/component.rb @@ -20,6 +20,12 @@ # ctype_id :integer # manufacturer_id :integer # +# Indexes +# +# index_components_on_bike_id (bike_id) +# index_components_on_bike_version_id (bike_version_id) +# index_components_on_manufacturer_id (manufacturer_id) +# class Component < ApplicationRecord include ActiveModel::Dirty diff --git a/app/models/exchange_rate.rb b/app/models/exchange_rate.rb index 3abfe2a24a..7fea79fe36 100644 --- a/app/models/exchange_rate.rb +++ b/app/models/exchange_rate.rb @@ -11,6 +11,10 @@ # created_at :datetime not null # updated_at :datetime not null # +# Indexes +# +# index_exchange_rates_on_from_and_to (from,to) UNIQUE +# class ExchangeRate < ApplicationRecord validates :from, :to, :rate, presence: true validates :from, :to, format: {with: /\A[A-Z]{3}\z/, message: "must be a valid ISO currency code"} diff --git a/app/models/export.rb b/app/models/export.rb index bf912def29..777a3188a3 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -14,6 +14,11 @@ # organization_id :integer # user_id :integer # +# Indexes +# +# index_exports_on_organization_id (organization_id) +# index_exports_on_user_id (user_id) +# class Export < ApplicationRecord PROGRESS_ENUM = { pending: 0, diff --git a/app/models/external_registry_bike.rb b/app/models/external_registry_bike.rb index 4389f6d9ee..f2b538ce6b 100644 --- a/app/models/external_registry_bike.rb +++ b/app/models/external_registry_bike.rb @@ -23,6 +23,13 @@ # country_id :integer not null # external_id :string not null # +# Indexes +# +# index_external_registry_bikes_on_country_id (country_id) +# index_external_registry_bikes_on_external_id (external_id) +# index_external_registry_bikes_on_serial_normalized (serial_normalized) +# index_external_registry_bikes_on_type (type) +# class ExternalRegistryBike < ApplicationRecord belongs_to :country, class_name: "Country" diff --git a/app/models/external_registry_bike/project529_bike.rb b/app/models/external_registry_bike/project529_bike.rb index 4a8ecff574..fff23a3d60 100644 --- a/app/models/external_registry_bike/project529_bike.rb +++ b/app/models/external_registry_bike/project529_bike.rb @@ -23,6 +23,13 @@ # country_id :integer not null # external_id :string not null # +# Indexes +# +# index_external_registry_bikes_on_country_id (country_id) +# index_external_registry_bikes_on_external_id (external_id) +# index_external_registry_bikes_on_serial_normalized (serial_normalized) +# index_external_registry_bikes_on_type (type) +# class ExternalRegistryBike::Project529Bike < ExternalRegistryBike def registry_url "https://project529.com" diff --git a/app/models/external_registry_bike/stop_heling_bike.rb b/app/models/external_registry_bike/stop_heling_bike.rb index b4faab108f..dfa53597f6 100644 --- a/app/models/external_registry_bike/stop_heling_bike.rb +++ b/app/models/external_registry_bike/stop_heling_bike.rb @@ -23,6 +23,13 @@ # country_id :integer not null # external_id :string not null # +# Indexes +# +# index_external_registry_bikes_on_country_id (country_id) +# index_external_registry_bikes_on_external_id (external_id) +# index_external_registry_bikes_on_serial_normalized (serial_normalized) +# index_external_registry_bikes_on_type (type) +# class ExternalRegistryBike::StopHelingBike < ExternalRegistryBike def registry_url "https://www.stopheling.nl" diff --git a/app/models/external_registry_bike/verloren_of_gevonden_bike.rb b/app/models/external_registry_bike/verloren_of_gevonden_bike.rb index 67324d4bec..29af18fec1 100644 --- a/app/models/external_registry_bike/verloren_of_gevonden_bike.rb +++ b/app/models/external_registry_bike/verloren_of_gevonden_bike.rb @@ -23,6 +23,13 @@ # country_id :integer not null # external_id :string not null # +# Indexes +# +# index_external_registry_bikes_on_country_id (country_id) +# index_external_registry_bikes_on_external_id (external_id) +# index_external_registry_bikes_on_serial_normalized (serial_normalized) +# index_external_registry_bikes_on_type (type) +# class ExternalRegistryBike::VerlorenOfGevondenBike < ExternalRegistryBike def registry_url "https://verlorenofgevonden.nl" diff --git a/app/models/external_registry_credential.rb b/app/models/external_registry_credential.rb index 0c882f853a..2b5a1c82d9 100644 --- a/app/models/external_registry_credential.rb +++ b/app/models/external_registry_credential.rb @@ -12,6 +12,10 @@ # updated_at :datetime not null # app_id :string # +# Indexes +# +# index_external_registry_credentials_on_type (type) +# class ExternalRegistryCredential < ApplicationRecord validates :type, uniqueness: true validates :app_id, uniqueness: {scope: :type} diff --git a/app/models/external_registry_credential/project529_credential.rb b/app/models/external_registry_credential/project529_credential.rb index c30c9a8da7..05c78c1dfb 100644 --- a/app/models/external_registry_credential/project529_credential.rb +++ b/app/models/external_registry_credential/project529_credential.rb @@ -12,6 +12,10 @@ # updated_at :datetime not null # app_id :string # +# Indexes +# +# index_external_registry_credentials_on_type (type) +# class ExternalRegistryCredential::Project529Credential < ExternalRegistryCredential validates :app_id, :refresh_token, presence: true diff --git a/app/models/external_registry_credential/stop_heling_credential.rb b/app/models/external_registry_credential/stop_heling_credential.rb index bc36aabd18..047021d220 100644 --- a/app/models/external_registry_credential/stop_heling_credential.rb +++ b/app/models/external_registry_credential/stop_heling_credential.rb @@ -12,6 +12,10 @@ # updated_at :datetime not null # app_id :string # +# Indexes +# +# index_external_registry_credentials_on_type (type) +# class ExternalRegistryCredential::StopHelingCredential < ExternalRegistryCredential validates :app_id, :access_token, presence: true diff --git a/app/models/feedback.rb b/app/models/feedback.rb index 7979a95991..104a85a264 100644 --- a/app/models/feedback.rb +++ b/app/models/feedback.rb @@ -15,6 +15,11 @@ # mailchimp_datum_id :bigint # user_id :integer # +# Indexes +# +# index_feedbacks_on_mailchimp_datum_id (mailchimp_datum_id) +# index_feedbacks_on_user_id (user_id) +# class Feedback < ApplicationRecord KIND_ENUM = { message: 0, diff --git a/app/models/graduated_notification.rb b/app/models/graduated_notification.rb index 8d2e8ddc00..c0448a7e8b 100644 --- a/app/models/graduated_notification.rb +++ b/app/models/graduated_notification.rb @@ -20,6 +20,16 @@ # primary_notification_id :bigint # user_id :bigint # +# Indexes +# +# index_graduated_notifications_on_bike_id (bike_id) +# index_graduated_notifications_on_bike_organization_id (bike_organization_id) +# index_graduated_notifications_on_marked_remaining_by_id (marked_remaining_by_id) +# index_graduated_notifications_on_organization_id (organization_id) +# index_graduated_notifications_on_primary_bike_id (primary_bike_id) +# index_graduated_notifications_on_primary_notification_id (primary_notification_id) +# index_graduated_notifications_on_user_id (user_id) +# class GraduatedNotification < ApplicationRecord STATUS_ENUM = {pending: 0, bike_graduated: 1, marked_remaining: 2}.freeze PENDING_PERIOD = 24.hours.freeze diff --git a/app/models/hot_sheet.rb b/app/models/hot_sheet.rb index 13ab7bfe60..c3d32e43ed 100644 --- a/app/models/hot_sheet.rb +++ b/app/models/hot_sheet.rb @@ -11,6 +11,10 @@ # updated_at :datetime not null # organization_id :bigint # +# Indexes +# +# index_hot_sheets_on_organization_id (organization_id) +# class HotSheet < ApplicationRecord belongs_to :organization diff --git a/app/models/hot_sheet_configuration.rb b/app/models/hot_sheet_configuration.rb index 48f0e71706..158ec69af2 100644 --- a/app/models/hot_sheet_configuration.rb +++ b/app/models/hot_sheet_configuration.rb @@ -11,6 +11,10 @@ # updated_at :datetime not null # organization_id :bigint # +# Indexes +# +# index_hot_sheet_configurations_on_organization_id (organization_id) +# class HotSheetConfiguration < ApplicationRecord include SearchRadiusMetricable diff --git a/app/models/impound_claim.rb b/app/models/impound_claim.rb index ccdca26de0..29182068e3 100644 --- a/app/models/impound_claim.rb +++ b/app/models/impound_claim.rb @@ -17,6 +17,15 @@ # stolen_record_id :bigint # user_id :bigint # +# Indexes +# +# index_impound_claims_on_bike_claimed_id (bike_claimed_id) +# index_impound_claims_on_bike_submitting_id (bike_submitting_id) +# index_impound_claims_on_impound_record_id (impound_record_id) +# index_impound_claims_on_organization_id (organization_id) +# index_impound_claims_on_stolen_record_id (stolen_record_id) +# index_impound_claims_on_user_id (user_id) +# class ImpoundClaim < ApplicationRecord STATUS_ENUM = { pending: 0, diff --git a/app/models/impound_configuration.rb b/app/models/impound_configuration.rb index 2c02ade17e..fb20c8e95f 100644 --- a/app/models/impound_configuration.rb +++ b/app/models/impound_configuration.rb @@ -13,6 +13,10 @@ # updated_at :datetime not null # organization_id :bigint # +# Indexes +# +# index_impound_configurations_on_organization_id (organization_id) +# class ImpoundConfiguration < ApplicationRecord belongs_to :organization has_many :impound_records, through: :organization diff --git a/app/models/impound_record.rb b/app/models/impound_record.rb index 2db2db19c3..52a2289a03 100644 --- a/app/models/impound_record.rb +++ b/app/models/impound_record.rb @@ -26,6 +26,15 @@ # state_id :bigint # user_id :integer # +# Indexes +# +# index_impound_records_on_bike_id (bike_id) +# index_impound_records_on_country_id (country_id) +# index_impound_records_on_location_id (location_id) +# index_impound_records_on_organization_id (organization_id) +# index_impound_records_on_state_id (state_id) +# index_impound_records_on_user_id (user_id) +# class ImpoundRecord < ApplicationRecord include Geocodeable diff --git a/app/models/impound_record_update.rb b/app/models/impound_record_update.rb index 00d3698f66..c72541c6e7 100644 --- a/app/models/impound_record_update.rb +++ b/app/models/impound_record_update.rb @@ -14,6 +14,13 @@ # location_id :bigint # user_id :bigint # +# Indexes +# +# index_impound_record_updates_on_impound_claim_id (impound_claim_id) +# index_impound_record_updates_on_impound_record_id (impound_record_id) +# index_impound_record_updates_on_location_id (location_id) +# index_impound_record_updates_on_user_id (user_id) +# class ImpoundRecordUpdate < ApplicationRecord # These statuses are used by impound_records! KIND_ENUM = { diff --git a/app/models/integration.rb b/app/models/integration.rb index fb12996735..7e3006e40f 100644 --- a/app/models/integration.rb +++ b/app/models/integration.rb @@ -10,6 +10,10 @@ # updated_at :datetime not null # user_id :integer # +# Indexes +# +# index_integrations_on_user_id (user_id) +# class IntegrationAssociationError < StandardError end diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 79875d2b11..9c19ff6500 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -20,6 +20,11 @@ # first_invoice_id :integer # organization_id :integer # +# Indexes +# +# index_invoices_on_first_invoice_id (first_invoice_id) +# index_invoices_on_organization_id (organization_id) +# # daily_maintenance_tasks updates all invoices that have expiring subscriptions every day class Invoice < ApplicationRecord diff --git a/app/models/invoice_organization_feature.rb b/app/models/invoice_organization_feature.rb index f9842280a0..7f1b3c6dba 100644 --- a/app/models/invoice_organization_feature.rb +++ b/app/models/invoice_organization_feature.rb @@ -10,6 +10,11 @@ # invoice_id :integer # organization_feature_id :integer # +# Indexes +# +# index_invoice_organization_features_on_invoice_id (invoice_id) +# index_invoice_organization_features_on_organization_feature_id (organization_feature_id) +# class InvoiceOrganizationFeature < ActiveRecord::Base belongs_to :invoice belongs_to :organization_feature diff --git a/app/models/lock.rb b/app/models/lock.rb index 45be912127..e2a015a09c 100644 --- a/app/models/lock.rb +++ b/app/models/lock.rb @@ -16,6 +16,10 @@ # manufacturer_id :integer # user_id :integer # +# Indexes +# +# index_locks_on_user_id (user_id) +# class Lock < ApplicationRecord belongs_to :manufacturer belongs_to :lock_type diff --git a/app/models/mail_snippet.rb b/app/models/mail_snippet.rb index cc2424ef42..3e03bbc20d 100644 --- a/app/models/mail_snippet.rb +++ b/app/models/mail_snippet.rb @@ -21,6 +21,12 @@ # organization_id :integer # state_id :bigint # +# Indexes +# +# index_mail_snippets_on_country_id (country_id) +# index_mail_snippets_on_organization_id (organization_id) +# index_mail_snippets_on_state_id (state_id) +# class MailSnippet < ApplicationRecord include Geocodeable diff --git a/app/models/mailchimp_datum.rb b/app/models/mailchimp_datum.rb index 6840fd8fd6..b17157922e 100644 --- a/app/models/mailchimp_datum.rb +++ b/app/models/mailchimp_datum.rb @@ -12,6 +12,10 @@ # updated_at :datetime not null # user_id :bigint # +# Indexes +# +# index_mailchimp_data_on_user_id (user_id) +# class MailchimpDatum < ApplicationRecord STATUS_ENUM = { no_subscription_required: 0, diff --git a/app/models/model_attestation.rb b/app/models/model_attestation.rb index 567f3eba8e..e13ed47459 100644 --- a/app/models/model_attestation.rb +++ b/app/models/model_attestation.rb @@ -15,6 +15,12 @@ # organization_id :bigint # user_id :bigint # +# Indexes +# +# index_model_attestations_on_model_audit_id (model_audit_id) +# index_model_attestations_on_organization_id (organization_id) +# index_model_attestations_on_user_id (user_id) +# class ModelAttestation < ApplicationRecord # NOTE: This hash is ordered by the importance of the kind CERTIFICATION_KIND_ENUM = { diff --git a/app/models/model_audit.rb b/app/models/model_audit.rb index 74d030d2f7..c211b05599 100644 --- a/app/models/model_audit.rb +++ b/app/models/model_audit.rb @@ -14,6 +14,10 @@ # updated_at :datetime not null # manufacturer_id :bigint # +# Indexes +# +# index_model_audits_on_manufacturer_id (manufacturer_id) +# class ModelAudit < ApplicationRecord UNKNOWN_STRINGS = %w[na idk no none nomodel tbd unknown unkown].freeze ADDITIONAL_CYCLE_TYPES = %w[bicycle dirtbike trike three-wheeler 3-wheeler].freeze diff --git a/app/models/normalized_serial_segment.rb b/app/models/normalized_serial_segment.rb index ae46792055..287ce7afcb 100644 --- a/app/models/normalized_serial_segment.rb +++ b/app/models/normalized_serial_segment.rb @@ -9,6 +9,11 @@ # bike_id :integer # duplicate_bike_group_id :integer # +# Indexes +# +# index_normalized_serial_segments_on_bike_id (bike_id) +# index_normalized_serial_segments_on_duplicate_bike_group_id (duplicate_bike_group_id) +# class NormalizedSerialSegment < ApplicationRecord MINIMUM_LENGTH_FOR_DUPLICATE_GROUP = 5 belongs_to :bike diff --git a/app/models/notification.rb b/app/models/notification.rb index 8f69e4804b..37458d1d22 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -15,6 +15,12 @@ # notifiable_id :bigint # user_id :bigint # +# Indexes +# +# index_notifications_on_bike_id (bike_id) +# index_notifications_on_notifiable_type_and_notifiable_id (notifiable_type,notifiable_id) +# index_notifications_on_user_id (user_id) +# # TODO: create notifications for each other notification model: # - graduated_notifications diff --git a/app/models/organization.rb b/app/models/organization.rb index 2952b4bd52..ecd14f53e8 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -41,6 +41,13 @@ # manufacturer_id :bigint # parent_organization_id :integer # +# Indexes +# +# index_organizations_on_location_latitude_and_location_longitude (location_latitude,location_longitude) +# index_organizations_on_manufacturer_id (manufacturer_id) +# index_organizations_on_parent_organization_id (parent_organization_id) +# index_organizations_on_slug (slug) UNIQUE +# class Organization < ApplicationRecord include ActionView::Helpers::SanitizeHelper include SearchRadiusMetricable diff --git a/app/models/organization_manufacturer.rb b/app/models/organization_manufacturer.rb index ffcecd9f11..082afcd71b 100644 --- a/app/models/organization_manufacturer.rb +++ b/app/models/organization_manufacturer.rb @@ -9,6 +9,11 @@ # manufacturer_id :bigint # organization_id :bigint # +# Indexes +# +# index_organization_manufacturers_on_manufacturer_id (manufacturer_id) +# index_organization_manufacturers_on_organization_id (organization_id) +# class OrganizationManufacturer < ApplicationRecord belongs_to :organization belongs_to :manufacturer diff --git a/app/models/organization_model_audit.rb b/app/models/organization_model_audit.rb index 4c053e95a1..7e2c1ab447 100644 --- a/app/models/organization_model_audit.rb +++ b/app/models/organization_model_audit.rb @@ -11,6 +11,11 @@ # model_audit_id :bigint # organization_id :bigint # +# Indexes +# +# index_organization_model_audits_on_model_audit_id (model_audit_id) +# index_organization_model_audits_on_organization_id (organization_id) +# class OrganizationModelAudit < ApplicationRecord enum :certification_status, ModelAttestation::CERTIFICATION_KIND_ENUM diff --git a/app/models/organization_stolen_message.rb b/app/models/organization_stolen_message.rb index 65699ddc20..a6edd7e668 100644 --- a/app/models/organization_stolen_message.rb +++ b/app/models/organization_stolen_message.rb @@ -16,6 +16,11 @@ # organization_id :bigint # updator_id :bigint # +# Indexes +# +# index_organization_stolen_messages_on_organization_id (organization_id) +# index_organization_stolen_messages_on_updator_id (updator_id) +# class OrganizationStolenMessage < ApplicationRecord MAX_BODY_LENGTH = 400 KIND_ENUM = {area: 0, association: 1} diff --git a/app/models/ownership.rb b/app/models/ownership.rb index 1a073b01ff..1d42072c17 100644 --- a/app/models/ownership.rb +++ b/app/models/ownership.rb @@ -29,6 +29,15 @@ # previous_ownership_id :bigint # user_id :integer # +# Indexes +# +# index_ownerships_on_bike_id (bike_id) +# index_ownerships_on_bulk_import_id (bulk_import_id) +# index_ownerships_on_creator_id (creator_id) +# index_ownerships_on_impound_record_id (impound_record_id) +# index_ownerships_on_organization_id (organization_id) +# index_ownerships_on_user_id (user_id) +# class Ownership < ApplicationRecord include RegistrationInfoable ORIGIN_ENUM = { diff --git a/app/models/parking_notification.rb b/app/models/parking_notification.rb index c5093eb346..207f92bd5a 100644 --- a/app/models/parking_notification.rb +++ b/app/models/parking_notification.rb @@ -37,6 +37,17 @@ # state_id :bigint # user_id :integer # +# Indexes +# +# index_parking_notifications_on_bike_id (bike_id) +# index_parking_notifications_on_country_id (country_id) +# index_parking_notifications_on_impound_record_id (impound_record_id) +# index_parking_notifications_on_initial_record_id (initial_record_id) +# index_parking_notifications_on_organization_id (organization_id) +# index_parking_notifications_on_retrieved_by_id (retrieved_by_id) +# index_parking_notifications_on_state_id (state_id) +# index_parking_notifications_on_user_id (user_id) +# class ParkingNotification < ActiveRecord::Base include Geocodeable KIND_ENUM = {appears_abandoned_notification: 0, parked_incorrectly_notification: 1, impound_notification: 2}.freeze diff --git a/app/models/payment.rb b/app/models/payment.rb index c056ec3144..4d09a66f61 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -17,6 +17,10 @@ # stripe_id :string(255) # user_id :integer # +# Indexes +# +# index_payments_on_user_id (user_id) +# class Payment < ApplicationRecord include Amountable PAYMENT_METHOD_ENUM = {stripe: 0, check: 1}.freeze diff --git a/app/models/public_image.rb b/app/models/public_image.rb index 2f76447694..32d452d9a1 100644 --- a/app/models/public_image.rb +++ b/app/models/public_image.rb @@ -14,6 +14,10 @@ # updated_at :datetime not null # imageable_id :integer # +# Indexes +# +# index_public_images_on_imageable_id_and_imageable_type (imageable_id,imageable_type) +# class PublicImage < ApplicationRecord KIND_ENUM = { photo_uncategorized: 0, # If editing these images, also update _public_image template diff --git a/app/models/recovery_display.rb b/app/models/recovery_display.rb index 23a70091a7..1d0d098864 100644 --- a/app/models/recovery_display.rb +++ b/app/models/recovery_display.rb @@ -12,6 +12,10 @@ # updated_at :datetime not null # stolen_record_id :integer # +# Indexes +# +# index_recovery_displays_on_stolen_record_id (stolen_record_id) +# class RecoveryDisplay < ActiveRecord::Base validates_presence_of :quote, :recovered_at mount_uploader :image, CircularImageUploader diff --git a/app/models/state.rb b/app/models/state.rb index 82ab984f75..6fe311abac 100644 --- a/app/models/state.rb +++ b/app/models/state.rb @@ -9,6 +9,10 @@ # updated_at :datetime not null # country_id :integer # +# Indexes +# +# index_states_on_country_id (country_id) +# class State < ApplicationRecord validates :country, presence: true validates :name, :abbreviation, uniqueness: true, presence: true diff --git a/app/models/stolen_bike_listing.rb b/app/models/stolen_bike_listing.rb index 5a9b139f84..aaf5e97118 100644 --- a/app/models/stolen_bike_listing.rb +++ b/app/models/stolen_bike_listing.rb @@ -28,6 +28,15 @@ # secondary_frame_color_id :bigint # tertiary_frame_color_id :bigint # +# Indexes +# +# index_stolen_bike_listings_on_bike_id (bike_id) +# index_stolen_bike_listings_on_initial_listing_id (initial_listing_id) +# index_stolen_bike_listings_on_manufacturer_id (manufacturer_id) +# index_stolen_bike_listings_on_primary_frame_color_id (primary_frame_color_id) +# index_stolen_bike_listings_on_secondary_frame_color_id (secondary_frame_color_id) +# index_stolen_bike_listings_on_tertiary_frame_color_id (tertiary_frame_color_id) +# # Initially created for mexican stolen bike ring class StolenBikeListing < ActiveRecord::Base diff --git a/app/models/stolen_notification.rb b/app/models/stolen_notification.rb index 799594a88a..0527f38b9e 100644 --- a/app/models/stolen_notification.rb +++ b/app/models/stolen_notification.rb @@ -16,6 +16,10 @@ # receiver_id :integer # sender_id :integer # +# Indexes +# +# index_stolen_notifications_on_oauth_application_id (oauth_application_id) +# class StolenNotification < ApplicationRecord KIND_ENUM = { stolen_permitted: 0, diff --git a/app/models/stolen_record.rb b/app/models/stolen_record.rb index 1b961b8149..e23d0cda08 100644 --- a/app/models/stolen_record.rb +++ b/app/models/stolen_record.rb @@ -47,6 +47,13 @@ # recovering_user_id :integer # state_id :integer # +# Indexes +# +# index_stolen_records_on_bike_id (bike_id) +# index_stolen_records_on_latitude_and_longitude (latitude,longitude) +# index_stolen_records_on_organization_stolen_message_id (organization_stolen_message_id) +# index_stolen_records_on_recovering_user_id (recovering_user_id) +# class StolenRecord < ApplicationRecord include ActiveModel::Dirty include Geocodeable diff --git a/app/models/superuser_ability.rb b/app/models/superuser_ability.rb index 941040b706..c8d5560d8c 100644 --- a/app/models/superuser_ability.rb +++ b/app/models/superuser_ability.rb @@ -12,6 +12,10 @@ # updated_at :datetime not null # user_id :bigint # +# Indexes +# +# index_superuser_abilities_on_user_id (user_id) +# # TODO: make this the way that superuser is defined for everyone # e.g. if universal, update user to be superuser: true, remove superuser: true if deleted, etc diff --git a/app/models/theft_alert.rb b/app/models/theft_alert.rb index 07e70b26b2..df31d4bd66 100644 --- a/app/models/theft_alert.rb +++ b/app/models/theft_alert.rb @@ -23,6 +23,14 @@ # theft_alert_plan_id :integer # user_id :integer # +# Indexes +# +# index_theft_alerts_on_bike_id (bike_id) +# index_theft_alerts_on_payment_id (payment_id) +# index_theft_alerts_on_stolen_record_id (stolen_record_id) +# index_theft_alerts_on_theft_alert_plan_id (theft_alert_plan_id) +# index_theft_alerts_on_user_id (user_id) +# # Foreign Keys # # fk_rails_... (payment_id => payments.id) diff --git a/app/models/tweet.rb b/app/models/tweet.rb index d3a7d053cd..33caf966ff 100644 --- a/app/models/tweet.rb +++ b/app/models/tweet.rb @@ -16,6 +16,12 @@ # twitter_account_id :integer # twitter_id :string # +# Indexes +# +# index_tweets_on_original_tweet_id (original_tweet_id) +# index_tweets_on_stolen_record_id (stolen_record_id) +# index_tweets_on_twitter_account_id (twitter_account_id) +# class Tweet < ApplicationRecord KIND_ENUM = {stolen_tweet: 0, imported_tweet: 1, app_tweet: 2}.freeze VALID_ALIGNMENTS = %w[top-left top-right bottom-left bottom-right].freeze diff --git a/app/models/twitter_account.rb b/app/models/twitter_account.rb index 2931d7d284..47d18c4b05 100644 --- a/app/models/twitter_account.rb +++ b/app/models/twitter_account.rb @@ -28,6 +28,13 @@ # country_id :bigint # state_id :bigint # +# Indexes +# +# index_twitter_accounts_on_country_id (country_id) +# index_twitter_accounts_on_latitude_and_longitude (latitude,longitude) +# index_twitter_accounts_on_screen_name (screen_name) +# index_twitter_accounts_on_state_id (state_id) +# class TwitterAccount < ApplicationRecord include Geocodeable diff --git a/app/models/user.rb b/app/models/user.rb index 28b97ce1cc..c2e61e8788 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -33,7 +33,6 @@ # partner_data :jsonb # password :text # password_digest :string(255) -# token_for_password_reset :text # phone :string(255) # preferred_language :string # show_bikes :boolean default(FALSE), not null @@ -46,6 +45,7 @@ # terms_of_service :boolean default(FALSE), not null # time_single_format :boolean default(FALSE) # title :text +# token_for_password_reset :text # twitter :string(255) # username :string(255) # vendor_terms_of_service :boolean @@ -57,6 +57,11 @@ # state_id :integer # stripe_id :string(255) # +# Indexes +# +# index_users_on_auth_token (auth_token) +# index_users_on_token_for_password_reset (token_for_password_reset) +# class User < ApplicationRecord include ActionView::Helpers::SanitizeHelper include FeatureFlaggable diff --git a/app/models/user_alert.rb b/app/models/user_alert.rb index ee87fe3149..4f8601a300 100644 --- a/app/models/user_alert.rb +++ b/app/models/user_alert.rb @@ -15,6 +15,14 @@ # user_id :bigint # user_phone_id :bigint # +# Indexes +# +# index_user_alerts_on_bike_id (bike_id) +# index_user_alerts_on_organization_id (organization_id) +# index_user_alerts_on_theft_alert_id (theft_alert_id) +# index_user_alerts_on_user_id (user_id) +# index_user_alerts_on_user_phone_id (user_phone_id) +# class UserAlert < ApplicationRecord KIND_ENUM = { phone_waiting_confirmation: 0, diff --git a/app/models/user_ban.rb b/app/models/user_ban.rb index 8df0ca0098..4f7946a613 100644 --- a/app/models/user_ban.rb +++ b/app/models/user_ban.rb @@ -11,6 +11,11 @@ # creator_id :bigint # user_id :bigint # +# Indexes +# +# index_user_bans_on_creator_id (creator_id) +# index_user_bans_on_user_id (user_id) +# class UserBan < ApplicationRecord REASON_ENUM = { abuse: 0, diff --git a/app/models/user_email.rb b/app/models/user_email.rb index c2c50ba0d6..9fd35dd753 100644 --- a/app/models/user_email.rb +++ b/app/models/user_email.rb @@ -10,6 +10,10 @@ # old_user_id :integer # user_id :integer # +# Indexes +# +# index_user_emails_on_user_id (user_id) +# class UserEmail < ActiveRecord::Base belongs_to :user, touch: true belongs_to :old_user, class_name: "User", touch: true diff --git a/app/models/user_phone.rb b/app/models/user_phone.rb index 6a42406151..6261ff999f 100644 --- a/app/models/user_phone.rb +++ b/app/models/user_phone.rb @@ -11,6 +11,10 @@ # updated_at :datetime not null # user_id :bigint # +# Indexes +# +# index_user_phones_on_user_id (user_id) +# class UserPhone < ApplicationRecord acts_as_paranoid diff --git a/app/models/user_registration_organization.rb b/app/models/user_registration_organization.rb index 6a9c18e3a0..d08a441636 100644 --- a/app/models/user_registration_organization.rb +++ b/app/models/user_registration_organization.rb @@ -12,6 +12,11 @@ # organization_id :bigint # user_id :bigint # +# Indexes +# +# index_user_registration_organizations_on_organization_id (organization_id) +# index_user_registration_organizations_on_user_id (user_id) +# class UserRegistrationOrganization < ApplicationRecord include RegistrationInfoable