mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-24 00:47:50 +01:00
parent
04dcf6048d
commit
c6ad90eca9
@ -1,7 +1,24 @@
|
|||||||
# Generated by Django 3.0.11 on 2021-03-26 12:10
|
# Generated by Django 3.0.11 on 2021-03-26 12:10
|
||||||
|
|
||||||
from django.contrib.postgres.operations import AddIndexConcurrently # type: ignore
|
from django.contrib.postgres.operations import AddIndexConcurrently # type: ignore
|
||||||
from django.db import migrations, models
|
from django.db import connection, migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
def migrate(apps, schema_editor):
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
cursor.execute(
|
||||||
|
"""SELECT exists(SELECT FROM information_schema.tables where table_name = \'posthog_event_default\')"""
|
||||||
|
)
|
||||||
|
exists = cursor.fetchone()
|
||||||
|
if not exists[0]:
|
||||||
|
cursor.execute("CREATE INDEX CONCURRENTLY posthog_eve_created_6a34ca_idx ON posthog_event(created_at)")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
print("Skipping migration 0141 because of partitions!")
|
||||||
|
|
||||||
|
|
||||||
|
def backwards(apps, schema_editor):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@ -12,7 +29,5 @@ class Migration(migrations.Migration):
|
|||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
AddIndexConcurrently(
|
migrations.RunPython(migrate, backwards),
|
||||||
model_name="event", index=models.Index(fields=["created_at"], name="posthog_eve_created_6a34ca_idx"),
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
@ -12,6 +12,10 @@ def create_user_uuid(apps, schema_editor):
|
|||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
|
|
||||||
|
def backwards(app, schema_editor):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
@ -20,7 +24,7 @@ class Migration(migrations.Migration):
|
|||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(model_name="user", name="uuid", field=models.UUIDField(blank=True, null=True),),
|
migrations.AddField(model_name="user", name="uuid", field=models.UUIDField(blank=True, null=True),),
|
||||||
migrations.RunPython(create_user_uuid),
|
migrations.RunPython(create_user_uuid, backwards),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name="user",
|
model_name="user",
|
||||||
name="uuid",
|
name="uuid",
|
||||||
|
Loading…
Reference in New Issue
Block a user