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
|
2018-11-22 09:09:38 +03:00
|
|
|
from django_clickhouse.engines import ReplacingMergeTree, CollapsingMergeTree
|
2019-01-10 13:05:16 +03:00
|
|
|
from tests.models import TestModel, SecondaryTestModel
|
2018-11-15 11:02:05 +03:00
|
|
|
|
|
|
|
|
2018-11-16 13:16:36 +03:00
|
|
|
class ClickHouseTestModel(ClickHouseModel):
|
2018-11-15 11:02:05 +03:00
|
|
|
django_model = TestModel
|
2018-11-20 15:24:15 +03:00
|
|
|
sync_delay = 2
|
2018-12-03 14:41:34 +03:00
|
|
|
sync_enabled = True
|
2018-11-15 14:50:38 +03:00
|
|
|
|
2018-11-15 15:37:58 +03:00
|
|
|
id = fields.Int32Field()
|
2018-11-15 14:50:38 +03:00
|
|
|
created_date = fields.DateField()
|
2019-06-26 10:24:46 +03:00
|
|
|
value = fields.Int32Field(default=100500)
|
2019-02-15 13:19:27 +03:00
|
|
|
str_field = fields.StringField()
|
2018-11-15 14:50:38 +03:00
|
|
|
|
2018-11-22 09:09:38 +03:00
|
|
|
engine = ReplacingMergeTree('created_date', ('id',))
|
2018-12-18 13:45:10 +03:00
|
|
|
migrate_replicated_db_aliases = ('default', 'secondary')
|
|
|
|
migrate_non_replicated_db_aliases = ('default', 'secondary')
|
2018-11-16 13:16:36 +03:00
|
|
|
|
|
|
|
|
|
|
|
class ClickHouseCollapseTestModel(ClickHouseModel):
|
|
|
|
django_model = TestModel
|
2018-11-20 15:24:15 +03:00
|
|
|
sync_delay = 2
|
2018-11-29 17:10:41 +03:00
|
|
|
sync_enabled = True
|
2018-11-16 13:16:36 +03:00
|
|
|
|
|
|
|
id = fields.Int32Field()
|
2019-01-14 10:45:46 +03:00
|
|
|
created = fields.DateTimeField()
|
2018-11-16 13:16:36 +03:00
|
|
|
value = fields.Int32Field()
|
2019-02-05 13:13:15 +03:00
|
|
|
sign = fields.Int8Field(default=1)
|
2019-01-11 11:00:42 +03:00
|
|
|
version = fields.Int8Field(default=1)
|
2018-11-16 13:16:36 +03:00
|
|
|
|
2019-01-16 15:17:48 +03:00
|
|
|
engine = CollapsingMergeTree('created', ('id',), 'sign')
|
2018-11-26 17:17:58 +03:00
|
|
|
|
|
|
|
|
|
|
|
class ClickHouseMultiTestModel(ClickHouseMultiModel):
|
|
|
|
django_model = TestModel
|
|
|
|
sub_models = [ClickHouseTestModel, ClickHouseCollapseTestModel]
|
2018-12-03 14:41:34 +03:00
|
|
|
sync_delay = 2
|
|
|
|
sync_enabled = True
|
2019-01-09 13:14:53 +03:00
|
|
|
|
|
|
|
|
|
|
|
class ClickHouseSecondTestModel(ClickHouseModel):
|
2019-01-10 13:05:16 +03:00
|
|
|
django_model = SecondaryTestModel
|
2019-01-09 13:14:53 +03:00
|
|
|
sync_delay = 2
|
|
|
|
sync_enabled = True
|
|
|
|
|
|
|
|
id = fields.Int32Field()
|
|
|
|
created_date = fields.DateField()
|
|
|
|
value = fields.Int32Field()
|
|
|
|
|
|
|
|
engine = ReplacingMergeTree('created_date', ('id',))
|