{"id":26286476,"url":"https://github.com/hmurtaza7/rails_schema_cleaner","last_synced_at":"2026-02-12T18:31:17.450Z","repository":{"id":280108112,"uuid":"940785283","full_name":"hmurtaza7/rails_schema_cleaner","owner":"hmurtaza7","description":"Identifies and removes orphaned tables from your Rails application","archived":false,"fork":false,"pushed_at":"2025-03-01T11:48:46.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-04T17:56:18.697Z","etag":null,"topics":["rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hmurtaza7.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-28T19:38:28.000Z","updated_at":"2025-03-01T11:47:15.000Z","dependencies_parsed_at":"2025-03-01T10:18:56.355Z","dependency_job_id":"3005fada-928b-4b92-91f4-466f514f9ef6","html_url":"https://github.com/hmurtaza7/rails_schema_cleaner","commit_stats":null,"previous_names":["hmurtaza7/rails_schema_cleaner"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/hmurtaza7/rails_schema_cleaner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmurtaza7%2Frails_schema_cleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmurtaza7%2Frails_schema_cleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmurtaza7%2Frails_schema_cleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmurtaza7%2Frails_schema_cleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hmurtaza7","download_url":"https://codeload.github.com/hmurtaza7/rails_schema_cleaner/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmurtaza7%2Frails_schema_cleaner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29376845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T18:17:34.915Z","status":"ssl_error","status_checked_at":"2026-02-12T18:17:34.495Z","response_time":55,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rails","ruby"],"created_at":"2025-03-14T20:29:30.217Z","updated_at":"2026-02-12T18:31:17.427Z","avatar_url":"https://github.com/hmurtaza7.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RailsSchemaCleaner\n\n## Overview\n`rails_schema_cleaner` is a Ruby gem that helps keep your Rails database schema clean by identifying and removing orphaned tables (tables that do not have corresponding ActiveRecord models). It generates a migration file to drop these unused tables safely.\n\n## Installation\nAdd this gem to your `Gemfile`:\n\n```ruby\ngem \"rails_schema_cleaner\"\n```\n\nThen run:\n\n```sh\nbundle install\n```\n\nAlternatively, install it manually:\n\n```sh\ngem install rails_schema_cleaner\n```\n\n## Usage\n### **1. Detect Orphaned Tables**\nTo list all tables in the database that do not have an associated model, run:\n\n```sh\nbundle exec rails_schema_cleaner detect\n```\n\nThis will return an array of orphaned table names.\n\n### **2. Generate Migration to Drop Orphaned Tables**\nTo create a Rails migration file that drops these tables, run:\n\n```sh\nbundle exec rails_schema_cleaner clean\n```\n\nThis will generate a timestamped migration file in `db/migrate/`, e.g.:\n\n```sh\ndb/migrate/20240228123456_drop_orphaned_tables.rb\n```\n\n### **3. Run the Migration**\nExecute the migration to drop the orphaned tables:\n\n```sh\nrails db:migrate\n```\n\n## Compatibility\n- Works with Rails \u003e=5.0\n- Supports SQLite, PostgreSQL, and MySQL\n\n## How It Works\n1. Fetches all database tables using `ActiveRecord::Base.connection.tables`\n2. Fetches all existing model table names using `ActiveRecord::Base.descendants.map(\u0026:table_name)`\n3. Compares both lists and identifies tables that do not have an associated model\n4. Generates a Rails migration file to drop those tables\n\n## Running Tests\nRun RSpec tests with:\n\n```sh\nrspec\n```\n\n## License\nThis project is licensed under the MIT License.\n\n## Contributions\nPull requests are welcome! Please open an issue to discuss any significant changes before submitting a PR.\n\n## Author\nCreated by [Hassan Murtaza](https://github.com/hmurtaza7).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmurtaza7%2Frails_schema_cleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhmurtaza7%2Frails_schema_cleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmurtaza7%2Frails_schema_cleaner/lists"}