Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add missing migration

Maciej Korycinskid26dac3eb2da
diff --git a/saleor/account/migrations/0034_auto_20190925_0937.py b/saleor/account/migrations/0034_auto_20190925_0937.py
new file mode 100644
index 0000000000..c406889b7d
--- /dev/null
+++ b/saleor/account/migrations/0034_auto_20190925_0937.py
@@ -0,0 +1,80 @@
+# Generated by Django 2.2.4 on 2019-09-25 14:37
+
+import django.db.models.deletion
+import oauthlib.common
+from django.db import migrations, models
+
+# import uuid
+#
+# from django.db import migrations, models
+#
+#
+# def get_token():
+# return str(uuid.uuid4())
+#
+#
+# def create_uuid(apps, schema_editor):
+# accounts = apps.get_model("account", "User").objects.all()
+# for account in accounts:
+# account.token = get_token()
+# account.save()
+#
+#
+# class Migration(migrations.Migration):
+#
+# dependencies = [("account", "0020_user_token")]
+#
+# operations = [
+# migrations.RunPython(create_uuid),
+# migrations.AlterField(
+# model_name="user",
+# name="token",
+# field=models.UUIDField(default=get_token, editable=False, unique=True),
+# ),
+# ]
+#
+#
+
+
+def move_existing_token(apps, schema_editor):
+ apps.get_model("account", "User")
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [("account", "0033_serviceaccount")]
+
+ operations = [
+ migrations.CreateModel(
+ name="ServiceAccountToken",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ ("name", models.CharField(blank=True, default="", max_length=128)),
+ (
+ "auth_token",
+ models.CharField(
+ default=oauthlib.common.generate_token,
+ max_length=30,
+ unique=True,
+ ),
+ ),
+ (
+ "service_account",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="tokens",
+ to="account.ServiceAccount",
+ ),
+ ),
+ ],
+ ),
+ migrations.RemoveField(model_name="serviceaccount", name="auth_token"),
+ ]