0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-30 19:41:46 +01:00
posthog/ee/management/commands/migrate_clickhouse.py
James Greenhill 62b5343a62
Add user param for clickhouse if provided (#3025)
* Add user param for clickhouse if provided

* remove duplicate setting - forgot it was there!

* inconsistent naming between migrations and clickhouse-driver
2021-01-20 16:54:03 -08:00

22 lines
708 B
Python

from django.core.management.base import BaseCommand
from infi.clickhouse_orm import Database # type: ignore
from posthog.settings import CLICKHOUSE_DATABASE, CLICKHOUSE_HTTP_URL, CLICKHOUSE_PASSWORD, CLICKHOUSE_USER
class Command(BaseCommand):
help = "Migrate clickhouse"
def handle(self, *args, **options):
try:
Database(
CLICKHOUSE_DATABASE,
db_url=CLICKHOUSE_HTTP_URL,
username=CLICKHOUSE_USER,
password=CLICKHOUSE_PASSWORD,
verify_ssl_cert=False,
).migrate("ee.clickhouse.migrations")
print("migration successful")
except Exception as e:
print(e)