Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed migration from 0.16.9 -> 0.17.1 multiple assignments to same column "status_custom_key" #8796

Open
2 of 6 tasks
lifeisafractal opened this issue Dec 31, 2024 · 11 comments
Assignees
Labels
bug Identifies a bug which needs to be addressed migration Data or schema migrations
Milestone

Comments

@lifeisafractal
Copy link
Contributor

lifeisafractal commented Dec 31, 2024

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

Describe the bug*

I'm trying to update my docker instance of inventree from 0.16.9 to 0.17.1. When running docker compose run --rm inventree-server invoke update I get the error django.db.utils.ProgrammingError: multiple assignments to same column "status_custom_key" (see full logs below). I'm not really sure how to address this and it's blocking me from upgrading to 0.17.x.

I tried wiping the database info and leaving all other settings, files, and configs in my setup the same, and I am able to deploy a fresh setup. This seems to point to some kind of issue in my database messing up the migration and not something else spurious about my setup.

Steps to Reproduce

Unfortunately this seems to be unique to my database and I can't share that publicly. I'm happy to share data with developers privately to try and debug this.

Expected behaviour

Expect to be able to migrate and start the server with all existing data.

Deployment Method

  • Docker
  • Package
  • Bare metal
  • Other - added info in Steps to Reproduce

Version Information

Below is the version info from my working instance on 0.16.9

Version Information:

InvenTree-Version: 0.16.9
Django Version: 4.2.15
Commit Hash: e0756a7
Commit Date: 2024-11-30

Database: postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-6.6.51+rpt-rpi-2712-aarch64-with
Installer: DOC

Active plugins: [{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.1.0'}, {'name': 'InvenTreeCoreNotificationsPlugin', 'slug': 'inventreecorenotificationsplugin', 'version': '1.0.0'}, {'name': 'InvenTreeCurrencyExchange', 'slug': 'inventreecurrencyexchange', 'version': '1.0.0'}, {'name': 'InvenTreeLabel', 'slug': 'inventreelabel', 'version': '1.1.0'}, {'name': 'InvenTreeLabelMachine', 'slug': 'inventreelabelmachine', 'version': '1.0.0'}, {'name': 'InvenTreeLabelSheet', 'slug': 'inventreelabelsheet', 'version': '1.0.0'}, {'name': 'DigiKeyPlugin', 'slug': 'digikeyplugin', 'version': '1.0.0'}, {'name': 'LCSCPlugin', 'slug': 'lcscplugin', 'version': '1.0.0'}, {'name': 'MouserPlugin', 'slug': 'mouserplugin', 'version': '1.0.0'}, {'name': 'TMEPlugin', 'slug': 'tmeplugin', 'version': '1.0.0'}, {'name': 'IPNAutoGenerator', 'slug': 'ipnautogenerator', 'version': None}, {'name': 'KiCadLibraryPlugin', 'slug': 'kicad-library-plugin', 'version': '1.4.3'}]

Please verify if you can reproduce this bug on the demo site.

  • I can reproduce this bug on the demo site.

Relevant log output

Running InvenTree database migrations...
Python version 3.11.9 - /usr/local/bin/python3
/root/.local/lib/python3.11/site-packages/allauth/exceptions.py:9: UserWarning: allauth.exceptions is deprecated, use allauth.core.exceptions
  warnings.warn("allauth.exceptions is deprecated, use allauth.core.exceptions")
No changes detected
Python version 3.11.9 - /usr/local/bin/python3
/root/.local/lib/python3.11/site-packages/allauth/exceptions.py:9: UserWarning: allauth.exceptions is deprecated, use allauth.core.exceptions
  warnings.warn("allauth.exceptions is deprecated, use allauth.core.exceptions")
Failed to set maintenance mode state
2024-12-30 19:23:53,209 WARNING Failed to set maintenance mode state
Failed to set maintenance mode state
2024-12-30 19:23:53,212 WARNING Failed to set maintenance mode state
Operations to perform:
  Apply all migrations: InvenTree, account, admin, auth, build, common, company, contenttypes, django_q, error_report, exchange, flags, importer, inventree_kicad, machine, order, otp_static, otp_totp, part, plugin, report, socialaccount, stock, taggit, user_sessions, users
Running migrations:
  Applying part.0128_part_testable... OK
  Applying part.0129_auto_20240815_0214...
Marking 16 Part objects as 'testable'
 OK
  Applying part.0130_alter_parttesttemplate_part... OK
  Applying build.0052_build_status_custom_key_alter_build_status... OK
  Applying build.0053_alter_build_part... OK
  Applying common.0029_inventreecustomuserstatemodel... OK
  Applying common.0030_barcodescanresult... OK
  Applying common.0031_auto_20241026_0024... OK
  Applying common.0032_selectionlist_selectionlistentry_and_more... OK
  Applying django_q.0018_task_success_index... OK
  Applying stock.0113_stockitem_status_custom_key_and_more... OK
  Applying order.0101_purchaseorder_status_custom_key_and_more... OK
  Applying order.0102_purchaseorder_destination_and_more... OK
  Applying order.0103_alter_salesorderallocation_shipment... OK
  Applying order.0104_alter_returnorderlineitem_quantity... OK
  Applying order.0105_auto_20241128_0431...Traceback (most recent call last):
  File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)
psycopg.errors.SyntaxError: multiple assignments to same column "status_custom_key"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/inventree/src/backend/InvenTree/manage.py", line 24, in <module>
    main()
  File "/home/inventree/src/backend/InvenTree/manage.py", line 20, in main
    execute_from_command_line(sys.argv)
  File "/root/.local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/root/.local/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/root/.local/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/root/.local/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/inventree/src/backend/InvenTree/InvenTree/management/commands/runmigrations.py", line 18, in handle
    check_for_migrations(force=True, reload_registry=False)
  File "/home/inventree/src/backend/InvenTree/InvenTree/tasks.py", line 677, in check_for_migrations
    call_command('migrate', interactive=False)
  File "/root/.local/lib/python3.11/site-packages/django/core/management/__init__.py", line 194, in call_command
    return command.execute(*args, **defaults)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/root/.local/lib/python3.11/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/home/inventree/src/backend/InvenTree/order/migrations/0105_auto_20241128_0431.py", line 33, in update_shipment_date
    order.save()
  File "/root/.local/lib/python3.11/site-packages/django/db/models/base.py", line 814, in save
    self.save_base(
  File "/root/.local/lib/python3.11/site-packages/django/db/models/base.py", line 877, in save_base
    updated = self._save_table(
              ^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/models/base.py", line 990, in _save_table
    updated = self._do_update(
              ^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/models/base.py", line 1054, in _do_update
    return filtered._update(values) > 0
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/models/query.py", line 1231, in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1984, in execute_sql
    cursor = super().execute_sql(result_type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
    cursor.execute(sql, params)
  File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/root/.local/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)
django.db.utils.ProgrammingError: multiple assignments to same column "status_custom_key"
ERROR: InvenTree command failed: 'python3 manage.py runmigrations'
- Refer to the error messages in the log above for more information
@lifeisafractal lifeisafractal added bug Identifies a bug which needs to be addressed question This is a question triage:not-checked Item was not checked by the core team labels Dec 31, 2024
@SchrodingersGat
Copy link
Member

SchrodingersGat commented Dec 31, 2024

@lifeisafractal thanks for the report. Are you using any custom status values for your sales orders?

If you have a dataset that you can export (via invoke export-records) you can send it to me at support at inventree dot org

@SchrodingersGat SchrodingersGat added migration Data or schema migrations and removed triage:not-checked Item was not checked by the core team labels Dec 31, 2024
@SchrodingersGat SchrodingersGat added this to the 0.17.2 milestone Dec 31, 2024
@lifeisafractal
Copy link
Contributor Author

lifeisafractal commented Dec 31, 2024

Hi @SchrodingersGat, I wasn't aware you could do custom sales order status values, so I don't think I am. It looks like all the status fields for the salesorder model instances match up against a value in the SalesOrderStatus class. I'm not 100% sure that is the custom status value you're talking about though. Aren't custom statuses a new feature in 0.17.0? I'm upgrading form 0.16.x.

// cat data.json|jq '.[] | select( .model == "order.salesorder"  ) | .fields.status '|jq -cs 'sort_by(.)|unique'
[10,15,20,30,40]

I'm only handy enough to be dangerous with these things, but it looks like the failing migration is getting triggered on these sales orders that are completed, but don't have a shipping date.

Completed sales orders with null shipment date

// cat data.json|jq '.[] | select( .model == "order.salesorder" and .fields.status == (20,30) and .fields.shipment_date == null) |(.fields.description, .fields.total_price, .fields.customer_reference) = "***REDACTED***" ' | jq -s .
[
  {
    "model": "order.salesorder",
    "pk": 10,
    "fields": {
      "metadata": {},
      "reference_int": 8,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 4,
      "link": "",
      "target_date": "2024-12-06",
      "creation_date": "2024-12-03",
      "created_by": [
        "vizzie"
      ],
      "responsible": null,
      "contact": null,
      "address": null,
      "reference": "SO-0008",
      "customer": 67,
      "status": 30,
      "customer_reference": "***REDACTED***",
      "shipment_date": null,
      "shipped_by": null
    }
  },
  {
    "model": "order.salesorder",
    "pk": 16,
    "fields": {
      "metadata": {},
      "reference_int": 14,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": null,
      "link": "",
      "target_date": null,
      "creation_date": "2024-12-11",
      "created_by": [
        "vizzie"
      ],
      "responsible": null,
      "contact": null,
      "address": null,
      "reference": "SO-0014",
      "customer": 72,
      "status": 30,
      "customer_reference": "***REDACTED***",
      "shipment_date": null,
      "shipped_by": null
    }
  }
]

I only have a handful of sales orders and the data for all those are below (I redacted a few fields). I'm a bit weary of sending over my full data dump as it has a lot of client/customer information. Let me know if there's anything else I can poke at here or if there are sub-sets of the data I can send over that'd be useful. Worst case, I can send over the full data dump, but I'd like to see if we can avoid that.

All salesorder model instances

// cat data.json|jq '.[] | select( .model == "order.salesorder" ) | (.fields.description, .fields.total_price, .fields.customer_reference) = "***REDACTED***"' | jq -s .
[
  {
    "model": "order.salesorder",
    "pk": 2,
    "fields": {
      "metadata": {},
      "reference_int": 1,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 1,
      "link": "",
      "target_date": null,
      "creation_date": "2024-07-16",
      "created_by": [
        "mattc"
      ],
      "responsible": null,
      "contact": null,
      "address": null,
      "reference": "SO-0001",
      "customer": 39,
      "status": 30,
      "customer_reference": "***REDACTED***",
      "shipment_date": "2024-07-16",
      "shipped_by": [
        "mattc"
      ]
    }
  },
  {
    "model": "order.salesorder",
    "pk": 3,
    "fields": {
      "metadata": {},
      "reference_int": 2,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 1,
      "link": "",
      "target_date": null,
      "creation_date": "2024-08-12",
      "created_by": [
        "mattc"
      ],
      "responsible": 1,
      "contact": null,
      "address": 3,
      "reference": "SO-0002",
      "customer": 39,
      "status": 20,
      "customer_reference": "***REDACTED***",
      "shipment_date": "2024-08-16",
      "shipped_by": [
        "mattc"
      ]
    }
  },
  {
    "model": "order.salesorder",
    "pk": 4,
    "fields": {
      "metadata": {},
      "reference_int": 3,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 4,
      "link": "",
      "target_date": "2024-09-13",
      "creation_date": "2024-09-13",
      "created_by": [
        "vizzie"
      ],
      "responsible": 2,
      "contact": null,
      "address": 5,
      "reference": "SO-0003",
      "customer": 59,
      "status": 15,
      "customer_reference": "***REDACTED***",
      "shipment_date": null,
      "shipped_by": null
    }
  },
  {
    "model": "order.salesorder",
    "pk": 5,
    "fields": {
      "metadata": {},
      "reference_int": 4,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 1,
      "link": "",
      "target_date": null,
      "creation_date": "2024-09-25",
      "created_by": [
        "mattc"
      ],
      "responsible": 6,
      "contact": null,
      "address": null,
      "reference": "SO-0004",
      "customer": 39,
      "status": 20,
      "customer_reference": "***REDACTED***",
      "shipment_date": "2024-10-16",
      "shipped_by": [
        "mattc"
      ]
    }
  },
  {
    "model": "order.salesorder",
    "pk": 6,
    "fields": {
      "metadata": {},
      "reference_int": 5,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 1,
      "link": "",
      "target_date": null,
      "creation_date": "2024-10-16",
      "created_by": [
        "mattc"
      ],
      "responsible": 6,
      "contact": null,
      "address": null,
      "reference": "SO-0005",
      "customer": 39,
      "status": 20,
      "customer_reference": "***REDACTED***",
      "shipment_date": "2024-10-16",
      "shipped_by": [
        "mattc"
      ]
    }
  },
  {
    "model": "order.salesorder",
    "pk": 8,
    "fields": {
      "metadata": {},
      "reference_int": 6,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 4,
      "link": "",
      "target_date": null,
      "creation_date": "2024-12-03",
      "created_by": [
        "vizzie"
      ],
      "responsible": 9,
      "contact": null,
      "address": null,
      "reference": "SO-0006",
      "customer": 70,
      "status": 30,
      "customer_reference": "***REDACTED***",
      "shipment_date": "2024-12-03",
      "shipped_by": [
        "vizzie"
      ]
    }
  },
  {
    "model": "order.salesorder",
    "pk": 9,
    "fields": {
      "metadata": {},
      "reference_int": 7,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 4,
      "link": "",
      "target_date": "2024-10-01",
      "creation_date": "2024-12-03",
      "created_by": [
        "vizzie"
      ],
      "responsible": 2,
      "contact": null,
      "address": null,
      "reference": "SO-0007",
      "customer": 71,
      "status": 30,
      "customer_reference": "***REDACTED***",
      "shipment_date": "2024-12-03",
      "shipped_by": [
        "vizzie"
      ]
    }
  },
  {
    "model": "order.salesorder",
    "pk": 10,
    "fields": {
      "metadata": {},
      "reference_int": 8,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 4,
      "link": "",
      "target_date": "2024-12-06",
      "creation_date": "2024-12-03",
      "created_by": [
        "vizzie"
      ],
      "responsible": null,
      "contact": null,
      "address": null,
      "reference": "SO-0008",
      "customer": 67,
      "status": 30,
      "customer_reference": "***REDACTED***",
      "shipment_date": null,
      "shipped_by": null
    }
  },
  {
    "model": "order.salesorder",
    "pk": 11,
    "fields": {
      "metadata": {},
      "reference_int": 9,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": null,
      "link": "",
      "target_date": "2024-10-01",
      "creation_date": "2024-12-03",
      "created_by": [
        "vizzie"
      ],
      "responsible": null,
      "contact": null,
      "address": null,
      "reference": "SO-0009",
      "customer": 69,
      "status": 30,
      "customer_reference": "***REDACTED***",
      "shipment_date": "2024-12-03",
      "shipped_by": [
        "vizzie"
      ]
    }
  },
  {
    "model": "order.salesorder",
    "pk": 12,
    "fields": {
      "metadata": {},
      "reference_int": 10,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 4,
      "link": "",
      "target_date": "2024-10-01",
      "creation_date": "2024-12-03",
      "created_by": [
        "vizzie"
      ],
      "responsible": null,
      "contact": null,
      "address": null,
      "reference": "SO-0010",
      "customer": 67,
      "status": 30,
      "customer_reference": "***REDACTED***",
      "shipment_date": "2024-12-03",
      "shipped_by": [
        "vizzie"
      ]
    }
  },
  {
    "model": "order.salesorder",
    "pk": 13,
    "fields": {
      "metadata": {},
      "reference_int": 11,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 4,
      "link": "",
      "target_date": null,
      "creation_date": "2024-12-03",
      "created_by": [
        "vizzie"
      ],
      "responsible": null,
      "contact": null,
      "address": null,
      "reference": "SO-0011",
      "customer": 68,
      "status": 30,
      "customer_reference": "***REDACTED***",
      "shipment_date": "2024-12-03",
      "shipped_by": [
        "vizzie"
      ]
    }
  },
  {
    "model": "order.salesorder",
    "pk": 14,
    "fields": {
      "metadata": {},
      "reference_int": 12,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 4,
      "link": "",
      "target_date": null,
      "creation_date": "2024-12-03",
      "created_by": [
        "vizzie"
      ],
      "responsible": 9,
      "contact": null,
      "address": null,
      "reference": "SO-0012",
      "customer": 72,
      "status": 40,
      "customer_reference": "***REDACTED***",
      "shipment_date": null,
      "shipped_by": null
    }
  },
  {
    "model": "order.salesorder",
    "pk": 15,
    "fields": {
      "metadata": {},
      "reference_int": 13,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": 4,
      "link": "",
      "target_date": null,
      "creation_date": "2024-12-03",
      "created_by": [
        "vizzie"
      ],
      "responsible": null,
      "contact": null,
      "address": null,
      "reference": "SO-0013",
      "customer": 72,
      "status": 40,
      "customer_reference": "***REDACTED***",
      "shipment_date": null,
      "shipped_by": null
    }
  },
  {
    "model": "order.salesorder",
    "pk": 16,
    "fields": {
      "metadata": {},
      "reference_int": 14,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": null,
      "link": "",
      "target_date": null,
      "creation_date": "2024-12-11",
      "created_by": [
        "vizzie"
      ],
      "responsible": null,
      "contact": null,
      "address": null,
      "reference": "SO-0014",
      "customer": 72,
      "status": 30,
      "customer_reference": "***REDACTED***",
      "shipment_date": null,
      "shipped_by": null
    }
  },
  {
    "model": "order.salesorder",
    "pk": 17,
    "fields": {
      "metadata": {},
      "reference_int": 15,
      "notes": null,
      "barcode_data": "",
      "barcode_hash": "",
      "total_price_currency": "USD",
      "total_price": "***REDACTED***",
      "order_currency": "",
      "description": "***REDACTED***",
      "project_code": null,
      "link": "",
      "target_date": null,
      "creation_date": "2024-12-13",
      "created_by": [
        "vizzie"
      ],
      "responsible": null,
      "contact": null,
      "address": null,
      "reference": "SO-0015",
      "customer": 68,
      "status": 10,
      "customer_reference": "***REDACTED***",
      "shipment_date": null,
      "shipped_by": null
    }
  }
]

@lifeisafractal
Copy link
Contributor Author

lifeisafractal commented Dec 31, 2024

As a work around to get on 0.17.1, I manually added ship dates to those two sales orders in the admin interface. After that, I could successfully migrate and update to 0.17.1.

I'm good now since I won't need to do this again, but I'm happy to help out if you want to root cause this further. I still have the json data dump if we want to poke at it, and I can also deploy a sandbox instance from my backups with the older data if we want to experiment with anything (for my reference, my backup snapshot right prior to migration with this issue is 2d4fecc4 scratch that, didn't tag that hourly backup to keep in time. I'm sure I've got a daily that will have this issue too though if we want to dig into it).

If this feels like an edge case you don't want to dig further on, feel free to close out this issue. Thanks @SchrodingersGat and the whole Inventree team for all your great work!

@SchrodingersGat
Copy link
Member

The issue with this data migration seems to be related to an issue I came across during the original migration:

#8585 (comment)

@matmair this appears to be something to do with the way that the custom status fields are attached to the model. During a "migration" run, the field seems to be attached multiple times...

@matmair matmair removed the question This is a question label Jan 2, 2025
@matmair
Copy link
Member

matmair commented Jan 2, 2025

Can reproduce; not sure why - looking into it

@matmair matmair self-assigned this Jan 2, 2025
@SchrodingersGat
Copy link
Member

@matmair have you made any progress on this? I am holding off on 0.17.2 so we can get this worked out

@matmair
Copy link
Member

matmair commented Jan 5, 2025

Not really, I am playing around with the migrations but I do not really know where this is comming from

@matmair
Copy link
Member

matmair commented Jan 5, 2025

I have a solution, will submit in the next few hours

matmair added a commit to matmair/InvenTree that referenced this issue Jan 5, 2025
@matmair
Copy link
Member

matmair commented Jan 5, 2025

it seems to work in matmair#281; maybe I need to change the migration order

@SchrodingersGat
Copy link
Member

@matmair intersting.. would be good to get a patch in for 0.17.2 if changing the order works

@SchrodingersGat SchrodingersGat modified the milestones: 0.17.2, 0.17.3 Jan 7, 2025
@SchrodingersGat
Copy link
Member

SchrodingersGat commented Jan 10, 2025

maybe I need to change the migration order

@matmair did you come to a conclusion here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identifies a bug which needs to be addressed migration Data or schema migrations
Projects
None yet
Development

No branches or pull requests

3 participants