Reorganize depot models in preparation for more.
[redakcja.git] / src / depot / migrations / 0009_sitebook_sitebookpublish_site_book.py
diff --git a/src/depot/migrations/0009_sitebook_sitebookpublish_site_book.py b/src/depot/migrations/0009_sitebook_sitebookpublish_site_book.py
new file mode 100644 (file)
index 0000000..a6aeb18
--- /dev/null
@@ -0,0 +1,58 @@
+# Generated by Django 4.1.9 on 2023-09-05 14:13
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("documents", "0011_book_woblink_id"),
+        ("depot", "0008_rename_shop_site"),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name="SiteBook",
+            fields=[
+                (
+                    "id",
+                    models.AutoField(
+                        auto_created=True,
+                        primary_key=True,
+                        serialize=False,
+                        verbose_name="ID",
+                    ),
+                ),
+                ("external_id", models.CharField(blank=True, max_length=255)),
+                ("created_at", models.DateTimeField(auto_now_add=True)),
+                (
+                    "book",
+                    models.ForeignKey(
+                        on_delete=django.db.models.deletion.CASCADE, to="documents.book"
+                    ),
+                ),
+                (
+                    "site",
+                    models.ForeignKey(
+                        null=True,
+                        on_delete=django.db.models.deletion.SET_NULL,
+                        to="depot.site",
+                    ),
+                ),
+            ],
+            options={
+                "unique_together": {("book", "site")},
+            },
+        ),
+        migrations.AddField(
+            model_name="sitebookpublish",
+            name="site_book",
+            field=models.ForeignKey(
+                blank=True,
+                null=True,
+                on_delete=django.db.models.deletion.PROTECT,
+                to="depot.sitebook",
+            ),
+        ),
+    ]