Create databases during shard creation
Issue by jberkus
Thursday Dec 04, 2014 at 22:34 GMT
Originally opened as https://github.com/citusdata/pg_shard/issues/3
Currently the user has to manually create databases on each worker to match the master. Since we require that the database names match anyways, and there are no real options here, we should just have master_create_worker_shards create the databases on workers if they don't already exist. Probably we should do this by connecting to the "postgres" database first, which would then require some extra error handling.
Comment by jasonmp85
Friday Dec 05, 2014 at 00:14 GMT
We'll have to scope this one, and I think the more general story at work here is "there are primitives above TABLE that may need to be created". We should probably enumerate them and decide which we will/won't create.
Creating a database may prove a bit problematic as I believe it's something that must be specified at connection-time, so this might involve:
- Connecting to a shard using the
postgres - Creating the proper database
- Purging that connection from our cache
- Reconnecting with the proper DB
I could be wrong about connections being DB-bound, but that was my impression.
Comment by jberkus
Friday Dec 05, 2014 at 00:18 GMT
No, that sounds right. That's what I meant by "additional error-handling"; we'll need to handle situations like if the "postgres" database doesn't exist or we can't reach it.