#37104: Naive timestamps used in migrations should reference the same timezone
-------------------------------------+-------------------------------------
     Reporter:  James Beith          |                     Type:
                                     |  Cleanup/optimization
       Status:  new                  |                Component:  Database
                                     |  layer (models, ORM)
      Version:  6.0                  |                 Severity:  Normal
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 When creating a migration there are two reference timestamps; one in the
 filename (e.g. `0002_auto_20260518_0601.py`) and one in the source header
 (e.g. `# Generated by Django 6.0.5 on 2026-05-18 05:01`).

 The filename is
 [https://github.com/django/django/blob/6.0.5/django/db/migrations/utils.py#L24
 created here], using current local date and time (from Python's runtime
 perspective), in this example `"Europe/London"`.

 The source header is
 
[https://github.com/django/django/blob/6.0.5/django/db/migrations/writer.py#L206
 created here], using UTC if `settings.USE_TZ`, otherwise current local
 date and time similar to filename.

 This can lead to different (naive) timestamps used in the filename and
 source header. Is there any reason why they shouldn't be the same?

 In terms of a fix, I think the change might be to have the filename call
 the Django timezone util instead of straight to Python's now classmethod.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/37104>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019e3986a077-eb6bc604-048e-46cb-b064-86c87dc20896-000000%40eu-central-1.amazonses.com.

Reply via email to