From 86ca43858ddf6e4b408fca9d1ee8d1a2d0be9ff1 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Thu, 28 Nov 2024 13:05:22 -0500 Subject: [PATCH] fix: address django migration failing on SQLite (#5308) ## Which issue(s) this PR closes Fixes https://github.com/grafana/oncall/issues/5306 (and related to https://github.com/grafana/oncall/issues/5244#issuecomment-2503999986) + add CI check to avoid this from happening in the future ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] Added the relevant release notes label (see labels prefixed w/ `release:`). These labels dictate how your PR will show up in the autogenerated release notes. --- .github/workflows/linting-and-tests.yml | 14 ++++++++++++- ...onnoteslackmessage__slack_channel_id_db.py | 20 +++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/linting-and-tests.yml b/.github/workflows/linting-and-tests.yml index d9450663..7a01bbe0 100644 --- a/.github/workflows/linting-and-tests.yml +++ b/.github/workflows/linting-and-tests.yml @@ -190,9 +190,15 @@ jobs: uses: actions/checkout@v4 - name: Setup Python uses: ./.github/actions/setup-python + - name: Wait for MySQL to be ready + working-directory: engine + run: ./wait_for_test_mysql_start.sh + - name: Test Django migrations work from blank slate + working-directory: engine + run: python manage.py migrate - name: Unit Test Backend working-directory: engine - run: ./wait_for_test_mysql_start.sh && pytest -x + run: pytest -x unit-test-backend-postgresql-rabbitmq: name: "Backend Tests: PostgreSQL + RabbitMQ (RBAC enabled: ${{ matrix.rbac_enabled }})" @@ -229,6 +235,9 @@ jobs: uses: actions/checkout@v4 - name: Setup Python uses: ./.github/actions/setup-python + - name: Test Django migrations work from blank slate + working-directory: engine + run: python manage.py migrate - name: Unit Test Backend working-directory: engine run: pytest -x @@ -259,6 +268,9 @@ jobs: uses: actions/checkout@v4 - name: Setup Python uses: ./.github/actions/setup-python + - name: Test Django migrations work from blank slate + working-directory: engine + run: python manage.py migrate - name: Unit Test Backend working-directory: engine run: pytest -x diff --git a/engine/apps/alerts/migrations/0070_remove_resolutionnoteslackmessage__slack_channel_id_db.py b/engine/apps/alerts/migrations/0070_remove_resolutionnoteslackmessage__slack_channel_id_db.py index 70355474..f2eb3d5a 100644 --- a/engine/apps/alerts/migrations/0070_remove_resolutionnoteslackmessage__slack_channel_id_db.py +++ b/engine/apps/alerts/migrations/0070_remove_resolutionnoteslackmessage__slack_channel_id_db.py @@ -1,7 +1,7 @@ # Generated by Django 4.2.16 on 2024-11-20 20:23 -import common.migrations.remove_field -import django_migration_linter as linter +# import common.migrations.remove_field +# import django_migration_linter as linter from django.db import migrations @@ -12,10 +12,14 @@ class Migration(migrations.Migration): ] operations = [ - linter.IgnoreMigration(), - common.migrations.remove_field.RemoveFieldDB( - model_name='resolutionnoteslackmessage', - name='_slack_channel_id', - remove_state_migration=('alerts', '0068_remove_resolutionnoteslackmessage__slack_channel_id_state'), - ), + # NOTE: commented out due to some issues this was causing w/ SQLite: + # https://github.com/grafana/oncall/issues/5306 + # https://github.com/grafana/oncall/issues/5244#issuecomment-2503999986 + # + # linter.IgnoreMigration(), + # common.migrations.remove_field.RemoveFieldDB( + # model_name='resolutionnoteslackmessage', + # name='_slack_channel_id', + # remove_state_migration=('alerts', '0068_remove_resolutionnoteslackmessage__slack_channel_id_state'), + # ), ]