Skip to content

Add way to specify database schema for extension-related helpers #3

@emmnull

Description

@emmnull

Some helpers are directly related to extensions installed by users. Such extensions are typically installed in their own schema. If users keep their database's or users' default search_path setting, this leads to having to prefix function calls or custom types with their host schema.

CREATE EXTENSION cube WITH SCHEMA extensions

-- Cube type or functions then generally need to be invoked using a pattern like "extensions"."cube"...

To circumvent this, we rely on forcing users to include their extensions schema to the search path. (see https://github.com/iolyd/drizzle-orm-helpers/blob/main/sql/search-path.sql). But we ideally want to let consumers decide how they manage their database settings, and we should thus provide a consistent way to include schemas with custom types and functions.

We could provide some type of instanciating functions à la

import {cube as _cube} from 'drizzle-orm-helpers/pg';

const extensionsSchema = pgSchema('extensions');
export const cube = createWithSchema(_cube, extensionsSchema)

But a good design should ideally not require devs to redeclare all functions within their code, maybe we could figure out some kind of global project config?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions