"Table 'openedx.waffle_switch' doesn't exist"

Hi there,
I got an issue when I start Tutor on my computer.
When I browse to local.overhang.io:8000 after started dev environment, I got this message:

ProgrammingError at /

(1146, “Table ‘openedx.waffle_switch’ doesn’t exist”)

Traceback:

Environment:


Request Method: GET
Request URL: http://local.overhang.io:8000/

Django Version: 3.2.15
Python Version: 3.8.12
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.humanize',
 'django.contrib.messages',
 'django.contrib.redirects',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.staticfiles',
 'django_celery_results',
 'openedx.core.djangoapps.common_initialization.apps.CommonInitializationConfig',
 'lms.djangoapps.lms_initialization.apps.LMSInitializationConfig',
 'openedx.core.djangoapps.common_views',
 'simple_history',
 'config_models',
 'openedx.core.djangoapps.config_model_utils',
 'waffle',
 'openedx.core.djangoapps.service_status',
 'common.djangoapps.status',
 'common.djangoapps.edxmako.apps.EdxMakoConfig',
 'pipeline',
 'common.djangoapps.static_replace',
 'webpack_loader',
 'web_fragments',
 'openedx.core.djangoapps.plugin_api',
 'openedx.core.djangoapps.contentserver',
 'openedx.core.djangoapps.site_configuration',
 'openedx.core.djangoapps.video_config',
 'openedx.core.djangoapps.video_pipeline',
 'lms.djangoapps.courseware',
 'common.djangoapps.student.apps.StudentConfig',
 'common.djangoapps.split_modulestore_django.apps.SplitModulestoreDjangoBackendAppConfig',
 'lms.djangoapps.static_template_view',
 'lms.djangoapps.staticbook',
 'common.djangoapps.track',
 'eventtracking.django.apps.EventTrackingConfig',
 'common.djangoapps.util',
 'lms.djangoapps.certificates.apps.CertificatesConfig',
 'lms.djangoapps.instructor_task',
 'openedx.core.djangoapps.course_groups',
 'lms.djangoapps.bulk_email',
 'lms.djangoapps.branding',
 'lms.djangoapps.course_home_api',
 'lms.djangoapps.user_tours',
 'openedx.core.djangoapps.xblock.apps.LmsXBlockAppConfig',
 'lms.djangoapps.support',
 'oauth2_provider',
 'openedx.core.djangoapps.oauth_dispatch.apps.OAuthDispatchAppConfig',
 'common.djangoapps.third_party_auth',
 'openedx.core.djangoapps.system_wide_roles',
 'openedx.core.djangoapps.auth_exchange',
 'wiki',
 'django_notify',
 'lms.djangoapps.course_wiki',
 'mptt',
 'sekizai',
 'wiki.plugins.links',
 'lms.djangoapps.course_wiki.plugins.markdownedx',
 'django.contrib.admin',
 'lms.djangoapps.debug',
 'openedx.core.djangoapps.util.apps.UtilConfig',
 'openedx.core.djangoapps.django_comment_common',
 'lms.djangoapps.edxnotes',
 'splash',
 'rest_framework',
 'openedx.core.djangoapps.user_api',
 'common.djangoapps.course_modes.apps.CourseModesConfig',
 'openedx.core.djangoapps.enrollments.apps.EnrollmentsConfig',
 'common.djangoapps.entitlements.apps.EntitlementsConfig',
 'lms.djangoapps.bulk_enroll',
 'lms.djangoapps.verify_student.apps.VerifyStudentConfig',
 'openedx.core.djangoapps.dark_lang',
 'lms.djangoapps.rss_proxy',
 'openedx.core.djangoapps.embargo',
 'common.djangoapps.course_action_state',
 'edx_jsme',
 'django_countries',
 'lms.djangoapps.mobile_api.apps.MobileApiConfig',
 'social_django',
 'lms.djangoapps.survey.apps.SurveyConfig',
 'lms.djangoapps.lms_xblock.apps.LMSXBlockConfig',
 'submissions',
 'openassessment',
 'openassessment.assessment',
 'openassessment.fileupload',
 'openassessment.staffgrader',
 'openassessment.workflow',
 'openassessment.xblock',
 'edxval',
 'openedx.core.djangoapps.content.course_overviews.apps.CourseOverviewsConfig',
 'openedx.core.djangoapps.content.block_structure.apps.BlockStructureConfig',
 'lms.djangoapps.course_blocks',
 'lms.djangoapps.mailing',
 'corsheaders',
 'openedx.core.djangoapps.cors_csrf',
 'lms.djangoapps.commerce.apps.CommerceConfig',
 'openedx.core.djangoapps.credit.apps.CreditConfig',
 'lms.djangoapps.teams',
 'common.djangoapps.xblock_django',
 'openedx.core.djangoapps.programs.apps.ProgramsConfig',
 'openedx.core.djangoapps.catalog',
 'openedx.core.djangoapps.self_paced',
 'sorl.thumbnail',
 'milestones',
 'lms.djangoapps.gating.apps.GatingConfig',
 'statici18n',
 'openedx.core.djangoapps.api_admin',
 'openedx.core.djangoapps.verified_track_content',
 'lms.djangoapps.learner_dashboard',
 'lms.djangoapps.badges.apps.BadgesConfig',
 'django_sites_extensions',
 'lms.djangoapps.email_marketing.apps.EmailMarketingConfig',
 'release_util',
 'rules.apps.AutodiscoverRulesConfig',
 'bridgekeeper',
 'celery_utils',
 'openedx.core.djangoapps.crawlers',
 'common.djangoapps.database_fixups',
 'openedx.core.djangoapps.waffle_utils',
 'lms.djangoapps.course_goals.apps.CourseGoalsConfig',
 'openedx.features.calendar_sync',
 'openedx.features.course_bookmarks',
 'openedx.features.course_experience',
 'openedx.features.course_search',
 'openedx.features.enterprise_support.apps.EnterpriseSupportConfig',
 'openedx.features.learner_profile',
 'openedx.features.course_duration_limits',
 'openedx.features.content_type_gating',
 'openedx.features.discounts',
 'openedx.features.effort_estimation',
 'openedx.features.name_affirmation_api.apps.NameAffirmationApiConfig',
 'lms.djangoapps.experiments',
 'django_filters',
 'drf_yasg',
 'csrf.apps.CsrfAppConfig',
 'xss_utils',
 'openedx.core.djangoapps.heartbeat',
 'openedx.core.djangoapps.course_date_signals',
 'openedx.core.djangoapps.external_user_ids',
 'openedx.core.djangoapps.demographics',
 'openedx.core.djangoapps.schedules',
 'rest_framework_jwt',
 'openedx.core.djangoapps.content.learning_sequences.apps.LearningSequencesConfig',
 'organizations',
 'lms.djangoapps.bulk_user_retirement',
 'openedx.core.djangoapps.agreements',
 'edx_django_utils.user',
 'pylti1p3.contrib.django.lti1p3_tool_config',
 'edx_ace',
 'lms.djangoapps.save_for_later',
 'blockstore.apps.bundles',
 'edx_sga',
 'enterprise',
 'consent',
 'integrated_channels.integrated_channel',
 'integrated_channels.degreed',
 'integrated_channels.degreed2',
 'integrated_channels.sap_success_factors',
 'integrated_channels.cornerstone',
 'integrated_channels.xapi',
 'integrated_channels.blackboard',
 'integrated_channels.canvas',
 'integrated_channels.moodle',
 'django_object_actions',
 'openedx.core.djangoapps.ace_common.apps.AceCommonConfig',
 'openedx.features.announcements.apps.AnnouncementsConfig',
 'openedx.core.djangoapps.bookmarks.apps.BookmarksConfig',
 'openedx.core.djangoapps.content_libraries.apps.ContentLibrariesConfig',
 'openedx.core.djangoapps.course_apps.apps.CourseAppsConfig',
 'openedx.core.djangoapps.course_live.apps.CourseLiveConfig',
 'openedx.core.djangoapps.courseware_api.apps.CoursewareAPIConfig',
 'openedx.core.djangoapps.credentials.apps.CredentialsConfig',
 'lms.djangoapps.discussion.apps.DiscussionConfig',
 'openedx.core.djangoapps.discussions.apps.DiscussionsConfig',
 'lms.djangoapps.grades.apps.GradesConfig',
 'lms.djangoapps.instructor.apps.InstructorConfig',
 'openedx.core.djangoapps.password_policy.apps.PasswordPolicyConfig',
 'openedx.core.djangoapps.plugins.apps.PluginsConfig',
 'lms.djangoapps.program_enrollments.apps.ProgramEnrollmentsConfig',
 'openedx.core.djangoapps.theming.apps.ThemingConfig',
 'openedx.core.djangoapps.user_authn.apps.UserAuthnConfig',
 'openedx.core.djangoapps.zendesk_proxy.apps.ZendeskProxyConfig',
 'completion.apps.CompletionAppConfig',
 'edx_name_affirmation.apps.EdxNameAffirmationConfig',
 'edx_proctoring.apps.EdxProctoringConfig',
 'edx_when.apps.EdxWhenConfig',
 'edx_toggles.apps.TogglesConfig',
 'super_csv.apps.SuperCSVConfig',
 'bulk_grades.apps.BulkGradesConfig',
 'lti_consumer.apps.LTIConsumerApp',
 'debug_toolbar']
Installed Middleware:
['openedx.core.lib.x_forwarded_for.middleware.XForwardedForMiddleware',
 'crum.CurrentRequestUserMiddleware',
 'edx_django_utils.cache.middleware.RequestCacheMiddleware',
 'edx_django_utils.monitoring.CachedCustomMonitoringMiddleware',
 'edx_django_utils.monitoring.CodeOwnerMonitoringMiddleware',
 'edx_django_utils.monitoring.CookieMonitoringMiddleware',
 'edx_django_utils.monitoring.DeploymentMonitoringMiddleware',
 'openedx.core.djangoapps.cookie_metadata.middleware.CookieNameChange',
 'openedx.core.lib.request_utils.ExpectedErrorMiddleware',
 'lms.djangoapps.mobile_api.middleware.AppVersionUpgrade',
 'openedx.core.djangoapps.header_control.middleware.HeaderControlMiddleware',
 'lms.djangoapps.discussion.django_comment_client.middleware.AjaxExceptionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sites.middleware.CurrentSiteMiddleware',
 'edx_rest_framework_extensions.auth.jwt.middleware.JwtAuthCookieMiddleware',
 'django_sites_extensions.middleware.RedirectMiddleware',
 'openedx.core.djangoapps.safe_sessions.middleware.SafeSessionMiddleware',
 'openedx.core.djangoapps.cache_toolbox.middleware.CacheBackedAuthenticationMiddleware',
 'common.djangoapps.student.middleware.UserStandingMiddleware',
 'openedx.core.djangoapps.contentserver.middleware.StaticContentServer',
 'openedx.core.djangoapps.user_api.middleware.UserTagsEventContextMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'common.djangoapps.track.middleware.TrackMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'openedx.core.djangoapps.cors_csrf.middleware.CorsCSRFMiddleware',
 'openedx.core.djangoapps.cors_csrf.middleware.CsrfCrossDomainCookieMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'splash.middleware.SplashMiddleware',
 'openedx.core.djangoapps.geoinfo.middleware.CountryMiddleware',
 'openedx.core.djangoapps.embargo.middleware.EmbargoMiddleware',
 'enterprise.middleware.EnterpriseLanguagePreferenceMiddleware',
 'openedx.core.djangoapps.lang_pref.middleware.LanguagePreferenceMiddleware',
 'openedx.core.djangoapps.dark_lang.middleware.DarkLangMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'lms.djangoapps.discussion.django_comment_client.utils.ViewNameMiddleware',
 'codejail.django_integration.ConfigureCodeJailMiddleware',
 'openedx.core.djangoapps.session_inactivity_timeout.middleware.SessionInactivityTimeout',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'lms.djangoapps.courseware.middleware.CacheCourseIdMiddleware',
 'lms.djangoapps.courseware.middleware.RedirectMiddleware',
 'lms.djangoapps.course_wiki.middleware.WikiAccessMiddleware',
 'openedx.core.djangoapps.theming.middleware.CurrentSiteThemeMiddleware',
 'waffle.middleware.WaffleMiddleware',
 'edx_django_utils.cache.middleware.TieredCacheMiddleware',
 'edx_rest_framework_extensions.middleware.RequestCustomAttributesMiddleware',
 'edx_rest_framework_extensions.auth.jwt.middleware.EnsureJWTAuthSettingsMiddleware',
 'simple_history.middleware.HistoryRequestMiddleware',
 'openedx.core.djangoapps.site_configuration.middleware.SessionCookieDomainOverrideMiddleware',
 'lms.djangoapps.discussion.django_comment_client.utils.QueryCountDebugMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware',
 'common.djangoapps.third_party_auth.middleware.ExceptionMiddleware']



Traceback (most recent call last):
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)

The above exception ((1146, "Table 'openedx.waffle_switch' doesn't exist")) was the direct cause of the following exception:
  File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/openedx/venv/lib/python3.8/site-packages/django/utils/deprecation.py", line 116, in __call__
    response = self.process_request(request)
  File "/openedx/edx-platform/openedx/core/lib/x_forwarded_for/middleware.py", line 100, in process_request
    if ip.USE_LEGACY_IP.is_enabled():
  File "/openedx/venv/lib/python3.8/site-packages/edx_toggles/toggles/internal/waffle/switch.py", line 25, in is_enabled
    value = switch_is_active(self.name)
  File "/openedx/venv/lib/python3.8/site-packages/waffle/__init__.py", line 22, in switch_is_active
    switch = Switch.get(switch_name)
  File "/openedx/venv/lib/python3.8/site-packages/waffle/models.py", line 46, in get
    obj = cls.get_from_db(name)
  File "/openedx/venv/lib/python3.8/site-packages/waffle/models.py", line 59, in get_from_db
    return objects.get(name=name)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 431, in get
    num = len(clone)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 262, in __len__
    self._fetch_all()
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 51, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
    cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/utils.py", line 90, 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 84, in _execute
    return self.cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)

Exception Type: ProgrammingError at /
Exception Value: (1146, "Table 'openedx.waffle_switch' doesn't exist")```

How can I fix this?

Hello @Quentin_s and welcome to the community!

I am not sure why this error is coming in the first place but maybe you can resolve it using following command (you can give it a try):

tutor dev run lms ./manage.py lms migrate

The above command will simply run migrations for your edx-platform.
I hope this will help!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.