Skip to content

Move extensions out of public schema #173

Closed

Description

@thinkclay

Summary

Six extensions are installed in the public schema. Extensions in public are visible and can clutter the public namespace; moving them to a dedicated schema (e.g. extensions) is recommended.

Affected objects

  • citext
  • postgis
  • pg_net
  • uuid-ossp
  • pgcrypto
  • pg_trgm

Remediation

  1. Create a schema for extensions if needed: CREATE SCHEMA IF NOT EXISTS extensions;
  2. Move each extension using ALTER EXTENSION ... SET SCHEMA extensions; where supported, or drop and re-create in the new schema. Check Postgres extension docs and Supabase migration practices.
  3. See Extension in Public.

References

Activity

  1. thinkclay commented on Mar 10, 2026

    @thinkclay
    ContributorAuthor

    Done.

    • Added migration 405_move_extensions_to_extensions_schema.sql:
      • Creates extensions schema if missing.
      • Moves extensions from public to extensions when the migration runs as the extension owner (citext, postgis, uuid-ossp, pgcrypto, pg_trgm). pg_net is not moved (it does not support SET SCHEMA).
      • Sets search_path for roles anon, authenticated, service_role, postgres to public, extensions, pg_catalog so unqualified references keep working after moves.
    • Applied locally; extensions remained in public here because migrations did not run as extension owner. On Supabase Cloud, running as project owner (or running the ALTERs in SQL as owner) will move them.
    • Closing as completed.
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions