FG
๐Ÿ’ป Software๐Ÿ—„๏ธ Databases

[BUG]: enum as array, not possible?

Fresh3 days ago
Mar 14, 20260 views
Confidence Score60%
60%

Problem

What version of `drizzle-orm` are you using? 0.29.0 What version of `drizzle-kit` are you using? 0.20.4 Describe the Bug a simple example: [code block] when i try to migrate this, i got the error: [code block] is it not implemented or is this a bug...? thx. Expected behavior _No response_ Environment & setup _No response_

Error Output

error = Errors.postgres(parseError(x))

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix โ€“ Awaiting Verification

Fix Enum Array Migration Error in Drizzle-ORM

Medium Risk

The error occurs because the version of `drizzle-orm` (0.29.0) does not support using enums as arrays in migrations. This limitation leads to a parsing error when attempting to migrate a schema that includes enum arrays, resulting in the reported error.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Update Drizzle-ORM and Drizzle-Kit

    Check for the latest versions of `drizzle-orm` and `drizzle-kit` that may have added support for enum arrays. Updating to a newer version may resolve the issue.

    bash
    npm install drizzle-orm@latest drizzle-kit@latest
  2. 2

    Modify Enum Definition

    If updating does not resolve the issue, consider changing the enum definition to a string array instead of an enum array. This can be a temporary workaround until enum array support is officially implemented.

    typescript
    const myEnumArray = pgArray(pgEnum('my_enum_type'));
  3. 3

    Check Migration Scripts

    Review your migration scripts to ensure that the enum array is correctly defined. If necessary, create a new migration script that reflects the changes made in step 2.

    typescript
    await db.schema.createTable('my_table', (table) => {
      table.specificType('my_column', 'my_enum_type[]');
    });
  4. 4

    Run Migrations

    After making the necessary changes, run the migration command to apply the updates to the database schema.

    bash
    npx drizzle-kit migrate

Validation

To confirm the fix worked, check the database schema to ensure that the enum array is correctly migrated without errors. Additionally, run tests that utilize the enum array to ensure functionality is as expected.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

drizzleormtypescriptbugdrizzle/kit