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

db: updates for image expiry notification (PROJQUAY-7075) #2894

Merged
merged 5 commits into from
Jun 25, 2024

Conversation

Sunandadadi
Copy link
Contributor

@Sunandadadi Sunandadadi commented May 20, 2024

database migrations for image expiry notification (PROJQUAY-7075)

seeding db changes for cypress

@Sunandadadi Sunandadadi marked this pull request as ready for review May 20, 2024 15:07
@Sunandadadi Sunandadadi changed the title database migrations for image expiry notification (PROJQUAY-7075) db: updates for image expiry notification (PROJQUAY-7075) May 20, 2024
@Sunandadadi Sunandadadi force-pushed the 05-20-db-updates branch 2 times, most recently from 7e94780 to 6cd7f1a Compare May 21, 2024 19:20
@Sunandadadi Sunandadadi force-pushed the 05-20-db-updates branch 3 times, most recently from ed63988 to 2582626 Compare May 27, 2024 22:33
Copy link

codecov bot commented May 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.35%. Comparing base (e4f0558) to head (80dc8c9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2894   +/-   ##
=======================================
  Coverage   70.34%   70.35%           
=======================================
  Files         439      439           
  Lines       41269    41274    +5     
  Branches     5410     5410           
=======================================
+ Hits        29032    29037    +5     
  Misses      10531    10531           
  Partials     1706     1706           
Flag Coverage Δ
unit 70.35% <100.00%> (+<0.01%) ⬆️

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.

data/database.py Outdated
@@ -1426,6 +1428,7 @@ class RepositoryNotification(BaseModel):
config_json = TextField()
event_config_json = TextField(default="{}")
number_of_failures = IntegerField(default=0)
last_ran_ms = BigIntegerField(null=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll want an index on this field if you're going to be looking up by last_ran_ms

class TagNotificationSuccess(BaseModel):
notification = ForeignKeyField(RepositoryNotification, index=True, null=False)
tag = ForeignKeyField(Tag, index=True, null=False)
method = ForeignKeyField(ExternalNotificationMethod, null=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll have to test when ever the foreign notification or tag rows are deleted that this row get's deleted as well without causing any issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I added both in the second PR, tags clean up and notification clean up

repositorynotification_indexes = inspector.get_indexes("repositorynotification")
if not "last_ran_repositorynotification" in [i["name"] for i in repositorynotification_indexes]:
op.create_index(
"last_ran_repositorynotification",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the conventional index name is <table_name>_<column_name>


def downgrade(op, tables, tester):
op.drop_column("repositorynotification", "last_ran_ms")
op.drop_index("last_ran_repositorynotification", table_name="repositorynotification")
Copy link
Contributor

Choose a reason for hiding this comment

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

I would imagine that the index needs to be dropped before the column, could be wrong though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. I reversed the operations

bcaton85
bcaton85 previously approved these changes Jun 25, 2024
Copy link
Contributor

@bcaton85 bcaton85 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@bcaton85 bcaton85 left a comment

Choose a reason for hiding this comment

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

LGTM

@Sunandadadi Sunandadadi merged commit 6c371c5 into master Jun 25, 2024
29 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants