ColumnLens
columnlens is a CLI tool to analyze your Ruby on Rails database schema. It helps detect unused, read-only, and orphaned columns, providing insight into schema hygiene and technical debt.
✨ Features
- Scan your full Rails database schema
- Detect actively used, write-only, read-only, and orphaned columns
- Respect system tables and configurable ignore rules
🧰 Installation
Add this line to your application's Gemfile:
gem 'columnlens'Then execute:
$ bundle installOr install it globally:
$ gem install columnlens🚀 Usage
From any Rails project:
$ bundle exec columnlens scanOutput example:
🔍 ColumnLens Scan Mode
Scanning full schema...
posts.title read_write
users.email read_write
users.last_seen_at orphaned
...
⚙️ Configuration
ColumnLens uses a .columnlens.yml in your project root:
system_tables:
- "^active_storage_"
- "^schema_migrations$"
- "^ar_internal_metadata$"
ignore:
scan:
orphaned:
- "posts"
- "users.created_at"
- "users.updated_at"
deep:
orphaned: []Defaults are provided in lib/config/default.yml and merged with the project config.
🔧 Development
To set up the project locally:
$ git clone https://github.com/BestBitsLab/columnlens.git
$ cd columnlens
$ bin/setupYou can experiment with the code via:
$ bin/consoleTo build and install the gem locally:
$ bundle exec rake installTo release a new version:
- Update the version in
lib/columnlens/version.rb - Run:
$ bundle exec rake releaseThis will tag, push, and publish to RubyGems.org.
🤝 Contributing
Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration. Please read and follow the code of conduct.
🪪 License
This gem is available as open source under the terms of the MIT License.
📜 Code of Conduct
Everyone interacting in the ColumnLens project's codebase, issue trackers, and other community spaces is expected to follow the Code of Conduct.