Enum's created in schema are unqualified when used in tables

Seeing an issue where when I'm trying to define enums and tables within a postgres schema, the enums are created within the schema, however the table columns reference the schema unqualified. Is there something I'm missing here?
// schema defs

export enum IssueStatus {
TODO = "todo",
READY = "ready",
DEV = "dev"
}

export const foo = pgSchema("foo");
export const issueStatusEnum = foo.enum("issue_status", IssueStatus);

export const issues = foo.table("issues", {
id: entityId("issues"),
title: text().notNull(),
description: text().notNull(),
status: issueStatusEnum().notNull().default(IssueStatus.TODO),
...timestamps,
});
// schema defs

export enum IssueStatus {
TODO = "todo",
READY = "ready",
DEV = "dev"
}

export const foo = pgSchema("foo");
export const issueStatusEnum = foo.enum("issue_status", IssueStatus);

export const issues = foo.table("issues", {
id: entityId("issues"),
title: text().notNull(),
description: text().notNull(),
status: issueStatusEnum().notNull().default(IssueStatus.TODO),
...timestamps,
});
// Generated migration

CREATE SCHEMA "foo";
CREATE TYPE "foo"."issue_status" AS ENUM('todo', 'ready', 'dev');--> statement-breakpoint
CREATE TABLE "foo"."issues" (
"id" text PRIMARY KEY NOT NULL,
"title" text NOT NULL,
"description" text NOT NULL,
// figured this would be "foo"."issue_status" for the type
"status" "issue_status" DEFAULT 'inbox' NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
"deleted_at" timestamp with time zone
);
// Generated migration

CREATE SCHEMA "foo";
CREATE TYPE "foo"."issue_status" AS ENUM('todo', 'ready', 'dev');--> statement-breakpoint
CREATE TABLE "foo"."issues" (
"id" text PRIMARY KEY NOT NULL,
"title" text NOT NULL,
"description" text NOT NULL,
// figured this would be "foo"."issue_status" for the type
"status" "issue_status" DEFAULT 'inbox' NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
"deleted_at" timestamp with time zone
);
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?