-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
feat(crons): Remove slug null=True #45276
feat(crons): Remove slug null=True #45276
Conversation
This PR has a migration; here is the generated SQL for --
-- Alter field slug on monitor
--
ALTER TABLE "sentry_monitor" ADD CONSTRAINT "sentry_monitor_slug_ad0f637f_notnull" CHECK ("slug" IS NOT NULL) NOT VALID;
ALTER TABLE "sentry_monitor" VALIDATE CONSTRAINT "sentry_monitor_slug_ad0f637f_notnull"; |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #45276 +/- ##
==========================================
- Coverage 80.23% 80.23% -0.01%
==========================================
Files 4724 4724
Lines 198821 198821
Branches 12020 12020
==========================================
- Hits 159525 159520 -5
- Misses 39034 39039 +5
Partials 262 262
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how often is this table written / read to? from what i'm understanding, the first statement will still lock, albeit not for long. https://medium.com/doctolib/adding-a-not-null-constraint-on-pg-faster-with-minimal-locking-38b2c00c4d1c
1cf382e
to
40265a1
Compare
reading https://develop.sentry.dev/database-migrations/#adding-not-null-to-columns, seems safe -- LGTM once tests pass |
@@ -155,7 +155,7 @@ def save(self, *args, **kwargs): | |||
# NOTE: We ONLY set a slug while saving when creating a new monitor and | |||
# the slug has not been set. Otherwise existing monitors without slugs | |||
# would have their guids changed | |||
if self._state.adding is True and self.slug is None: | |||
if self._state.adding is True and self.slug == "": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just say and not self.slug
. empty strings eval to False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 will follow up
After the completion of #45270 all slugs now have values
This is safe as we will be adding the constraint as
NOT VALID
and runningVALIDATE
immediately after (which does not lock)