File: 0006_taskresult_date_created.py

package info (click to toggle)
python-django-celery-results 2.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 696 kB
  • sloc: python: 2,373; makefile: 312; sh: 7; sql: 2
file content (46 lines) | stat: -rw-r--r-- 1,399 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Generated by Django 2.2.4 on 2019-08-21 19:53

# this file is auto-generated so don't do flake8 on it
# flake8: noqa


import django.utils.timezone
from django.db import migrations, models


def copy_date_done_to_date_created(apps, schema_editor):
    TaskResult = apps.get_model('django_celery_results', 'taskresult')
    db_alias = schema_editor.connection.alias
    TaskResult.objects.using(db_alias).all().update(
        date_created=models.F('date_done')
    )


def reverse_copy_date_done_to_date_created(app, schema_editor):
    # the reverse of 'copy_date_done_to_date_created' is do nothing
    # because the 'date_created' will be removed.
    pass


class Migration(migrations.Migration):

    dependencies = [
        ('django_celery_results', '0005_taskresult_worker'),
    ]

    operations = [
        migrations.AddField(
            model_name='taskresult',
            name='date_created',
            field=models.DateTimeField(
                auto_now_add=True,
                db_index=True,
                default=django.utils.timezone.now,
                help_text='Datetime field when the task result was created in UTC',
                verbose_name='Created DateTime'
            ),
            preserve_default=False,
        ),
        migrations.RunPython(copy_date_done_to_date_created,
                             reverse_copy_date_done_to_date_created),
    ]