5

I need to configure my app to use multiple shards, and even multiple db adapters. I have noticed that all rake commands like rake db:migrate are working, and have consequence on shards defined in shards.yml, except rake db:create. It will be a real pain to create all this manually. How can I make it work?

My database.yml (I have defined here, only my master shard)

development:
  adapter:  postgresql
  host:     localhost
  encoding: unicode
  database: db_workload_master_development
  pool:     5
  username: 
  password: 

production:
  ...... 

My shards.yml

octopus:
  environments:
    - production
    - development
  development:
    shards:
      mysql:
        host: localhost
        adapter: mysql2
        database: db_workload_mysql_shard_development
      sqlite:
        host: localhost
        adapter: sqlite3
        database: db_workload_sqlite_shard_development
      pg:
        host: localhost
        adapter: postgresql
        database: db_workload_pg_shard_development
        pool:     5
        username: 
        password: 
  production:
    ....

Only db's from database.yml are created with rake-task rake db:create.

Andrey Yasinishyn
  • 1,851
  • 2
  • 23
  • 36
  • Same problem here... I dont understand how to create the shard databases... Should I create them by hand? wtf – Pioz Dec 14 '17 at 15:34

2 Answers2

1

I would recommend creating your own rake task that will read the shards.yml and create the db's as appropriate.

Leonel Galán
  • 6,993
  • 2
  • 41
  • 60
omarvelous
  • 2,774
  • 14
  • 18
-1

I think the Octopus gem using shards rake task like db

Try rake shards:create