stash
All checks were successful
/ test (push) Successful in 52s
/ deploy (push) Successful in 4m46s

This commit is contained in:
j3d1 2024-11-22 00:22:11 +01:00
parent 0eaff2266c
commit aebdeab99d
2 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,23 @@
# Generated by Django 4.2.7 on 2024-11-21 22:40
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('files', '0002_alter_file_file'),
]
def set_creation_date(apps, schema_editor):
File = apps.get_model('files', 'File')
for file in File.objects.all():
if file.created_at is None:
if not file.item.created_at is None:
file.created_at = file.item.created_at
else:
file.created_at = max(File.objects.filter(
id__lt=file.id,created_at__isnull=False).values_list('created_at', flat=True))
operations = [
migrations.RunPython(set_creation_date),
]