Cover cropping.
[redakcja.git] / src / cover / migrations / 0004_populate_use_file.py
diff --git a/src/cover/migrations/0004_populate_use_file.py b/src/cover/migrations/0004_populate_use_file.py
new file mode 100644 (file)
index 0000000..0ae5295
--- /dev/null
@@ -0,0 +1,26 @@
+# Generated by Django 3.1.13 on 2022-02-25 14:31
+
+from django.db import migrations
+
+
+def populate_use_file(apps, schema_editor):
+    Image = apps.get_model('cover', 'Image')
+    for img in Image.objects.all():
+        img.use_file.save(
+            "%d.jpg" % img.id,
+            img.file
+        )
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('cover', '0003_auto_20220225_1431'),
+    ]
+
+    operations = [
+        migrations.RunPython(
+            populate_use_file,
+            migrations.RunPython.noop
+        )
+    ]