django-clickhouse/tests/clickhouse_models.py

40 lines
1.1 KiB
Python
Raw Normal View History

2018-11-21 14:51:19 +03:00
from infi.clickhouse_orm import fields
2018-11-21 14:50:54 +03:00
2018-11-26 17:17:58 +03:00
from django_clickhouse.clickhouse_models import ClickHouseModel, ClickHouseMultiModel
from django_clickhouse.engines import ReplacingMergeTree, CollapsingMergeTree
from tests.models import TestModel
class ClickHouseTestModel(ClickHouseModel):
django_model = TestModel
sync_delay = 2
sync_enabled = True
2018-11-15 15:37:58 +03:00
id = fields.Int32Field()
created_date = fields.DateField()
2018-11-15 15:37:58 +03:00
value = fields.Int32Field()
engine = ReplacingMergeTree('created_date', ('id',))
migrate_replicated_db_aliases = ('default', 'secondary')
migrate_non_replicated_db_aliases = ('default', 'secondary')
class ClickHouseCollapseTestModel(ClickHouseModel):
django_model = TestModel
sync_delay = 2
sync_enabled = True
id = fields.Int32Field()
created_date = fields.DateField()
value = fields.Int32Field()
sign = fields.Int8Field()
2018-11-21 14:50:54 +03:00
engine = CollapsingMergeTree('created_date', ('id',), 'sign')
2018-11-26 17:17:58 +03:00
class ClickHouseMultiTestModel(ClickHouseMultiModel):
django_model = TestModel
sub_models = [ClickHouseTestModel, ClickHouseCollapseTestModel]
sync_delay = 2
sync_enabled = True