2017-11-16 00:55:49 +01:00
|
|
|
from django.db import migrations
|
2020-04-27 07:19:08 +02:00
|
|
|
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
|
2017-03-19 00:11:07 +01:00
|
|
|
from django.db.migrations.state import StateApps
|
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
def clear_message_sent_by_message_type_values(
|
|
|
|
apps: StateApps, schema_editor: DatabaseSchemaEditor
|
|
|
|
) -> 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-03-19 00:11:07 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
property = "messages_sent:message_type:day"
|
2017-03-19 00:11:07 +01:00
|
|
|
UserCount.objects.filter(property=property).delete()
|
|
|
|
StreamCount.objects.filter(property=property).delete()
|
|
|
|
RealmCount.objects.filter(property=property).delete()
|
|
|
|
InstallationCount.objects.filter(property=property).delete()
|
|
|
|
FillState.objects.filter(property=property).delete()
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2017-03-19 00:11:07 +01:00
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
dependencies = [("analytics", "0009_remove_messages_to_stream_stat")]
|
2017-03-19 00:11:07 +01:00
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(clear_message_sent_by_message_type_values),
|
|
|
|
]
|