For distributed environments, use the following configuration options in DATABASES[...]['OPTIONS']:
migration_cluster: Specifies the cluster name where the migration table should be created. If not specified, migrations are local.distributed_migrations: (Boolean) If True, a distributed migration table is created on all nodes, allowing migrations to be performed via a load balancer.TEST: Use this key to configure test database behavior for specific cluster nodes.
Distributed Table Example:
To create a distributed table, define the Distributed engine in your model's Meta class and specify the cluster attribute.
class DistributedStudent(models.ClickhouseModel):
name = models.StringField()
score = models.Int8Field()
class Meta:
engine = models.Distributed(
"cluster",
models.currentDatabase(),
Student._meta.db_table,
models.Rand()
)
cluster = "cluster"
DATABASES = {
"default": {
"ENGINE": "clickhouse_backend.backend",
"HOST": "clickhouse-load-balancer",
"OPTIONS": {
"migration_cluster": "cluster",
"distributed_migrations": True,
"settings": {
"mutations_sync": 2,
"insert_distributed_sync": 1,
},
},
}
}