├── .document ├── .github ├── CODEOWNERS ├── term-check.yaml └── workflows │ ├── ci.yml │ └── publish.yml ├── .gitignore ├── .rubocop.yml ├── Changelog.md ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── active_record_shards.gemspec ├── gemfiles ├── common.rb ├── rails5.1.gemfile ├── rails5.2.gemfile ├── rails6.0.gemfile ├── rails6.1.gemfile └── rails7.0.gemfile ├── lib ├── active_record_shards.rb └── active_record_shards │ ├── association_collection_connection_selection.rb │ ├── configuration_parser.rb │ ├── connection_switcher-5-1.rb │ ├── connection_switcher-6-0.rb │ ├── connection_switcher-6-1.rb │ ├── connection_switcher-7-0.rb │ ├── connection_switcher.rb │ ├── default_replica_patches.rb │ ├── default_shard.rb │ ├── migration.rb │ ├── model.rb │ ├── schema_dumper_extension.rb │ ├── shard_selection.rb │ ├── shard_support.rb │ ├── sql_comments.rb │ └── tasks.rb └── test ├── active_record └── connection_adapters │ └── mysql2_fake_adapter.rb ├── active_record_shards ├── configuration_parser_test.rb ├── schema_dumper_extension_test.rb └── sql_comments_test.rb ├── active_record_shards_test.rb ├── check_performance.rb ├── connection_switching_test.rb ├── database.yml ├── helper.rb ├── migrator_test.rb ├── models.rb ├── on_replica_by_default_test.rb ├── schemas ├── ars_test.sql ├── ars_test2.sql ├── ars_test2_replica.sql ├── ars_test3.sql ├── ars_test3_shard0.sql ├── ars_test_replica.sql ├── ars_test_shard0.sql ├── ars_test_shard0_replica.sql ├── ars_test_shard1.sql └── ars_test_shard1_replica.sql ├── support ├── cowardly_migration │ └── 20110824010215_cowardly_migration.rb ├── database_tasks.yml ├── db_helper.rb ├── failure_migration │ └── 20110824010215_failure_migration.rb ├── migrations │ ├── 20110824010216_shard_migration.rb │ └── 20110829215912_account_migration.rb ├── separate_migrations │ ├── 20190121112233_separate_unsharded_migration.rb │ └── 20190121112234_separate_sharded_migration.rb ├── sharded_schema.rb ├── tcp_proxy.rb └── unsharded_schema.rb ├── tasks_test.rb └── thread_safety_test.rb /.document: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/.document -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/.github/CODEOWNERS -------------------------------------------------------------------------------- /.github/term-check.yaml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - Changelog.md 3 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/.github/workflows/ci.yml -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/.github/workflows/publish.yml -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/.gitignore -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/.rubocop.yml -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/Changelog.md -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/Gemfile -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/LICENSE -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/README.md -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/Rakefile -------------------------------------------------------------------------------- /active_record_shards.gemspec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/active_record_shards.gemspec -------------------------------------------------------------------------------- /gemfiles/common.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/gemfiles/common.rb -------------------------------------------------------------------------------- /gemfiles/rails5.1.gemfile: -------------------------------------------------------------------------------- 1 | eval_gemfile 'common.rb' 2 | 3 | gem 'activerecord', '~> 5.1.6' 4 | -------------------------------------------------------------------------------- /gemfiles/rails5.2.gemfile: -------------------------------------------------------------------------------- 1 | eval_gemfile 'common.rb' 2 | 3 | gem 'activerecord', '~> 5.2.0' 4 | -------------------------------------------------------------------------------- /gemfiles/rails6.0.gemfile: -------------------------------------------------------------------------------- 1 | eval_gemfile 'common.rb' 2 | 3 | gem 'activerecord', '~> 6.0.0' 4 | -------------------------------------------------------------------------------- /gemfiles/rails6.1.gemfile: -------------------------------------------------------------------------------- 1 | eval_gemfile 'common.rb' 2 | 3 | gem 'activerecord', '~> 6.1.0' 4 | -------------------------------------------------------------------------------- /gemfiles/rails7.0.gemfile: -------------------------------------------------------------------------------- 1 | eval_gemfile 'common.rb' 2 | 3 | gem 'activerecord', '~> 7.0.0' 4 | -------------------------------------------------------------------------------- /lib/active_record_shards.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards.rb -------------------------------------------------------------------------------- /lib/active_record_shards/association_collection_connection_selection.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/association_collection_connection_selection.rb -------------------------------------------------------------------------------- /lib/active_record_shards/configuration_parser.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/configuration_parser.rb -------------------------------------------------------------------------------- /lib/active_record_shards/connection_switcher-5-1.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/connection_switcher-5-1.rb -------------------------------------------------------------------------------- /lib/active_record_shards/connection_switcher-6-0.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/connection_switcher-6-0.rb -------------------------------------------------------------------------------- /lib/active_record_shards/connection_switcher-6-1.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/connection_switcher-6-1.rb -------------------------------------------------------------------------------- /lib/active_record_shards/connection_switcher-7-0.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/connection_switcher-7-0.rb -------------------------------------------------------------------------------- /lib/active_record_shards/connection_switcher.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/connection_switcher.rb -------------------------------------------------------------------------------- /lib/active_record_shards/default_replica_patches.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/default_replica_patches.rb -------------------------------------------------------------------------------- /lib/active_record_shards/default_shard.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/default_shard.rb -------------------------------------------------------------------------------- /lib/active_record_shards/migration.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/migration.rb -------------------------------------------------------------------------------- /lib/active_record_shards/model.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/model.rb -------------------------------------------------------------------------------- /lib/active_record_shards/schema_dumper_extension.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/schema_dumper_extension.rb -------------------------------------------------------------------------------- /lib/active_record_shards/shard_selection.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/shard_selection.rb -------------------------------------------------------------------------------- /lib/active_record_shards/shard_support.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/shard_support.rb -------------------------------------------------------------------------------- /lib/active_record_shards/sql_comments.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/sql_comments.rb -------------------------------------------------------------------------------- /lib/active_record_shards/tasks.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/lib/active_record_shards/tasks.rb -------------------------------------------------------------------------------- /test/active_record/connection_adapters/mysql2_fake_adapter.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/active_record/connection_adapters/mysql2_fake_adapter.rb -------------------------------------------------------------------------------- /test/active_record_shards/configuration_parser_test.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/active_record_shards/configuration_parser_test.rb -------------------------------------------------------------------------------- /test/active_record_shards/schema_dumper_extension_test.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/active_record_shards/schema_dumper_extension_test.rb -------------------------------------------------------------------------------- /test/active_record_shards/sql_comments_test.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/active_record_shards/sql_comments_test.rb -------------------------------------------------------------------------------- /test/active_record_shards_test.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/active_record_shards_test.rb -------------------------------------------------------------------------------- /test/check_performance.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/check_performance.rb -------------------------------------------------------------------------------- /test/connection_switching_test.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/connection_switching_test.rb -------------------------------------------------------------------------------- /test/database.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/database.yml -------------------------------------------------------------------------------- /test/helper.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/helper.rb -------------------------------------------------------------------------------- /test/migrator_test.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/migrator_test.rb -------------------------------------------------------------------------------- /test/models.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/models.rb -------------------------------------------------------------------------------- /test/on_replica_by_default_test.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/on_replica_by_default_test.rb -------------------------------------------------------------------------------- /test/schemas/ars_test.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/schemas/ars_test.sql -------------------------------------------------------------------------------- /test/schemas/ars_test2.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/schemas/ars_test2.sql -------------------------------------------------------------------------------- /test/schemas/ars_test2_replica.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/schemas/ars_test2_replica.sql -------------------------------------------------------------------------------- /test/schemas/ars_test3.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/schemas/ars_test3_shard0.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/schemas/ars_test_replica.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/schemas/ars_test_replica.sql -------------------------------------------------------------------------------- /test/schemas/ars_test_shard0.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/schemas/ars_test_shard0.sql -------------------------------------------------------------------------------- /test/schemas/ars_test_shard0_replica.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/schemas/ars_test_shard0_replica.sql -------------------------------------------------------------------------------- /test/schemas/ars_test_shard1.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/schemas/ars_test_shard1.sql -------------------------------------------------------------------------------- /test/schemas/ars_test_shard1_replica.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/schemas/ars_test_shard1_replica.sql -------------------------------------------------------------------------------- /test/support/cowardly_migration/20110824010215_cowardly_migration.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/support/cowardly_migration/20110824010215_cowardly_migration.rb -------------------------------------------------------------------------------- /test/support/database_tasks.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/support/database_tasks.yml -------------------------------------------------------------------------------- /test/support/db_helper.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/support/db_helper.rb -------------------------------------------------------------------------------- /test/support/failure_migration/20110824010215_failure_migration.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/support/failure_migration/20110824010215_failure_migration.rb -------------------------------------------------------------------------------- /test/support/migrations/20110824010216_shard_migration.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/support/migrations/20110824010216_shard_migration.rb -------------------------------------------------------------------------------- /test/support/migrations/20110829215912_account_migration.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/support/migrations/20110829215912_account_migration.rb -------------------------------------------------------------------------------- /test/support/separate_migrations/20190121112233_separate_unsharded_migration.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/support/separate_migrations/20190121112233_separate_unsharded_migration.rb -------------------------------------------------------------------------------- /test/support/separate_migrations/20190121112234_separate_sharded_migration.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/support/separate_migrations/20190121112234_separate_sharded_migration.rb -------------------------------------------------------------------------------- /test/support/sharded_schema.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/support/sharded_schema.rb -------------------------------------------------------------------------------- /test/support/tcp_proxy.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/support/tcp_proxy.rb -------------------------------------------------------------------------------- /test/support/unsharded_schema.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/support/unsharded_schema.rb -------------------------------------------------------------------------------- /test/tasks_test.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/tasks_test.rb -------------------------------------------------------------------------------- /test/thread_safety_test.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/active_record_shards/HEAD/test/thread_safety_test.rb --------------------------------------------------------------------------------