Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix Enum Array Column Types for PostgreSQL Migrations #3759

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

davidsonsns
Copy link

@davidsonsns davidsonsns commented Dec 13, 2024

Fix an issue specific to PostgreSQL migrations, where enum array column types are generated without the schema prefix. This omission leads to invalid SQL statements that cannot be executed properly.

Current Behavior:

Generated migrations for enum array columns omit the schema prefix. For example:

"completedOnboardingItems" "onboardingChecklistItem"[] DEFAULT '{}'

Expected Behavior (Post-Fix):

Enum array columns correctly include the schema prefix, ensuring valid SQL generation:

"completedOnboardingItems" "app"."onboardingChecklistItem"[] DEFAULT '{}'

Schema Structure:

Below is a simplified version of the schema used for generating the migrations:

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

const appSchema = pgSchema("app");

export const onboardingChecklistItem = appSchema.enum(
  "onboardingChecklistItem",
  [
    "A",
    "B",
    "C"
  ]
);

export const user = appSchema.table("user", {
  id: serial("id").primaryKey(),
  completedOnboardingItems: onboardingChecklistItem("completedOnboardingItems")
    .array()
    .default([]),
});

Related to: #3278

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant