{"id":20690321,"url":"https://github.com/jomei/multibase","last_synced_at":"2025-04-22T16:56:59.717Z","repository":{"id":56884770,"uuid":"78331501","full_name":"jomei/multibase","owner":"jomei","description":"Multiple databases support for Rails","archived":false,"fork":false,"pushed_at":"2018-04-07T16:14:37.000Z","size":94,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T04:06:24.041Z","etag":null,"topics":["activerecord","database-management","multibase","multibase-database","rails"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/multibase-rails","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/jomei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-08T08:46:10.000Z","updated_at":"2022-07-05T10:40:19.000Z","dependencies_parsed_at":"2022-08-20T13:00:07.478Z","dependency_job_id":null,"html_url":"https://github.com/jomei/multibase","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomei%2Fmultibase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomei%2Fmultibase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomei%2Fmultibase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomei%2Fmultibase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jomei","download_url":"https://codeload.github.com/jomei/multibase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250284205,"owners_count":21405289,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["activerecord","database-management","multibase","multibase-database","rails"],"created_at":"2024-11-16T23:12:44.084Z","updated_at":"2025-04-22T16:56:59.685Z","avatar_url":"https://github.com/jomei.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multibase [![Build Status](https://travis-ci.org/jomei/multibase.svg?branch=master)](https://travis-ci.org/jomei/multibase)   [![Coverage Status](https://coveralls.io/repos/github/jomei/multibase/badge.svg?branch=master)](https://coveralls.io/github/jomei/multibase?branch=master) [![Code Climate](https://lima.codeclimate.com/github/jomei/multibase/badges/gpa.svg)](https://lima.codeclimate.com/github/jomei/multibase)\nMultiple database support for Rails. \n\nThis solution inspired by the [SecondBase](https://github.com/customink/secondbase)\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'multibase-rails'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install multibase-rails\n\n## Usage\n\n### database.yml \nChange config/database.yml so that settings for every database are placed under the following root key:\n```yaml\n# config/database.yml\n---\ndefault: # default key for the default database\n  test:\n    adapter: sqlite3\n    url:     ./base/test.sqlite3\n  development:\n    adapter: sqlite3\n    url:     ./base/development.sqlite3\n  production:\n    adapter: postgresql\n    url:     \u003c%= ENV['DEFAULT_BASE_URL'] %\u003e\ncustom_db: # the unique name for another database\n  test:\n    adapter: sqlite3\n    url:     ./custom_db/test.sqlite3\n  development:\n    adapter: sqlite3\n    url:     ./custom_db/development.sqlite3\n  production:\n    adapter: postgresql\n    url:     \u003c%= ENV['PERSONAL_BASE_URL'] %\u003e\n```\n### Configurations\nYou can define your own default database key in `config/application.rb`\n```\nconfig.multibase.default_key # Default: 'default'\n```\n\n### Rake tasks\nAll `db:` rake tasks defined for each database as `db:your_database_name:command`, e.g. `rake db:cusom_db:create`\n\n### Rails Generators\n#### Migrations\nUse `multibase:migration` to generate migration for specific database\n```\nrails g multibase:migration \u003cmigration_name\u003e \u003cdatabase_name\u003e \u003coptions\u003e\n```\nExample\n```ruby\nrails g multibase:migration CreateMyTable custom_db foo:integer baz:string \n```\n### Rails models\nAll models should be inherit from `Multibase::Base`.\nUse `using` method to specify database connection \nExample\n```ruby\nclass Comment \u003c Multibase::Base\n  using :my_not_default_connection\nend\n```\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjomei%2Fmultibase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjomei%2Fmultibase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjomei%2Fmultibase/lists"}