Skip to content

Conversation

jladd-geant
Copy link
Contributor

@jladd-geant jladd-geant commented Jun 23, 2025

Scope and purpose

Since the incident migrations were squashed in 7cbcc9f it seems like makemigrations still detects some small changes in some BigAutoField's without making any changes to the database model. The reason for these changes seem to be that in the squashed migration these fields are marked as auto_created even though they are explicitly defined in the model. Removing auto_created and vebose_name from these fields makes makemigrations no longer detect changes. This also aligns with how these fields were defined in the latest migration before squashing where these fields were converted to BigAutoField (10bc007#diff-0f8dba41fb179ac51f795d2f691e8ec017ba2eb706190a6bc3ad5b7b8904f34f)

Generated migration with no model changes
    class Migration(migrations.Migration):
    
        dependencies = [
            ("argus_incident", "0001_squashed_incident_20250514"),
        ]
    
        operations = [
            migrations.AlterField(
                model_name="event",
                name="id",
                field=models.BigAutoField(primary_key=True, serialize=False),
            ),
            migrations.AlterField(
                model_name="incident",
                name="id",
                field=models.BigAutoField(primary_key=True, serialize=False),
            ),
            migrations.AlterField(
                model_name="incidenttagrelation",
                name="id",
                field=models.BigAutoField(primary_key=True, serialize=False),
            ),
            migrations.AlterField(
                model_name="tag",
                name="id",
                field=models.BigAutoField(primary_key=True, serialize=False),
            ),
        ]

Related to discussion in #1504

This pull request

  • changes the database

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to Argus can be found in the
Development docs.

  • Added a changelog fragment for towncrier
  • Linted/formatted the code with ruff and djLint, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See our how-to
  • If this results in changes to the database model: Updated the ER diagram
    There are no changes to the ER diagram

@jladd-geant jladd-geant force-pushed the squash-migration-fix branch from 324d350 to 925eeb7 Compare June 23, 2025 14:06
@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.46%. Comparing base (6b66a77) to head (a73ce49).
⚠️ Report is 42 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1506   +/-   ##
=======================================
  Coverage   79.46%   79.46%           
=======================================
  Files         121      121           
  Lines        5409     5409           
=======================================
  Hits         4298     4298           
  Misses       1111     1111           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jladd-geant jladd-geant marked this pull request as ready for review June 23, 2025 14:15
@johannaengland johannaengland added the data migration Batch change to data in the database label Jun 24, 2025
Copy link
Contributor

@hmpf hmpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hmpf hmpf self-requested a review June 24, 2025 09:42
Copy link
Contributor

@hmpf hmpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a test-project, verbose_name='ID' is a side-effect of autocreated=True.

I think the smart thing to do is to manually add verbose_name=ID to the manually set primary key fields. I doubt anything is using this (besides admin) but it is nice to be consistent.

@hmpf hmpf mentioned this pull request Jun 24, 2025
6 tasks
@jladd-geant
Copy link
Contributor Author

I made a test-project, verbose_name='ID' is a side-effect of autocreated=True.

I think the smart thing to do is to manually add verbose_name=ID to the manually set primary key fields. I doubt anything is using this (besides admin) but it is nice to be consistent.

Yeah I didn't test this but thought this was the case since that was generated in the initial migration and then seemed to be undone when they were converted to bigautofield and no longer autocreated. I wasn't really sure what its for but it was also triggering changes and seemed to result from auto creation so removed it. Adding verbose_name to the model makes sense will do that.

Copy link

@jladd-geant jladd-geant requested a review from hmpf June 24, 2025 10:36
@hmpf hmpf changed the base branch from master to stable/2.0.x June 25, 2025 07:37
@hmpf hmpf changed the base branch from stable/2.0.x to master June 25, 2025 07:37
@hmpf
Copy link
Contributor

hmpf commented Jun 25, 2025

Merged manually.

@hmpf hmpf closed this Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data migration Batch change to data in the database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants