wisq/rails_parallel — pull request #1 by boourns (2013-03-28 21:26:37+00:00)
Title: Add shard support to Rails Parallel

@wisq @hornairs @camilo @burke What do you think /cc @jstorimer

This PR teaches RP to create databases, and prep the schema, for many sharded databases along with the main DB.

**Shard Config:**
Config for shards exist as children of the main database config in `config/database.yml`. It looks like this (somewhat simplified):
```
test:
user: root
database: app_test
host: localhost
shard_1:
user: root
host: localhost
database: app_test_shard_1
schema: db/shard_schema.sql
```

Having the nested database definitions is the `db_charmer` convention.

You may notice the 'schema:' key in the shard config. That's the canonical SQL schema for the shard. We need to track that separately from the main schema as it's a different DB with (for now) a subset of tables. Adding it here makes it simple to map schemas to children databases. This file is checked into the application when modified.

With those conventions in place the changes to RP here are rather straightforward. Also, none of this would break RP for non-sharded users.