2017-11-16 00:55:49 +01:00
|
|
|
from django.db import migrations
|
2023-03-04 01:40:40 +01:00
|
|
|
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
2017-04-28 01:26:50 +02:00
|
|
|
from django.db.migrations.state import StateApps
|
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2022-05-27 23:33:51 +02:00
|
|
|
def clear_analytics_tables(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:
|
2021-02-12 08:20:45 +01:00
|
|
|
UserCount = apps.get_model("analytics", "UserCount")
|
|
|
|
StreamCount = apps.get_model("analytics", "StreamCount")
|
|
|
|
RealmCount = apps.get_model("analytics", "RealmCount")
|
|
|
|
InstallationCount = apps.get_model("analytics", "InstallationCount")
|
|
|
|
FillState = apps.get_model("analytics", "FillState")
|
2017-04-28 01:26:50 +02:00
|
|
|
|
|
|
|
UserCount.objects.all().delete()
|
|
|
|
StreamCount.objects.all().delete()
|
|
|
|
RealmCount.objects.all().delete()
|
|
|
|
InstallationCount.objects.all().delete()
|
|
|
|
FillState.objects.all().delete()
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2017-04-28 01:26:50 +02:00
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
2021-02-12 08:20:45 +01:00
|
|
|
("analytics", "0010_clear_messages_sent_values"),
|
2017-04-28 01:26:50 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(clear_analytics_tables),
|
|
|
|
]
|