drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[FEATURE]: Add schema enums to pg

Open maaasyn opened this issue 2 years ago • 0 comments

Describe want to want

Hey. Currently I'm trying to make my enum available only to the certain schema.

import { pgSchema, pgEnum } from "drizzle-orm/pg-core";

export const publicSchema = pgSchema("public");
export const differentSchema = pgSchema("different_schema");

// ✅ As expected I'm able to create table on different schema
export const publicTable = differentSchema.table("public_table", {
  id: varchar("id", { length: 36 }).primaryKey().notNull(),
});

// ✅ This works, it's available to public
export const abcEnum = pgEnum("ENUM", ["A", "B", "C"]);

// ❌ This syntax doesn't exist, but will fix my issue.
export const zyxEnum = differentSchema.enum("DIFFERENT_ENUM", ["Z", "Y", "X"]);

I will expect it to create:

CREATE TYPE "different_schema"."DIFFERENT_ENUM" AS ENUM ('Z', 'Y', 'X');

maaasyn avatar May 31 '23 09:05 maaasyn