adding default to array of text creates invalid migrations

values: text('values').array().notNull().default(['a', 'b']) generates: ALTER TABLE "test" ALTER COLUMN "values" SET DEFAULT a,b; Should be: ALTER TABLE "test" ALTER COLUMN "values" SET DEFAULT ARRAY['a', 'b'];
"drizzle-orm": "^0.28.3",
"drizzle-kit": "^0.19.13",
"pg": "^8.11.3"
"drizzle-orm": "^0.28.3",
"drizzle-kit": "^0.19.13",
"pg": "^8.11.3"
5 Replies
Angelelz
Angelelz16mo ago
Try like this:
values: text('values').array().notNull().default(sql`ARRAY['a', 'b']`)
values: text('values').array().notNull().default(sql`ARRAY['a', 'b']`)
I'm not very familiar with pg but that should work.
ak4zh
ak4zhOP16mo ago
Thanks, I did not get a chance to try this method as I already edited the SQL manually and migrated. Just reporting so this can be improved.
Angelelz
Angelelz16mo ago
Can you create an issue in the repo?
ak4zh
ak4zhOP16mo ago
Sure
ak4zh
ak4zhOP16mo ago
GitHub
adding default to array of text creates invalid migrations · Issue ...
values: text('values').array().notNull().default(['a', 'b']) generates: ALTER TABLE "test" ALTER COLUMN "values" SET DEFAULT a,b; Should be: ALTER TABLE ...
Want results from more Discord servers?
Add your server