-
-
Couldn't load subscription status.
- Fork 4.5k
feat(prevent): add table for prevent AI configs #102097
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
Conversation
|
This PR has a migration; here is the generated SQL for for --
-- 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"); |
| ), | ||
| ], | ||
| options={ | ||
| "db_table": "prevent_ai_configuration", |
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.
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?
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.
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" |
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.
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)
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.
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?
Add a configuration model to control prevent AI product features (code review, test analytics, bug prediction).
Add a configuration model to control prevent AI product features (code review, test analytics, bug prediction).