Skip to content

Drop the unused get_bookmark_count and admin_get_user_notification_subs functions #605

Closed

Description

@HMarzban

Goal

Drop two Supabase functions that nothing calls: get_bookmark_count and admin_get_user_notification_subs. Maintainer ruling on #327, 2026-10-24.

Facts

Checked at 25992f89e.

  • git grep finds no caller of either function in apps/, extensions/ or packages/, outside the generated apps/webapp/src/types/supabase.ts.
  • Close the remaining 47 linter warnings on functions #318 made both service_role only (packages/supabase/migrations/20261014121100_close_self_gated_and_trigger_function_grants.sql:17). Close the remaining 47 linter warnings on functions #318 left the drop to its own issue.
  • get_bookmark_count(character varying, boolean) is defined in packages/supabase/scripts/07-bookmark-functions.sql:238-279. Its search path is at :343, and its grants at :358-359.
  • admin_get_user_notification_subs() is defined in packages/supabase/scripts/07-4-push-notifications-pgmq.sql:489-513. Its search path is at :754.
  • Its body gates on is_admin(auth.uid()), so under service_role it returns zero rows. A code comment says not to call it (apps/hocuspocus.server/src/api/controllers/admin-stats.controller.ts:428).

What to do

  1. Remove both functions from the two scripts: the definition, the comment, the search-path line and the grant lines.
  2. Add a paired migration in packages/supabase/migrations/, with a timestamp later than the newest file there (20261023120000 at 25992f89e). It runs drop function if exists for each signature above.
  3. Run bun run --filter @docs.plus/supabase_back seed, which regenerates packages/supabase/seed.sql from the scripts. Then run bun run --filter @docs.plus/supabase_back types. Commit both regenerated files, seed.sql and apps/webapp/src/types/supabase.ts, in the same change. Never hand-edit either one. Without the seed step, the git grep below still finds both functions in seed.sql.
  4. Update the comment at admin-stats.controller.ts:428, so it no longer names a dropped function.
  5. Apply the migration to the local database without a reset, as packages/supabase/CLAUDE.md says. A reset wipes the local volume that other worktrees share. Then run packages/supabase/scripts/check-grants.sql. It returns 0 rows.

Acceptance criteria

  • git grep -nE 'get_bookmark_count|admin_get_user_notification_subs' -- . ':!packages/supabase/migrations' finds nothing.
  • The migration applies locally, and check-grants.sql returns 0 rows.
  • The regenerated supabase.ts is in the same commit.
  • After the production push, the maintainer runs check-grants.sql on production, and it returns 0 rows.

Effort and order

Effort S. No blocker. It lands with the other Supabase work in this milestone.


Parent: #327. Ruled there on 2026-10-24.

Activity

  1. added this to the v2.3.0 milestone on Oct 24, 2026
  2. added
    Security
    on Oct 24, 2026
  3. HMarzban commented on Oct 25, 2026

    @HMarzban
    CollaboratorAuthor

    Built and committed on local main. Awaits the maintainer's final push.

    Remaining gates: the Supabase production push, then check-grants.sql on production (0 rows).

  4. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Status, 2026-11-03. The drop is pushed in eb4e7fb53. Its CHANGELOG entries are in 5cfcc023d. These steps are left:

    • maintainer: push migration 20261025120000 to prod.
    • maintainer: run check-grants.sql on prod.

    The guard will also show default_acl_open rows for pgmq and storage. Those belong to #570 and stay until its held migration 20261026120000 lands.

  5. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Live in production. Migration 20261025120000 (eb4e7fb53) is applied, so get_bookmark_count and admin_get_user_notification_subs are dropped. On 2026-11-03 the maintainer pushed every pending Supabase migration to production with supabase db push, and packages/supabase/scripts/check-grants.sql then returned 0 rows.

  6. modified the milestones: v2.3.0, v2.3.6 on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DevOpsSecurity

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions