django-clickhouse-backend
django-clickhouse-backend copied to clipboard
Json field migration
From readme example for Event model
content = models.JSONField(default=dict)
when applying python manage.py migrate --database clickhouse - you get error
django.db.utils.OperationalError: Code: 44.
DB::Exception: Cannot create column with type 'Object('json')' because experimental Object type is not allowed. Set setting allow_experimental_object_type = 1 in order to allow it. Stack trace:
for fixing this you need to pass in settings db
"OPTIONS": {
"settings": {
"allow_experimental_object_type": 1,
}
}
then migration works
python manage.py migrate event --database clickhouse
Operations to perform:
Apply all migrations: event
Running migrations:
Applying event.0001_initial... OK
in db too
Query id: bc4656b9-94de-48e3-a921-7f16ecb603bc
┌─statement────────────────────────────────────────────────────────────────────────────────────────────────┐
1. │ CREATE TABLE stats.event_event ↴│
│↳( ↴│
│↳ `id` Int64, ↴│
│↳ `ip` IPv6, ↴│
│↳ `ipv4` IPv4, ↴│
│↳ `ip_nullable` Nullable(IPv6), ↴│
│↳ `port` UInt16, ↴│
│↳ `protocol` LowCardinality(String), ↴│
│↳ `content` Object('json'),