{"id":13394967,"url":"https://github.com/thiagopradi/octopus","last_synced_at":"2026-02-19T23:03:26.503Z","repository":{"id":909233,"uuid":"668622","full_name":"thiagopradi/octopus","owner":"thiagopradi","description":"Database Sharding for ActiveRecord","archived":false,"fork":false,"pushed_at":"2024-02-16T15:24:07.000Z","size":1234,"stargazers_count":2546,"open_issues_count":123,"forks_count":504,"subscribers_count":55,"default_branch":"master","last_synced_at":"2026-02-15T23:09:48.062Z","etag":null,"topics":["activerecord","ruby","ruby-on-rails","sharding"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thiagopradi.png","metadata":{"files":{"readme":"README.mkdn","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2010-05-15T20:19:59.000Z","updated_at":"2026-02-15T20:39:49.000Z","dependencies_parsed_at":"2023-07-12T16:12:05.691Z","dependency_job_id":"8d071e97-675c-4a5a-b98d-4e681b08efad","html_url":"https://github.com/thiagopradi/octopus","commit_stats":{"total_commits":893,"total_committers":92,"mean_commits":9.706521739130435,"dds":0.5363941769316909,"last_synced_commit":"1c0abed4a2cd58869b4aa05e46e1a49a2e0f670f"},"previous_names":["tchandy/octopus"],"tags_count":56,"template":false,"template_full_name":null,"purl":"pkg:github/thiagopradi/octopus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagopradi%2Foctopus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagopradi%2Foctopus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagopradi%2Foctopus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagopradi%2Foctopus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thiagopradi","download_url":"https://codeload.github.com/thiagopradi/octopus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagopradi%2Foctopus/sbom","scorecard":{"id":880859,"data":{"date":"2025-08-11","repo":{"name":"github.com/thiagopradi/octopus","commit":"1c0abed4a2cd58869b4aa05e46e1a49a2e0f670f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":5,"reason":"Found 9/17 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 23 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"101 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-h47h-mwp9-c6q6","Warn: Project is vulnerable to: GHSA-rg5m-3fqp-6px8","Warn: Project is vulnerable to: GHSA-29gr-w57f-rpfw","Warn: Project is vulnerable to: GHSA-4g8v-vg43-wpgf","Warn: Project is vulnerable to: GHSA-699m-mcjm-9cw8","Warn: Project is vulnerable to: GHSA-6h5q-96hp-9jgm","Warn: Project is vulnerable to: GHSA-6x85-j5j2-27jx","Warn: Project is vulnerable to: GHSA-78rc-8c29-p45g","Warn: Project is vulnerable to: GHSA-7cgp-c3g7-qvrw","Warn: Project is vulnerable to: GHSA-ffpv-c4hm-3x6v","Warn: Project is vulnerable to: GHSA-h56m-vwxc-3qpw","Warn: Project is vulnerable to: GHSA-hjg4-8q5f-x6fm","Warn: Project is vulnerable to: GHSA-m46p-ggm5-5j83","Warn: Project is vulnerable to: GHSA-mpxf-gcw2-pw5q","Warn: Project is vulnerable to: GHSA-p692-7mm3-3fxg","Warn: Project is vulnerable to: GHSA-p84v-45xj-wwqj","Warn: Project is vulnerable to: GHSA-vx9j-46rh-fqr8","Warn: Project is vulnerable to: GHSA-wpw7-wxjm-cw8r","Warn: Project is vulnerable to: GHSA-x76w-6vjr-8xgj","Warn: Project is vulnerable to: GHSA-xrr4-p6fq-hjg7","Warn: Project is vulnerable to: GHSA-3hhc-qp5v-9p2j","Warn: Project is vulnerable to: GHSA-579w-22j4-4749","Warn: Project is vulnerable to: GHSA-76r7-hhxj-r776","Warn: Project is vulnerable to: GHSA-mhwp-qhpc-h3jm","Warn: Project is vulnerable to: GHSA-xrr6-3pc4-m447","Warn: Project is vulnerable to: GHSA-46j2-xjgp-jrfm","Warn: Project is vulnerable to: GHSA-j6gc-792m-qgm2","Warn: Project is vulnerable to: GHSA-j96r-xvjq-r9pg","Warn: Project is vulnerable to: GHSA-pj73-v5mw-pm9j","Warn: Project is vulnerable to: GHSA-vxvp-4xwc-jpp6","Warn: Project is vulnerable to: GHSA-jxhc-q857-3j6g","Warn: Project is vulnerable to: GHSA-2gw2-8q9w-cw8p","Warn: Project is vulnerable to: GHSA-34hf-g744-jw64","Warn: Project is vulnerable to: GHSA-r5hc-9xx5-97rw","Warn: Project is vulnerable to: GHSA-jphg-qwrw-7w9g","Warn: Project is vulnerable to: GHSA-q86f-fmqf-qrf6","Warn: Project is vulnerable to: GHSA-242x-7cm6-4w8j","Warn: Project is vulnerable to: GHSA-286v-pcf5-25rc","Warn: Project is vulnerable to: GHSA-2qc6-mcvw-92cw","Warn: Project is vulnerable to: GHSA-2rr5-8q37-2w7h","Warn: Project is vulnerable to: GHSA-353f-x4gh-cqq8","Warn: Project is vulnerable to: GHSA-4hm9-844j-jmxp","Warn: Project is vulnerable to: GHSA-59gp-qqm7-cw4j","Warn: Project is vulnerable to: GHSA-5w6v-399v-w3cc","Warn: Project is vulnerable to: GHSA-62qp-3fxm-9wxf","Warn: Project is vulnerable to: GHSA-6qvp-r6r3-9p7h","Warn: Project is vulnerable to: GHSA-7553-jr98-vx47","Warn: Project is vulnerable to: GHSA-7hp2-xwpj-95jq","Warn: Project is vulnerable to: GHSA-7rrm-v45f-jp64","Warn: Project is vulnerable to: GHSA-882p-jqgm-f45g","Warn: Project is vulnerable to: GHSA-8c56-cpmw-89x7","Warn: Project is vulnerable to: GHSA-cf46-6xxh-pc75","Warn: Project is vulnerable to: GHSA-cgx6-hpwq-fhv5","Warn: Project is vulnerable to: GHSA-cr5j-953j-xw5p","Warn: Project is vulnerable to: GHSA-crjr-9rc5-ghw8","Warn: Project is vulnerable to: GHSA-fq42-c5rg-92c2","Warn: Project is vulnerable to: GHSA-fr52-4hqw-p27f","Warn: Project is vulnerable to: GHSA-gx8x-g87m-h5q6","Warn: Project is vulnerable to: GHSA-jc36-42cf-vqwj","Warn: Project is vulnerable to: GHSA-jmhh-w7xp-wg39","Warn: Project is vulnerable to: GHSA-jw9f-hh49-cvp9","Warn: Project is vulnerable to: GHSA-jxjr-5h69-qw3w","Warn: Project is vulnerable to: GHSA-mrxw-mxhj-p664","Warn: Project is vulnerable to: GHSA-pf6m-fxpq-fg8v","Warn: Project is vulnerable to: GHSA-pxvg-2qj5-37jq","Warn: Project is vulnerable to: GHSA-qxcg-xjjg-66mj","Warn: Project is vulnerable to: GHSA-r58r-74gx-6wx3","Warn: Project is vulnerable to: GHSA-r95h-9x8f-r3f7","Warn: Project is vulnerable to: GHSA-v4f8-2847-rwm7","Warn: Project is vulnerable to: GHSA-v6gp-9mmm-c6p5","Warn: Project is vulnerable to: GHSA-vmfx-gcfq-wvm2","Warn: Project is vulnerable to: GHSA-vr8q-g5c7-m54m","Warn: Project is vulnerable to: GHSA-vvfq-8hwr-qm4m","Warn: Project is vulnerable to: GHSA-x2fm-93ww-ggvx","Warn: Project is vulnerable to: GHSA-x7rv-cr6v-4vm4","Warn: Project is vulnerable to: GHSA-xc9x-jj77-9p9j","Warn: Project is vulnerable to: GHSA-xh29-r2w5-wx8m","Warn: Project is vulnerable to: GHSA-xjqg-9jvg-fgx2","Warn: Project is vulnerable to: GHSA-xxx9-3xcr-gjj3","Warn: Project is vulnerable to: GHSA-22f2-v57c-j9cx","Warn: Project is vulnerable to: GHSA-3h57-hmj3-gj3p","Warn: Project is vulnerable to: GHSA-54rr-7fvw-6x8f","Warn: Project is vulnerable to: GHSA-5f9h-9pjv-v6j7","Warn: Project is vulnerable to: GHSA-5r2p-j47h-mhpg","Warn: Project is vulnerable to: GHSA-7g2v-jj9q-g3rg","Warn: Project is vulnerable to: GHSA-7wqh-767x-r66v","Warn: Project is vulnerable to: GHSA-8cgq-6mh2-7j6v","Warn: Project is vulnerable to: GHSA-gjh7-p2fx-99vx","Warn: Project is vulnerable to: GHSA-hrqr-hxpp-chr3","Warn: Project is vulnerable to: GHSA-hxqx-xwvh-44m2","Warn: Project is vulnerable to: GHSA-j6w9-fv6q-3q52","Warn: Project is vulnerable to: GHSA-rgr4-9jh5-j4j6","Warn: Project is vulnerable to: GHSA-vpfw-47h7-xj4g","Warn: Project is vulnerable to: GHSA-wq4h-7r42-5hrr","Warn: Project is vulnerable to: GHSA-xj5v-6v4g-jfw6","Warn: Project is vulnerable to: GHSA-v3rr-cph9-2g2q","Warn: Project is vulnerable to: GHSA-jppv-gw3r-w3q8","Warn: Project is vulnerable to: GHSA-ggxm-pgc9-g7fp","Warn: Project is vulnerable to: GHSA-33pp-3763-mrfp","Warn: Project is vulnerable to: GHSA-pr3h-jjhj-573x","Warn: Project is vulnerable to: GHSA-5cm2-9h8c-rvfx"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T08:08:36.993Z","repository_id":909233,"created_at":"2025-08-24T08:08:36.993Z","updated_at":"2025-08-24T08:08:36.993Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29636040,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T22:32:43.237Z","status":"ssl_error","status_checked_at":"2026-02-19T22:32:38.330Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["activerecord","ruby","ruby-on-rails","sharding"],"created_at":"2024-07-30T17:01:37.711Z","updated_at":"2026-02-19T23:03:26.489Z","avatar_url":"https://github.com/thiagopradi.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Important Notice:\n\nOctopus will enter into maintainance mode once Rails 6 is released - since Rails 6 will include all the features for Database Sharding / Replication into Rails Core (PR: https://github.com/rails/rails/pull/34052).\nOnce the first version of Rails 6 beta is released, there will be a migration guide to help users migrate from Octopus to Rails 6.\n\n# Octopus - Easy Database Sharding for ActiveRecord\n\n[![Build Status](https://travis-ci.org/thiagopradi/octopus.svg)](https://travis-ci.org/thiagopradi/octopus) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/thiagopradi/octopus)\n\nOctopus is a better way to do Database Sharding in ActiveRecord. Sharding allows multiple databases in the same rails application. While there are several projects that implement Sharding (e.g. DbCharmer, DataFabric, MultiDb), each project has its own limitations. The main goal of octopus project is to provide a better way of doing Database Sharding.\n\n## Feature list:\n\nThe api is designed to be simple as possible. Octopus focuses on the end user, giving the power of multiple databases but with reliable code and flexibility. Octopus is compatible with Rails 4 and Rails 5.\n\nOctopus supports:\n\n- Sharding (with multiple shards, and grouped shards).\n- Replication (Master/slave support, with multiple slaves).\n- Moving data between shards with migrations.\n- Tools to manage database configurations. (soon)\n\n### Replication\n\nWhen using replication, all writes queries will be sent to master, and read queries to slaves. More info could be found at: \u003ca href=\"https://github.com/thiagopradi/octopus/wiki/replication\"\u003e Wiki\u003c/a\u003e\n\n### Sharding\n\nWhen using sharding, you need to specify which shard to send the query. Octopus supports selecting the shard inside a controller, or manually in each object. More could be found at \u003ca href=\"https://github.com/thiagopradi/octopus/wiki/sharding\"\u003e Wiki\u003c/a\u003e\n\n### Replication + Sharding\n\nWhen using replication and sharding concurrently, you must specify a shard, and can optionally specify a \u003ca href=\"https://github.com/thiagopradi/octopus/wiki/Slave-Groups\"\u003eslave group\u003c/a\u003e.\nAll write queries will be sent to each shard's master. If the slave group is specified read queries will be sent to slaves in it, or else to shard's master.\nMore info could be found at \u003ca href=\"https://github.com/thiagopradi/octopus/wiki/Slave-Groups\"\u003e Wiki\u003c/a\u003e\n\n## Install\n\nAdd this line to Gemfile:\n\n```\ngem 'ar-octopus'\n```\n\nCurrently, Octopus doesn't support Rails 2. If you need support for rails 2, please use the version 0.5.0.\n\n## Upgrading\n\n### From \u003c 0.5.0\n\nOctopus \u003c 0.5.0 stored schema version information in the master database defined in the database.yml file, and assumed\nthat each shard's schema matched the others and the master database. Beginning with Octopus 0.5.0, the schema version\ninformation for each shard is stored within that shard's database.\n\nIf you are upgrading from \u003c 0.5.0 run the `copy_schema_versions` rake task to copy the schema version information in the\nmaster database to each of the shards:\n\n```bash\nrake octopus:copy_schema_versions\n```\n\nOnce the task completes migrations will operate normally and schema information will be stored in each shard database\ngoing forward.\n\n## How to use Octopus?\n\nFirst, you need to create a config file, shards.yml, inside your config/ directory. to see the syntax and how this file should look, please checkout \u003ca href=\"https://github.com/thiagopradi/octopus/wiki/config-file\"\u003ethis page on wiki\u003c/a\u003e.\n\n### Syntax\n\nOctopus adds a method to each AR Class and object: the using method is used to select the shard like this:\n\n```ruby\nUser.where(:name =\u003e \"Boba\").limit(3).using(:read_replica_one)\n```\n\nOctopus also supports queries within a block. When you pass a block to the using method, all queries inside the block will be sent to the specified shard.\n\n```ruby\nOctopus.using(:read_replica_two) do\n  User.create(:name =\u003e \"Thiago\")\nend\n```\n\nIf you want to use the same code for all shards or all shards in a specific group (for example in `db/seeds.rb`), you can use this syntax.\n\n```ruby\n# This will return a list of the given block's results, per shard.\nOctopus.using_all do\n  User.create_from_csv!\nend\n\n# This will return a list of the given block's results, per shard in history_shards group.\nOctopus.using_group(:history_shards) do\n  HistoryCategory.create_from_csv!\nend\n```\n\nEach model instance knows which shard it came from so this will work automatically:\n\n```ruby\n# This will find the user in the shard1\n@user = User.using(:shard1).find_by_name(\"Joao\")\n\n# This will find the user in the master database\n@user2 = User.find_by_name(\"Jose\")\n\n#Sets the name\n@user.name = \"Mike\"\n\n# Save the user in the correct shard, shard1.\n@user.save\n```\n\n### Migrations\n\nIn migrations, you also have access to the using method. The syntax is basically the same. This migration will run in the brazil and canada shards.\n\n```ruby\nclass CreateUsersOnBothShards \u003c ActiveRecord::Migration\n  using(:brazil, :canada)\n\n  def self.up\n    User.create!(:name =\u003e \"Both\")\n  end\n\n  def self.down\n    User.delete_all\n  end\nend\n```\n\nYou also could send a migration to a group of shards. This migration will be sent to all shards that belongs to history_shards group, specified in shards.yml:\n\n```ruby\nclass CreateUsersOnMultiplesGroups \u003c ActiveRecord::Migration\n  using_group(:history_shards)\n\n  def self.up\n    User.create!(:name =\u003e \"MultipleGroup\")\n  end\n\n  def self.down\n    User.delete_all\n  end\nend\n```\n\nYou can specify a `default_migration_group` for migrations, so that modifications to each individual migration file are not needed:\n\n```yaml\noctopus:\n  default_migration_group: europe_databases\n```\n\nThere is no need for a corresponding `default_migration_shard` - simply define that database to be your master. You might want this setting if all of your databases have identical schemas, but are not replicated.\n\nYou can configure a master shard for the rails application, to connect to when rails is going up. The safest would be to configure this to the shard specified in `database.yml` (some things still use it).\n\n```yaml\noctopus:\n  master_shard: \u003c%= ENV['SHARD'] || 'shard1' %\u003e\n```\n\nThen you can use the `SHARD` environment variable to override the `master_shard` specified in `config/shards.yml`, useful for running rake tasks.\n\n```bash\nSHARD=shard1 rake db:setup \u0026\u0026 SHARD=shard2 rake db:setup\n```\n\n### Rails Controllers\n\nIf you want to send a specified action, or all actions from a controller, to a specific shard, use this syntax:\n\n```ruby\nclass ApplicationController \u003c ActionController::Base\n  around_filter :select_shard\n\n  def select_shard(\u0026block)\n    Octopus.using(:brazil, \u0026block)\n  end\nend\n```\n\nTo see the complete list of features and syntax, please check out our \u003ca href=\"https://github.com/thiagopradi/octopus/wiki/\"\u003e Wiki\u003c/a\u003e\nWant to see sample rails applications using octopus features? please check it out: \u003ca href=\"http://github.com/thiagopradi/octopus_sharding_example\"\u003eSharding Example\u003c/a\u003e and \u003ca href=\"http://github.com/thiagopradi/octopus_replication_example\"\u003eReplication Example\u003c/a\u003e. Also, we have an example that shows how to use Octopus without Rails: \u003ca href=\"http://github.com/thiagopradi/octopus_sinatra\"\u003e Octopus + Sinatra Example\u003c/a\u003e.\n\n## Mixing Octopus with the Rails multiple database model\n\nIf you want to set a custom connection to a specific model, use the syntax `octopus_establish_connection` syntax:\n\n```ruby\n#This class sets its own connection\nclass CustomConnection \u003c ActiveRecord::Base\n  octopus_establish_connection(:adapter =\u003e \"mysql\", :database =\u003e \"octopus_shard2\")\nend\n```\n\n### allow_shard\n\nIf you'd like to use specific shards with a model that has a Rails-managed connection, you can use `allow_shard`:\n\n```ruby\nclass CustomConnectedModel\n   octopus_establish_connection(...)\n   allow_shard :my_shard\nend\n\n#This uses :my_shard\nCustomConnectedModel.using(:my_shard).first\n\n#This uses the Rails-managed connection pool (the call to 'using' is ignored)\nCustomConnectedModel.using(:some_other_shard).first\n```\n\nThis can be useful if you have a model that lives in a separate database and would like to add sharding or replication to it. For other use cases, you may be better off with \u003ca href=\"https://github.com/thiagopradi/octopus/wiki/Slave-Groups\"\u003eslave groups\u003c/a\u003e.\n\n## Contributing with Octopus\n\nContributors are welcome! To run the test suite, you need mysql, postgresql and sqlite3 installed. This is what you need to setup your Octopus development environment:\n\n```bash\ngit clone http://github.com/thiagopradi/octopus.git\ncd octopus\nbundle install\nbundle exec rake db:prepare\nbundle exec rake appraisal:install\nbundle exec rake spec\n```\n\nThis command will run the spec suite for all rails versions supported.\nTo run our integrations tests inside sample_app, you need to following commands:\n\n```bash\ncd sample_app\nbundle install\ncucumber\n```\n\nIf you are having issues running the octopus spec suite, verify your database users and passwords match those inside the config files and your permissions are correct.\n\n## Contributors:\n\n- \u003ca href=\"https://github.com/thiagopradi/octopus/contributors\"\u003eAll Contributors\u003c/a\u003e\n\n## Mailing List:\n\n- \u003ca href=\"http://groups.google.com/group/octopus-activerecord/\"\u003eOctopus Mailing List\u003c/a\u003e\n\n## Thanks\n\nThis project is sponsored by the \u003ca href=\"http://www.rubysoc.org\"\u003eRuby Summer of Code\u003c/a\u003e, Rapid River Software,\nand my mentors \u003ca href=\"http://github.com/mperham\"\u003eMike Perham\u003c/a\u003e and \u003ca href=\"http://github.com/amitagarwal\"\u003eAmit Agarwal\u003c/a\u003e.\n\n## Copyright\n\nCopyright (c) Thiago Pradi, released under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagopradi%2Foctopus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiagopradi%2Foctopus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagopradi%2Foctopus/lists"}