Skip to content

Conversation

@srest2021
Copy link
Member

@srest2021 srest2021 commented Jan 26, 2026

fixes CW-683

Add date_updated and date_added columns to RepositorySettings for easier debugging.

Also, remove test_1016_remove_on_command_phrase_trigger.py as it was failing due to using a direct import of RepositorySettings, and we don't need this test anymore.

@linear
Copy link

linear bot commented Jan 26, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 26, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2026

This PR has a migration; here is the generated SQL for src/sentry/migrations/1021_add_date_added_date_updated_to_repositorysettings.py

for 1021_add_date_added_date_updated_to_repositorysettings in sentry

--
-- Add field date_added to repositorysettings
--
ALTER TABLE "sentry_repositorysettings" ADD COLUMN "date_added" timestamp with time zone DEFAULT (STATEMENT_TIMESTAMP()) NOT NULL;
--
-- Add field date_updated to repositorysettings
--
ALTER TABLE "sentry_repositorysettings" ADD COLUMN "date_updated" timestamp with time zone DEFAULT (STATEMENT_TIMESTAMP()) NOT NULL;

@srest2021 srest2021 marked this pull request as ready for review January 26, 2026 19:06
@srest2021 srest2021 requested review from a team as code owners January 26, 2026 19:06
@srest2021 srest2021 requested a review from a team January 26, 2026 19:06
@srest2021 srest2021 marked this pull request as draft January 27, 2026 21:31
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

default=list,
)
date_added = models.DateTimeField(db_default=Now())
date_updated = models.DateTimeField(db_default=Now(), auto_now=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

date_updated not updated during bulk upsert operations

Medium Severity

The new date_updated field uses auto_now=True, but auto_now only triggers on .save() calls. The existing OrganizationRepositorySettingsEndpoint uses bulk_create with update_conflicts=True and doesn't include date_updated in update_fields. For existing rows updated via this bulk endpoint, date_updated will remain unchanged, defeating the purpose of tracking update times "for easier debugging." The db_default=Now() only applies to INSERT operations, not UPDATE operations in the upsert.

Fix in Cursor Fix in Web

@srest2021 srest2021 merged commit 455b02b into master Jan 27, 2026
66 of 67 checks passed
@srest2021 srest2021 deleted the srest2021/CW-683 branch January 27, 2026 22:04
srest2021 added a commit that referenced this pull request Jan 28, 2026
followup to #106977

Add `"date_updated"` to `update_fields` when bulk creating repo
settings. Otherwise the value will not update.
priscilawebdev pushed a commit that referenced this pull request Jan 28, 2026
…rySettings (#106977)

fixes CW-683

Add `date_updated` and `date_added` columns to `RepositorySettings` for
easier debugging.

Also, remove `test_1016_remove_on_command_phrase_trigger.py` as it was
failing due to using a direct import of `RepositorySettings`, and we
don't need this test anymore.
priscilawebdev pushed a commit that referenced this pull request Jan 28, 2026
followup to #106977

Add `"date_updated"` to `update_fields` when bulk creating repo
settings. Otherwise the value will not update.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants