From 0e05f3f4ee79a773f1da3965e9cdbd0342d77f42 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 9 May 2017 23:02:21 -0700 Subject: [PATCH] emails: Remove pre-email-migration scheduled jobs. This fixes an issue introduced when we migrated the format of all of our emails, which caused any old ScheduledJob rows to be corrupted. --- .../0079_remove_old_scheduled_jobs.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 zerver/migrations/0079_remove_old_scheduled_jobs.py diff --git a/zerver/migrations/0079_remove_old_scheduled_jobs.py b/zerver/migrations/0079_remove_old_scheduled_jobs.py new file mode 100644 index 0000000000..b96eaa437b --- /dev/null +++ b/zerver/migrations/0079_remove_old_scheduled_jobs.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-05-10 05:59 +from __future__ import unicode_literals + +from django.db import migrations +from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor +from django.db.migrations.state import StateApps + +def delete_old_scheduled_jobs(apps, schema_editor): + # type: (StateApps, DatabaseSchemaEditor) -> None + """Delete any old scheduled jobs, to handle changes in the format of + that table. Ideally, we'd translate the jobs, but it's not really + worth the development effort to save a few invitation reminders + and day2 followup emails. + """ + ScheduledJob = apps.get_model('zerver', 'ScheduledJob') + ScheduledJob.objects.all().delete() + +class Migration(migrations.Migration): + + dependencies = [ + ('zerver', '0078_service'), + ] + + operations = [ + migrations.RunPython(delete_old_scheduled_jobs), + ]