Skip to content

Conversation

@JerrySentry
Copy link
Contributor

Add a configuration model to control prevent AI product features (code review, test analytics, bug prediction).

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 24, 2025
@github-actions
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/prevent/migrations/0001_create_prevent_ai_configuration.py

for 0001_create_prevent_ai_configuration in prevent

--
-- Create model PreventAIConfiguration
--
CREATE TABLE "prevent_ai_configuration" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "integration_id" bigint NULL, "data" jsonb NOT NULL, "organization_id" bigint NOT NULL);
CREATE UNIQUE INDEX CONCURRENTLY "prevent_ai_configuration_organization_id_integrat_2daf0f56_uniq" ON "prevent_ai_configuration" ("organization_id", "integration_id");
ALTER TABLE "prevent_ai_configuration" ADD CONSTRAINT "prevent_ai_configuration_organization_id_integrat_2daf0f56_uniq" UNIQUE USING INDEX "prevent_ai_configuration_organization_id_integrat_2daf0f56_uniq";
ALTER TABLE "prevent_ai_configuration" ADD CONSTRAINT "prevent_ai_configura_organization_id_69ec9fa2_fk_sentry_or" FOREIGN KEY ("organization_id") REFERENCES "sentry_organization" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "prevent_ai_configuration" VALIDATE CONSTRAINT "prevent_ai_configura_organization_id_69ec9fa2_fk_sentry_or";
CREATE INDEX CONCURRENTLY "prevent_ai_configuration_integration_id_a6f19c01" ON "prevent_ai_configuration" ("integration_id");
CREATE INDEX CONCURRENTLY "prevent_ai_configuration_organization_id_69ec9fa2" ON "prevent_ai_configuration" ("organization_id");

@JerrySentry JerrySentry marked this pull request as ready for review October 24, 2025 19:43
@JerrySentry JerrySentry requested a review from a team as a code owner October 24, 2025 19:43
),
],
options={
"db_table": "prevent_ai_configuration",
Copy link
Member

Choose a reason for hiding this comment

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

I looked over other migrations in the repo and it seems like most follow the convention of sentry_{thingwithnospaces}. Should we update this to match, or is there something that automagically formats it for us?

Copy link
Contributor Author

@JerrySentry JerrySentry Oct 27, 2025

Choose a reason for hiding this comment

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

its called prevent_ai_configuration now as per this suggestion, not sure about the "thingwithnospaces", some tables has multiple underscores but most tables has 1..
#101831 (comment)

(
"integration_id",
sentry.db.models.fields.hybrid_cloud_foreign_key.HybridCloudForeignKey(
"sentry.Integration", db_index=True, null=True, on_delete="CASCADE"
Copy link
Member

Choose a reason for hiding this comment

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

Looks like if integration is nullable and part of the unique_together, we'll have to make sure on application side not to write multiple rows with organization_id=abc and integration_id=NULL (probably can just disallow writing if integration is null)

Copy link
Member

Choose a reason for hiding this comment

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

The unique index actually won't enforce (organization_id=x, integration_id=null) as unique, because in postgres every null value is considered unique. But I'm confused as to what the use of these rows is when there's no integration?

@JerrySentry JerrySentry merged commit 97a4988 into master Oct 27, 2025
71 checks passed
@JerrySentry JerrySentry deleted the jerry/extend-config-perm-migration branch October 27, 2025 13:52
priscilawebdev pushed a commit that referenced this pull request Oct 28, 2025
Add a configuration model to control prevent AI product features (code
review, test analytics, bug prediction).
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.

3 participants