mirror of
https://github.com/carrotquest/django-clickhouse.git
synced 2024-11-22 00:56:37 +03:00
Сделал создание стандартных типов при создании app-а.
Сделал галочку active у EventType.
This commit is contained in:
parent
33dea53aa2
commit
96300761a7
|
@ -2,7 +2,7 @@ from infi.clickhouse_orm import fields
|
|||
|
||||
from django_clickhouse.clickhouse_models import ClickHouseModel, ClickHouseMultiModel
|
||||
from django_clickhouse.engines import ReplacingMergeTree, CollapsingMergeTree
|
||||
from tests.models import TestModel, SecondTestModel
|
||||
from tests.models import TestModel, SecondaryTestModel
|
||||
|
||||
|
||||
class ClickHouseTestModel(ClickHouseModel):
|
||||
|
@ -40,7 +40,7 @@ class ClickHouseMultiTestModel(ClickHouseMultiModel):
|
|||
|
||||
|
||||
class ClickHouseSecondTestModel(ClickHouseModel):
|
||||
django_model = SecondTestModel
|
||||
django_model = SecondaryTestModel
|
||||
sync_delay = 2
|
||||
sync_enabled = True
|
||||
|
||||
|
|
|
@ -11,6 +11,6 @@ class TestModel(ClickHouseSyncModel):
|
|||
created_date = models.DateField()
|
||||
|
||||
|
||||
class SecondTestModel(ClickHouseSyncModel):
|
||||
class SecondaryTestModel(ClickHouseSyncModel):
|
||||
value = models.IntegerField()
|
||||
created_date = models.DateField()
|
||||
|
|
16
tests/routers.py
Normal file
16
tests/routers.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
class SecondaryRouter:
|
||||
def db_for_read(self, model, **hints):
|
||||
if model.__name__.lower().startswith('secondary'):
|
||||
return 'secondary'
|
||||
|
||||
def db_for_write(self, model, **hints):
|
||||
if model.__name__.lower().startswith('secondary'):
|
||||
return 'secondary'
|
||||
|
||||
def allow_relation(self, obj1, obj2, **hints):
|
||||
return True
|
||||
|
||||
def allow_migrate(self, db, app_label, model=None, **hints):
|
||||
if model.__name__.lower().startswith('secondary'):
|
||||
return 'secondary'
|
|
@ -81,3 +81,5 @@ CLICKHOUSE_REDIS_CONFIG = {
|
|||
'db': 8,
|
||||
'socket_timeout': 10
|
||||
}
|
||||
|
||||
DATABASE_ROUTERS = ['tests.routers.SecondaryRouter']
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.test import TransactionTestCase
|
|||
|
||||
from tests.clickhouse_models import ClickHouseTestModel, ClickHouseSecondTestModel, ClickHouseCollapseTestModel, \
|
||||
ClickHouseMultiTestModel
|
||||
from tests.models import TestModel, SecondTestModel
|
||||
from tests.models import TestModel, SecondaryTestModel
|
||||
|
||||
|
||||
# TestCase can't be used here:
|
||||
|
@ -113,6 +113,6 @@ class ClickHouseDjangoModelTest(TransactionTestCase):
|
|||
self.assertListEqual([('delete', 'default.1')], self.storage.get_operations(ClickHouseTestModel.get_import_key(), 10))
|
||||
|
||||
def test_clickhouse_sync_models(self):
|
||||
self.assertSetEqual({ClickHouseSecondTestModel}, SecondTestModel.get_clickhouse_sync_models())
|
||||
self.assertSetEqual({ClickHouseSecondTestModel}, SecondaryTestModel.get_clickhouse_sync_models())
|
||||
self.assertSetEqual({ClickHouseTestModel, ClickHouseCollapseTestModel, ClickHouseMultiTestModel},
|
||||
TestModel.get_clickhouse_sync_models())
|
||||
|
|
Loading…
Reference in New Issue
Block a user