Repository: saleor/saleor

Issue:
Database migrate is failing
### What I'm trying to achieve
I'm trying to run `python manage.py migrate` on our existing Saleor dev instance with existing data in the database. I'm currently using the state from master. The database is using version 2.9.0.

I receive the following message:
```
Operations to perform:
  Apply all migrations: account, auth, checkout, contenttypes, core, discount, django_prices_openexchangerates, django_prices_vatlayer, extensions, giftcard, menu, order, page, payment, product, shipping, site, sites, warehouse, webhook, wishlist
Running migrations:
  Applying product.0112_auto_20200129_0050...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 231, in handle
    post_migrate_state = executor.migrate(
  File "/usr/local/lib/python3.8/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.8/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.8/site-packages/django/db/migrations/executor.py", line 245, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python3.8/site-packages/django/db/migrations/migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python3.8/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/app/saleor/product/migrations/0112_auto_20200129_0050.py", line 28, in create_unique_slugs_for_producttypes
    slug_values.append(slug)
AttributeError: 'QuerySet' object has no attribute 'append'
``` 


### Steps to reproduce the problem
I don't know, if you can reproduce the issue, as it might be because of the existing data in the database.
Nevertheless, this migration has to work, as it is highly realistic, that it will fail in our production environment as well.

### What I expected to happen
Migration runs successfully. 

### Screenshots

**System information**
Operating system: Using Saleor in Docker



Discussion:
Hey @JannikZed. Thank you for pointing this out! It looks like a bug on our side. We'll fix it soon. Thanks :) 

Resolving patch:
diff --git a/saleor/product/migrations/0112_auto_20200129_0050.py b/saleor/product/migrations/0112_auto_20200129_0050.py
--- a/saleor/product/migrations/0112_auto_20200129_0050.py
+++ b/saleor/product/migrations/0112_auto_20200129_0050.py
@@ -19,9 +19,11 @@ def create_unique_slugs_for_producttypes(apps, schema_editor):
         first_char = product_type.name[0].lower()
         if first_char != previous_char:
             previous_char = first_char
-            slug_values = ProductType.objects.filter(
-                slug__istartswith=first_char
-            ).values_list("slug", flat=True)
+            slug_values = list(
+                ProductType.objects.filter(slug__istartswith=first_char).values_list(
+                    "slug", flat=True
+                )
+            )
 
         slug = generate_unique_slug(product_type, slug_values)
         product_type.slug = slug


Test patch: