Skip to content

chore(shared): Generate missing migrations #277

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

Merged
merged 1 commit into from
Jul 7, 2025

Conversation

ElioDiNino
Copy link
Member

@ElioDiNino ElioDiNino commented Jul 3, 2025

Resolves the 'model_name' have changes that are not yet reflected in a migration, and so won't be applied. warning that we currently see for shared models. This has been tested in staging and had no issues.

Note: There is one remaining migration that is more complicated for the legacy_migrations model that will be a separate PR. Per #278, the model will be removed instead (#281)

@ElioDiNino ElioDiNino self-assigned this Jul 3, 2025
@ElioDiNino ElioDiNino requested a review from a team as a code owner July 3, 2025 19:20
@ElioDiNino ElioDiNino requested a review from ajay-sentry July 3, 2025 19:20
Copy link

codecov bot commented Jul 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.34%. Comparing base (8030fd0) to head (69c8a01).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #277   +/-   ##
=======================================
  Coverage   94.33%   94.34%           
=======================================
  Files        1222     1226    +4     
  Lines       45309    45325   +16     
  Branches     1441     1441           
=======================================
+ Hits        42744    42760   +16     
  Misses       2264     2264           
  Partials      301      301           
Flag Coverage Δ
apiunit 96.49% <ø> (ø)
sharedintegration 40.16% <0.00%> (-0.06%) ⬇️
sharedunit 88.63% <100.00%> (+0.01%) ⬆️
workerintegration 61.60% <ø> (ø)
workerunit 90.61% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@codecov-notifications
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link

codspeed-hq bot commented Jul 3, 2025

CodSpeed Performance Report

Merging #277 will not alter performance

Comparing ElioDiNino/missing-migrations (69c8a01) with main (a9d4685)

Summary

✅ 9 untouched benchmarks

@michelletran-codecov
Copy link
Collaborator

Can you run a sqlmigrate command to get the output of the query and add the raw query as a comment on the migration files? More info here.

Copy link
Collaborator

@michelletran-codecov michelletran-codecov left a comment

Choose a reason for hiding this comment

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

I've verified that the Postgres alter tables will be a no-op in production. I would also want to get a review from @joseph-sentry to ensure that the TA migration on Timescale will be no-op in production (I don't have prod access to the timescale DBs to verify).

@joseph-sentry
Copy link
Contributor

hmmm I messed this up when i created migrations that ran index migrations using SQL, I don't think there's any way to make Django aware of those index operations.

I think the way to fix this is to: using only Risky migration statements, undo my index creation and deletion changes for the TA timeseries table, then add the indexes using django so it's aware

@ElioDiNino ElioDiNino force-pushed the ElioDiNino/missing-migrations branch from 0ae0c91 to 42da75d Compare July 4, 2025 19:46
Comment on lines +11 to +39
operations = [
# Bringing the state in sync with the changes made manually with migration 0011
migrations.SeparateDatabaseAndState(
database_operations=[
migrations.RunSQL(
"""
ALTER INDEX IF EXISTS ta_ts_upload_id_outcome_test_id_idx RENAME TO ta_ts_upload_outcome_test_idx;
"""
),
],
state_operations=[
migrations.RemoveIndex(
model_name="testrun",
name="ta_ts__branch_i",
),
migrations.RemoveIndex(
model_name="testrun",
name="ta_ts__test_i",
),
migrations.AddIndex(
model_name="testrun",
index=models.Index(
fields=["upload_id", "outcome", "test_id"],
name="ta_ts_upload_outcome_test_idx",
),
),
],
),
]
Copy link
Member Author

Choose a reason for hiding this comment

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

python manage.py sqlmigrate ta_timeseries 0016 --database ta_timeseries

BEGIN;
--
-- Custom state/database change combination
--

                    ALTER INDEX IF EXISTS ta_ts_upload_id_outcome_test_id_idx RENAME TO ta_ts_upload_outcome_test_idx;

COMMIT;

@ElioDiNino ElioDiNino force-pushed the ElioDiNino/missing-migrations branch from 42da75d to 69c8a01 Compare July 4, 2025 19:51
Copy link
Collaborator

@michelletran-codecov michelletran-codecov left a comment

Choose a reason for hiding this comment

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

LGTM. Just make sure you test this in staging as well. 👍

ElioDiNino added a commit that referenced this pull request Jul 4, 2025
Old TA timeseries models that are not in use. Builds on #277
@ElioDiNino ElioDiNino added this pull request to the merge queue Jul 7, 2025
Merged via the queue into main with commit b49e108 Jul 7, 2025
102 checks passed
@ElioDiNino ElioDiNino deleted the ElioDiNino/missing-migrations branch July 7, 2025 14:18
ElioDiNino added a commit that referenced this pull request Jul 7, 2025
Old TA timeseries models that are not in use. Builds on #277
github-merge-queue bot pushed a commit that referenced this pull request Jul 7, 2025
Old TA timeseries models that are not in use. Builds on #277
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants