define default value for array
I work with a PostgreSQL database.
Here is my Schema:
export const user = pgTable(
'auth_user',
{
id: uuid('id').primaryKey(),
email: text('email').notNull(),
roles: text('roles').array().default(['registered'])
},
(table) => {
return {
email: uniqueIndex('auth_user_email').on(table.email)
};
}
);
I have a problem with this line:
roles: text('roles').array().default(['registered']) How do I define the default value to be ['registered'] ?
roles: text('roles').array().default(['registered']) How do I define the default value to be ['registered'] ?
6 Replies
I would try to surround the array with quotes (a string), because it is a text type in the end.
“['registered']”
What the problem is exactly? It should be able to accept the regular array values as defaults.
bumping this thread, having the same issue
here's a little bit more details regarding it:
so i have a table where i want to set the default value as an empty array but drizzle generates invalid sql syntax:
On me
Will fix it
If I won’t till the end of this week please ping me here
alright
@Andrew Sherman forgot to ping earlier
was this ever fixed? I'm currently seeing the same issue on the latest release @Andrew Sherman