[BUG]: enum as array, not possible?
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
Fix Enum Array Migration Error in Drizzle-ORM
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
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.
bashnpm install drizzle-orm@latest drizzle-kit@latest - 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.
typescriptconst myEnumArray = pgArray(pgEnum('my_enum_type')); - 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.
typescriptawait db.schema.createTable('my_table', (table) => { table.specificType('my_column', 'my_enum_type[]'); }); - 4
Run Migrations
After making the necessary changes, run the migration command to apply the updates to the database schema.
bashnpx 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
Alex Chen
2450 rep