Default value for Array creates an incorrect SQL migration

I'm currently adding a new field roles to my PG table, users, such as:
export const users = pgTable(
  'users',
  {
    user_id: text('user_id').primaryKey(),
    balance: integer('balance').notNull().default(0),
    roles: text('roles').array().default(['user']),
  },
  (table) => {
    return {
      user_idIdx: uniqueIndex('user_id_idx').on(table.user_id),
    };
  },
);

The problem is that when I generate the SQL schema it returns this:
ALTER TABLE "users" ADD COLUMN "roles" text[] DEFAULT user;


which is wrong since it thinks it's referencing to a user table but not just a default string value called user
Was this page helpful?