Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 19, 2025

This PR adds the annotaterb gem to automatically keep Rails model files annotated with current database schema information.

What was added

annotaterb gem setup:

  • Added annotaterb gem to development dependencies in Gemfile
  • Generated .annotaterb.yml configuration file with sensible defaults
  • Created lib/tasks/annotate_rb.rake for automatic annotation on database migrations
  • Applied initial annotations to existing models and test factories

Key features configured

  • Automatic updates: Model annotations are automatically updated when running rails db:migrate in development
  • Schema information: Shows table columns, data types, constraints, and indexes
  • Factory annotation: Test factories are kept in sync with model changes
  • Clean formatting: Uses classified sorting (id, columns, timestamps) for predictable output
  • Selective annotation: Focuses on models and tests, excludes controllers and helpers

Before and after

Before - The Org model had no schema documentation:

class Org < ApplicationRecord
  validates :clerk_org_id, presence: true, uniqueness: true
end

After - All models now include comprehensive schema information:

# == 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

The setup improves developer experience by keeping database schema information visible and up-to-date directly in model files, making it easier to understand table structure without checking migrations or schema files.

Fixes #28.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Setup gem "annotaterb" Setup gem "annotaterb" for automatic model schema annotation Aug 19, 2025
@Copilot Copilot AI requested a review from danielpaul August 19, 2025 14:57
Copilot finished work on behalf of danielpaul August 19, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup gem "annotaterb"
2 participants