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

New Installation with sqlite fails migrations #5304

Closed
exu-g opened this issue Nov 28, 2024 · 2 comments
Closed

New Installation with sqlite fails migrations #5304

exu-g opened this issue Nov 28, 2024 · 2 comments
Labels
bug Something isn't working part:helm/kubernetes/docker

Comments

@exu-g
Copy link

exu-g commented Nov 28, 2024

What went wrong?

Breaking this out from #5244 (comment) as it's a separate issue

What happened:

  • Migrations are failing in an new sqlite database

What did you expect to happen:

  • Successful initial installation

How do we reproduce it?

  1. Get the docker-compose file
  2. Set the variables as described in the readme (Installation with grafana)
  3. Start with docker compose
Full log of oncall_db_migration container
/usr/local/lib/python3.12/site-packages/telegram/utils/request.py:49: UserWarning: python-telegram-bot is using upstream urllib3. This is allowed but not supported by python-telegram-bot maintainers.
  warnings.warn(
Operations to perform:
  Apply all migrations: admin, alerts, auth, auth_token, base, contenttypes, email, exotel, fcm_django, google, heartbeat, labels, mobile_app, oss_installation, phone_notifications, schedules, sessions, slack, social_django, telegram, twilioapp, user_management, webhooks, zvonok
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying alerts.0001_squashed_initial... OK
  Applying slack.0001_squashed_initial... OK
  Applying user_management.0001_squashed_initial... OK
  Applying user_management.0002_auto_20220705_1214... OK
  Applying user_management.0003_user_hide_phone_number... OK
  Applying user_management.0004_auto_20221025_0316... OK
  Applying user_management.0005_rbac_permissions... OK
  Applying user_management.0006_organization_uuid... OK
  Applying user_management.0007_organization_deleted_at... OK
  Applying user_management.0008_organization_is_grafana_incident_enabled... OK
  Applying user_management.0009_organization_cluster_slug... OK
/usr/local/lib/python3.12/site-packages/django_add_default_value/add_default_value.py:77: UserWarning: AddDefaultValue cannot be applied on a non-supported vendor.
  warnings.warn(
  Applying user_management.0010_team_is_sharing_resources_to_all... OK
  Applying user_management.0011_auto_20230411_1358... OK
  Applying user_management.0012_auto_20230711_1554... OK
  Applying user_management.0013_alter_organization_acknowledge_remind_timeout... OK
  Applying slack.0002_squashed_initial... OK
  Applying slack.0003_delete_slackactionrecord... OK
  Applying webhooks.0001_initial... OK
  Applying telegram.0001_squashed_initial... OK
  Applying schedules.0001_squashed_initial... OK
  Applying alerts.0002_squashed_initial... OK
  Applying alerts.0003_grafanaalertingcontactpoint_datasource_uid... OK
  Applying alerts.0004_auto_20220711_1106... OK
  Applying alerts.0005_alertgroup_cached_render_for_web... OK
  Applying alerts.0006_alertgroup_alerts_aler_channel_ee84a7_idx... OK
  Applying alerts.0007_populate_web_title_cache... OK
  Applying alerts.0008_alter_alertgrouplogrecord_type... OK
  Applying alerts.0009_alertreceivechannel_web_templates_modified_at... OK
  Applying alerts.0010_channelfilter_filtering_term_type... OK
  Applying webhooks.0002_auto_20230320_1604... OK
  Applying alerts.0011_auto_20230329_1617... OK
  Applying alerts.0012_auto_20230406_1010... OK
  Applying alerts.0012_alertreceivechannel_description_short... OK
  Applying alerts.0013_merge_20230418_0336... OK
  Applying alerts.0014_alertreceivechannel_restricted_at... OK
  Applying alerts.0015_auto_20230508_1641... OK
  Applying alerts.0016_auto_20230523_1355... OK
  Applying alerts.0017_alertgroup_is_restricted... OK
  Applying alerts.0018_remove_alertreceivechannel_integration_slack_channel_id... OK
  Applying alerts.0019_auto_20230705_1619... OK
  Applying alerts.0020_auto_20230711_1532... OK
  Applying alerts.0021_alter_alertgroup_started_at... OK
  Applying alerts.0022_alter_alertgroup_manual_severity... OK
  Applying alerts.0023_auto_20230718_0952... OK
  Applying alerts.0024_auto_20230718_0953... OK
  Applying alerts.0025_auto_20230718_1042... OK
  Applying alerts.0026_auto_20230719_1010... OK
  Applying alerts.0027_remove_alertreceivechannel_restricted_at_from_state... OK
  Applying alerts.0028_drop_alertreceivechannel_restricted_at... OK
  Applying alerts.0029_auto_20230728_0802... OK
  Applying user_management.0014_auto_20230728_0802... OK
  Applying user_management.0015_auto_20230926_2203... OK
  Applying user_management.0016_alter_user_role... OK
  Applying user_management.0017_alter_organization_maintenance_author... OK
  Applying user_management.0018_auto_20231115_1206... OK
  Applying user_management.0019_organization_grafana_incident_backend_url... OK
  Applying user_management.0020_organization_is_grafana_labels_enabled... OK
  Applying user_management.0021_user_google_calendar_settings... OK
  Applying user_management.0022_alter_team_unique_together... OK
  Applying user_management.0023_organization_is_grafana_irm_enabled... OK
  Applying user_management.0024_organization_direct_paging_prefer_important_policy... OK
  Applying slack.0004_auto_20230913_1020... OK
  Applying slack.0005_slackteamidentity__unified_slack_app_installed... OK
  Applying user_management.0025_organization_default_slack_channel... OK
source=engine:app google_trace_id=none logger=apps.user_management.migrations.0026_auto_20241017_1919 Starting migration to populate default_slack_channel field.
source=engine:app google_trace_id=none logger=apps.user_management.migrations.0026_auto_20241017_1919 Total organizations to process: 0
source=engine:app google_trace_id=none logger=apps.user_management.migrations.0026_auto_20241017_1919 Finished migration. Total organizations processed: 0. Organizations updated: 0. Missing SlackChannels: 0.
  Applying user_management.0026_auto_20241017_1919... OK
  Applying user_management.0027_serviceaccount... OK
  Applying base.0001_squashed_initial... OK
  Applying base.0002_squashed_initial... OK
  Applying base.0003_delete_organizationlogrecord... OK
  Applying base.0004_auto_20230616_1510... OK
  Applying base.0005_drop_unused_dynamic_settings... OK
  Applying alerts.0030_auto_20230731_0341... OK
  Applying alerts.0031_auto_20230831_1445... OK
  Applying alerts.0032_remove_alertgroup_slack_message_state... OK
  Applying alerts.0033_alertgrouplogrecord_action_source... OK
  Applying alerts.0034_alter_resolutionnote_source... OK
  Applying alerts.0035_alter_alertreceivechannel_maintenance_author... OK
  Applying alerts.0036_alertgroup_grafana_incident_id... OK
  Applying alerts.0037_remove_alertgroup_is_restricted_state... OK
  Applying alerts.0038_remove_alertgroup_is_restricted_db... OK
  Applying alerts.0039_remove_alertreceivechannel_unique_integration_name... OK
  Applying alerts.0040_alertreceivechannel_alert_group_labels_custom_and_more... OK
  Applying alerts.0041_alertreceivechannel_unique_direct_paging_integration_per_team... OK
  Applying alerts.0042_alertgroup_received_at... OK
  Applying alerts.0043_remove_alertgroup_alerts_aler_channel_81aeec_idx_and_more... OK
  Applying alerts.0044_alertreceivechannel_alertmanager_v2_backup_templates_and_more... OK
  Applying alerts.0045_escalationpolicy_notify_to_team_members_and_more... OK
  Applying alerts.0046_alertreceivechannelconnection... OK
  Applying alerts.0047_alertreceivechannel_additional_settings... OK
  Applying alerts.0048_alertgroupexternalid... OK
  Applying alerts.0049_alter_alertgrouplogrecord_action_source... OK
  Applying alerts.0050_alter_alertgrouplogrecord_type... OK
  Applying alerts.0051_remove_escalationpolicy_custom_button_trigger... OK
  Applying alerts.0052_alter_channelfilter_filtering_term_type... OK
  Applying alerts.0053_channelfilter_filtering_labels... OK
  Applying alerts.0054_usernotificationbundle_bundlednotification_and_more... OK
  Applying alerts.0055_alter_bundlednotification_alert_group... OK
  Applying alerts.0056_remove_alertgroup_slack_log_message_state... OK
  Applying alerts.0057_remove_alertgroup_slack_log_message_db... OK
  Applying alerts.0058_alter_alertgroup_reason_to_skip_escalation... OK
  Applying alerts.0059_escalationpolicy_severity_and_more... OK
  Applying alerts.0060_relatedincident... OK
  Applying alerts.0061_alter_alertgroup_resolved_by_alert... OK
  Applying alerts.0062_rename_slack_channel_id_channelfilter__slack_channel_id_and_more... OK
source=engine:app google_trace_id=none logger=apps.alerts.migrations.0063_migrate_channelfilter_slack_channel_id Starting migration to populate slack_channel field.
source=engine:app google_trace_id=none logger=apps.alerts.migrations.0063_migrate_channelfilter_slack_channel_id Total channel filters to process: 0
source=engine:app google_trace_id=none logger=apps.alerts.migrations.0063_migrate_channelfilter_slack_channel_id Finished migration. Total channel filters processed: 0. Channel filters updated: 0. Missing SlackChannels: 0.
  Applying alerts.0063_migrate_channelfilter_slack_channel_id... OK
source=engine:app google_trace_id=none logger=apps.alerts.migrations.0064_migrate_resolutionnoteslackmessage_slack_channel_id Starting migration to populate slack_channel field.
source=engine:app google_trace_id=none logger=apps.alerts.migrations.0064_migrate_resolutionnoteslackmessage_slack_channel_id Total resolution note slack messages to process: 0
source=engine:app google_trace_id=none logger=apps.alerts.migrations.0064_migrate_resolutionnoteslackmessage_slack_channel_id Finished migration. Total resolution note slack messages processed: 0. Resolution note slack messages updated: 0. Missing SlackChannels: 0.
  Applying alerts.0064_migrate_resolutionnoteslackmessage_slack_channel_id... OK
  Applying alerts.0065_alertreceivechannel_service_account... OK
  Applying alerts.0066_remove_channelfilter__slack_channel_id_and_more... OK
  Applying alerts.0067_remove_channelfilter__slack_channel_id_state... OK
  Applying alerts.0068_remove_resolutionnoteslackmessage__slack_channel_id_state... OK
  Applying alerts.0069_remove_channelfilter__slack_channel_id_db... OK
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py", line 328, in execute
    return super().execute(query, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: error in index alerts_reso_ts_a9bdf7_idx after drop column: no such column: _slack_channel_id

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

Traceback (most recent call last):
  File "/etc/app/manage.py", line 34, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.12/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.12/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/etc/app/common/migrations/remove_field.py", line 61, in database_forwards
    super().database_forwards(app_label, schema_editor, from_state, to_state)
  File "/usr/local/lib/python3.12/site-packages/django/db/migrations/operations/fields.py", line 170, in database_forwards
    schema_editor.remove_field(
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/sqlite3/schema.py", line 424, in remove_field
    super().remove_field(model, field)
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/base/schema.py", line 767, in remove_field
    self.execute(sql)
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/base/schema.py", line 201, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py", line 328, in execute
    return super().execute(query, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: error in index alerts_reso_ts_a9bdf7_idx after drop column: no such column: _slack_channel_id
  Applying alerts.0070_remove_resolutionnoteslackmessage__slack_channel_id_db...

Grafana OnCall Version

v1.13.4

Product Area

Helm/Kubernetes/Docker

Grafana OnCall Platform?

Docker

User's Browser?

No response

Anything else to add?

No response

@aristide-moonce
Copy link

I've got the exact same problem, and observed the same behaviour in v1.13.3 too.

@joeyorlando
Copy link
Contributor

a fix is being worked on, hang tight!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working part:helm/kubernetes/docker
Projects
None yet
Development

No branches or pull requests

3 participants