From 68914a20f0a98fa5d13b1a759453c747c05f9e9f Mon Sep 17 00:00:00 2001 From: M1ha Date: Fri, 23 Nov 2018 11:04:31 +0500 Subject: [PATCH] Infi https://github.com/Infinidat/infi.clickhouse_orm/issues/89 fix some refactoring --- src/django_clickhouse/database.py | 5 +++++ src/django_clickhouse/migrations.py | 5 ++--- tests/clickhouse_migrations/0001_initial.py | 5 ++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/django_clickhouse/database.py b/src/django_clickhouse/database.py index 5d1fc05..4d638a5 100644 --- a/src/django_clickhouse/database.py +++ b/src/django_clickhouse/database.py @@ -15,6 +15,11 @@ class Database(InfiDatabase): } super(Database, self).__init__(**infi_kwargs) + def drop_database(self): + # BUG fix https://github.com/Infinidat/infi.clickhouse_orm/issues/89 + super(Database, self).drop_database() + self.db_exists = False + def migrate(self, migrations_package_name, up_to=9999): raise NotImplementedError('This method is not supported by django-clickhouse.' ' Use django_clickhouse.migrations module instead.') diff --git a/src/django_clickhouse/migrations.py b/src/django_clickhouse/migrations.py index 916696e..626960e 100644 --- a/src/django_clickhouse/migrations.py +++ b/src/django_clickhouse/migrations.py @@ -3,16 +3,15 @@ Migrating database """ import datetime +from django.db import DEFAULT_DB_ALIAS as DJANGO_DEFAULT_DB_ALIAS from django.db.models.signals import post_migrate from django.dispatch import receiver -from django.db import DEFAULT_DB_ALIAS as DJANGO_DEFAULT_DB_ALIAS - from infi.clickhouse_orm.migrations import * from infi.clickhouse_orm.utils import import_submodules -from django_clickhouse.utils import lazy_class_import, module_exists from .configuration import config from .database import connections +from .utils import lazy_class_import, module_exists class Migration: diff --git a/tests/clickhouse_migrations/0001_initial.py b/tests/clickhouse_migrations/0001_initial.py index 15529a5..d9c0277 100644 --- a/tests/clickhouse_migrations/0001_initial.py +++ b/tests/clickhouse_migrations/0001_initial.py @@ -1,11 +1,10 @@ -from infi.clickhouse_orm.migrations import CreateTable from django_clickhouse import migrations from tests.clickhouse_models import ClickHouseTestModel, ClickHouseCollapseTestModel class Migration(migrations.Migration): operations = [ - CreateTable(ClickHouseTestModel), - CreateTable(ClickHouseCollapseTestModel) + migrations.CreateTable(ClickHouseTestModel), + migrations.CreateTable(ClickHouseCollapseTestModel) ]