diff --git a/.annotaterb.yml b/.annotaterb.yml new file mode 100644 index 00000000..89f547ae --- /dev/null +++ b/.annotaterb.yml @@ -0,0 +1,64 @@ +--- +:position: before +:position_in_additional_file_patterns: before +:position_in_class: before +:position_in_factory: before +:position_in_fixture: before +:position_in_routes: before +:position_in_serializer: before +:position_in_test: before +:classified_sort: true +:exclude_controllers: true +:exclude_factories: false +:exclude_fixtures: false +:exclude_helpers: true +:exclude_scaffolds: true +:exclude_serializers: false +:exclude_sti_subclasses: false +:exclude_tests: false +:force: false +:format_markdown: false +:format_rdoc: false +:format_yard: false +:frozen: false +:grouped_polymorphic: false +:ignore_model_sub_dir: false +:ignore_unknown_models: false +:include_version: false +:show_check_constraints: false +:show_complete_foreign_keys: false +:show_foreign_keys: true +:show_indexes: true +:show_indexes_include: false +:simple_indexes: false +:sort: false +:timestamp: false +:trace: false +:with_comment: true +:with_column_comments: true +:with_table_comments: true +:position_of_column_comment: :with_name +:active_admin: false +:command: +:debug: false +:hide_default_column_types: '' +:hide_limit_column_types: '' +:timestamp_columns: +- created_at +- updated_at +:ignore_columns: +:ignore_routes: +:models: true +:routes: false +:skip_on_db_migrate: false +:target_action: :do_annotations +:wrapper: +:wrapper_close: +:wrapper_open: +:classes_default_to_s: [] +:additional_file_patterns: [] +:model_dir: +- app/models +:require: [] +:root_dir: +- '' diff --git a/Gemfile b/Gemfile index 7711a8a2..89c8566b 100644 --- a/Gemfile +++ b/Gemfile @@ -81,6 +81,9 @@ group :development do # Use letter_opener to preview emails in the browser in development [https://github.com/ryanb/letter_opener] gem "letter_opener" + + # Automatically annotate models with schema information + gem "annotaterb" end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 4072344d..5b88416f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,6 +74,9 @@ GEM uri (>= 0.13.1) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) + annotaterb (4.18.0) + activerecord (>= 6.0.0) + activesupport (>= 6.0.0) ast (2.4.3) base64 (0.3.0) bcrypt (3.1.20) @@ -441,6 +444,7 @@ PLATFORMS x86_64-linux-musl DEPENDENCIES + annotaterb bcrypt (~> 3.1.7) bootsnap brakeman diff --git a/app/models/org.rb b/app/models/org.rb index ac624d1a..347a3b36 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -1,5 +1,18 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: orgs +# +# id :bigint not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# clerk_org_id :string not null +# +# Indexes +# +# index_orgs_on_clerk_org_id (clerk_org_id) UNIQUE +# class Org < ApplicationRecord validates :clerk_org_id, presence: true, uniqueness: true end diff --git a/app/models/user.rb b/app/models/user.rb index 0f9262ee..fd1b1aa2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,9 +5,9 @@ # Table name: users # # id :bigint not null, primary key -# clerk_id :string not null # created_at :datetime not null # updated_at :datetime not null +# clerk_id :string not null # # Indexes # diff --git a/db/cable_schema.rb b/db/cable_schema.rb index 7d9c3a0b..23e6a368 100644 --- a/db/cable_schema.rb +++ b/db/cable_schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_08_03_194905) do +ActiveRecord::Schema[8.0].define(version: 2025_08_19_145110) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -25,6 +25,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "clerk_id", null: false + t.string "test_field" t.index ["clerk_id"], name: "index_users_on_clerk_id", unique: true end end diff --git a/db/cache_schema.rb b/db/cache_schema.rb index 7d9c3a0b..23e6a368 100644 --- a/db/cache_schema.rb +++ b/db/cache_schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_08_03_194905) do +ActiveRecord::Schema[8.0].define(version: 2025_08_19_145110) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -25,6 +25,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "clerk_id", null: false + t.string "test_field" t.index ["clerk_id"], name: "index_users_on_clerk_id", unique: true end end diff --git a/db/queue_schema.rb b/db/queue_schema.rb index 7d9c3a0b..23e6a368 100644 --- a/db/queue_schema.rb +++ b/db/queue_schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_08_03_194905) do +ActiveRecord::Schema[8.0].define(version: 2025_08_19_145110) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -25,6 +25,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "clerk_id", null: false + t.string "test_field" t.index ["clerk_id"], name: "index_users_on_clerk_id", unique: true end end diff --git a/lib/tasks/annotate_rb.rake b/lib/tasks/annotate_rb.rake new file mode 100644 index 00000000..611cfe9e --- /dev/null +++ b/lib/tasks/annotate_rb.rake @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +# This rake task was added by annotate_rb gem. + +# Can set `ANNOTATERB_SKIP_ON_DB_TASKS` to be anything to skip this +if Rails.env.development? && ENV["ANNOTATERB_SKIP_ON_DB_TASKS"].nil? + require "annotate_rb" + + AnnotateRb::Core.load_rake_tasks +end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 44cab328..01e49dd9 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,5 +1,18 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: users +# +# id :bigint not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# clerk_id :string not null +# +# Indexes +# +# index_users_on_clerk_id (clerk_id) UNIQUE +# FactoryBot.define do factory :user do sequence(:clerk_id) { |n| "user_#{n}_clerk_id" }