diff --git a/contrib/claude/coredata.md b/contrib/claude/coredata.md index 616945a15..a7235e992 100644 --- a/contrib/claude/coredata.md +++ b/contrib/claude/coredata.md @@ -174,7 +174,9 @@ Each entity gets a unique `uint16` constant in `entity_type_reg.go`. **Never reu ## Migrations -Files in `pkg/coredata/migrations/` use timestamp naming: `YYYYMMDDTHHMMSSZ.sql` (UTC). One logical change per file. +- Files in `pkg/coredata/migrations/` . +- Run `date -u +"%Y%m%dT%H%M%SZ.sql"` to get the name of the new migration file. +- One logical change per file. **No indexes by default.** Only add indexes when justified by observed query latency in production environments. Do not speculatively create indexes on new tables or columns. This rule does not apply to indexes that enforce constraints, such as unique indexes. diff --git a/pkg/cookiebanner/service.go b/pkg/cookiebanner/service.go index e9354f27e..a7a046918 100644 --- a/pkg/cookiebanner/service.go +++ b/pkg/cookiebanner/service.go @@ -376,32 +376,6 @@ func (s *Service) GetActiveCookieBanner( return &banner, nil } -func (s *Service) GetActiveCookieBannerByOrigin( - ctx context.Context, - origin string, -) (*coredata.CookieBanner, error) { - var banner coredata.CookieBanner - - err := s.pg.WithConn( - ctx, - func(ctx context.Context, conn pg.Querier) error { - if err := banner.LoadActiveByOrigin(ctx, conn, CanonicalizeOrigin(origin)); err != nil { - if errors.Is(err, coredata.ErrResourceNotFound) { - return ErrBannerNotFound - } - return fmt.Errorf("cannot load cookie banner: %w", err) - } - - return nil - }, - ) - if err != nil { - return nil, err - } - - return &banner, nil -} - func (s *Service) ListCookieBannersForOrganization( ctx context.Context, scope coredata.Scoper, diff --git a/pkg/coredata/migrations/20260413T114822Z.sql b/pkg/coredata/migrations/20260413T130000Z.sql similarity index 97% rename from pkg/coredata/migrations/20260413T114822Z.sql rename to pkg/coredata/migrations/20260413T130000Z.sql index 785ca9d29..b3b2c8a0f 100644 --- a/pkg/coredata/migrations/20260413T114822Z.sql +++ b/pkg/coredata/migrations/20260413T130000Z.sql @@ -13,4 +13,4 @@ -- PERFORMANCE OF THIS SOFTWARE. CREATE UNIQUE INDEX idx_cookie_banners_unique_active_origin - ON cookie_banners (tenant_id, origin) WHERE state = 'ACTIVE'; + ON cookie_banners (tenant_id, origin) WHERE state = 'ACTIVE'::cookie_banner_state;