Immigration error when upgrading Quince from Palm

Immigration error when upgrading Quince from Palm.

Hello everyone,
I got migration error when upgrading from Palm version to Quince version. I think I encountered this problem because the data in the database did not match.
I switched from Tutor version 16.1.8 to version 17.0.2.
OS: Ubuntu 22.04
Works at Tutor Local
Thanks

File "/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 255, in apply_migration
    migration_recorded = True
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/schema.py", line 166, in __exit__
    self.execute(sql)
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/schema.py", line 201, in execute
    cursor.execute(sql, params)
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
File "/openedx/venv/lib/python3.8/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 75, in execute
    return self.cursor.execute(query, args)
File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(query)
File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
django.db.utils.OperationalError: (3780, "Referencing column 'enterprise_customer_id' and referenced column 'uuid' in foreign key constraint 'enterprise_chapter8_enterprise_customer__e07a7628_fk_enterpris' are incompatible.")

Error: Command failed with status 1: docker compose -f /home/appadm/.local/share/tutor/env/local/docker-compose.yml -f /home/appadm/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor_local -f /home/appadm/.local/share/tutor/env/local/docker-compose.jobs.yml run --rm lms-job sh -c dockerize -wait tcp://172.17.13.33:3306 -timeout 20s dockerize -wait tcp://172.17.13.33:27017 -timeout 20s

echo "Loading settings $DJANGO_SETTINGS_MODULE"

./manage.py lms migrate

# Create oauth apps for CMS SSO
# https://github.com/openedx/edx-platform/blob/master/docs/guides/studio_oauth.rst
./manage.py lms manage_user cms @openedx --unusable-password
./manage.py lms create_dot_application \
    --grant-type authorization-code \
    --redirect-uris "https://test-cms.allinkitukiye.com/complete/edx-oauth2/" \
    --client-id cms-sso \
    --client-secret 8ILkz2Yy73JK05EPmwGWXk1 \
    --scopes user_id \
    --skip-authorization
./manage.py lms create_dot_application \
    --update cms-sso cms \

1 Like

Hi, what steps did you follow to upgrade? Are you getting this error every time you attempt to launch?

I ran into the same error just now, performing the same upgrade operation. My working theory, in my case, is that the installation on which Iā€™m working uses a remote MySQL service, and for several months, we deferred the upgrade from v5.8 to v8x as the new version of MySQL was not initially available at the time that openedx bumped the version. It seems plausible that the incompatibility error in the foreign key constraint might be related data conversions in openedx that would have been performed in prior named releases.

WORKAROUND
If you do NOT use enterprise features then the following workaround will squelch the symptoms, though this does not actually resolve the problem.

STEP 1: retrieve local mysql root credentials

LOCAL_TUTOR_MYSQL_ROOT_PASSWORD=$(tutor config printvalue MYSQL_ROOT_PASSWORD)
LOCAL_TUTOR_MYSQL_ROOT_USERNAME=$(tutor config printvalue MYSQL_ROOT_USERNAME)
echo "LOCAL_TUTOR_MYSQL_ROOT_PASSWORD=$LOCAL_TUTOR_MYSQL_ROOT_PASSWORD"
echo "LOCAL_TUTOR_MYSQL_ROOT_USERNAME=$LOCAL_TUTOR_MYSQL_ROOT_USERNAME"

STEP 2: coerce Django into skipping over the following two enterprise migrations

docker exec -it tutor_local-mysql-1 /bin/bash
    mysql -u{VALUE OF YOUR LOCAL_TUTOR_MYSQL_ROOT_USERNAME} -p{VALUE OF YOUR LOCAL_TUTOR_MYSQL_ROOT_PASSWORD}
INSERT django_migrations (app, name, applied) values('enterprise', '0180_chatgptresponse');
INSERT django_migrations (app, name, applied) values('enterprise', '0181_enterprisecustomerssoconfiguration_historicalenterprisecustomerssoconfiguration');

STEP 3: manually re-run the LMS migrations

tutor local run lms ./manage.py lms migrate

I also ran into the same general problem upgrading from Palm to Redwood. The corresponding workaround is the following:

INSERT django_migrations (app, name, applied) values('integrated_channel', '0030_integratedchannelapirequestlogs', '2024-09-13 16:43:44.789889');
INSERT django_migrations (app, name, applied) values('enterprise', '0200_enterprisegroup_enterprisegroupmembership_historicalenterprisegroup_historicalenterprisegroupmembers', '2024-09-13 16:43:44.789889');

But at the risk of being redundant, please be mindful that these are workarounds, not solutions.