sentry icon indicating copy to clipboard operation
sentry copied to clipboard

feat(discover): Add is_default as field to saved query

Open narsaynorath opened this issue 3 years ago • 1 comments

We'd like to allow users to set default queries as their landing page. This field will be used to identify a saved query as a user's default query, i.e. there should be at most 1 row where created_by=user and is_default=True

narsaynorath avatar Sep 20 '22 14:09 narsaynorath

This PR has a migration; here is the generated SQL for src/sentry/migrations/0317_add_is_default_to_saved_query_model.py ()

--
-- Add field is_default to discoversavedquery
--
ALTER TABLE "sentry_discoversavedquery" ADD COLUMN "is_default" boolean NULL;
--
-- Create constraint unique_user_default_query on model discoversavedquery
--
CREATE UNIQUE INDEX CONCURRENTLY "unique_user_default_query" ON "sentry_discoversavedquery" ("organization_id", "is_default") WHERE "is_default" = true;

github-actions[bot] avatar Sep 20 '22 14:09 github-actions[bot]

Setting to draft to work out uniqueness validation.

narsaynorath avatar Sep 20 '22 20:09 narsaynorath

This PR has a migration; here is the generated SQL for src/sentry/migrations/0318_add_is_default_to_saved_query_model.py ()

--
-- Add field is_default to discoversavedquery
--
ALTER TABLE "sentry_discoversavedquery" ADD COLUMN "is_default" boolean NULL;
--
-- Create constraint unique_user_default_query on model discoversavedquery
--
CREATE UNIQUE INDEX CONCURRENTLY "unique_user_default_query" ON "sentry_discoversavedquery" ("organization_id", "is_default") WHERE "is_default" = true;

github-actions[bot] avatar Sep 23 '22 12:09 github-actions[bot]

This PR has a migration; here is the generated SQL for src/sentry/migrations/0318_add_is_homepage_to_saved_query_model.py ()

--
-- Add field is_homepage to discoversavedquery
--
ALTER TABLE "sentry_discoversavedquery" ADD COLUMN "is_homepage" boolean NULL;
--
-- Create constraint unique_user_homepage_query on model discoversavedquery
--
CREATE UNIQUE INDEX CONCURRENTLY "unique_user_homepage_query" ON "sentry_discoversavedquery" ("organization_id", "created_by_id", "is_homepage") WHERE "is_homepage" = true;

github-actions[bot] avatar Sep 26 '22 13:09 github-actions[bot]