© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago
bxr

Default value for Array creates an incorrect SQL migration

I'm currently adding a new field
roles
roles
to my PG table,
users
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),
    };
  },
);
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;
ALTER TABLE "users" ADD COLUMN "roles" text[] DEFAULT user;


which is wrong since it thinks it's referencing to a
user
user
table but not just a default string value called
user
user
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

define default value for array
Drizzle TeamDTDrizzle Team / help
3y ago
adding default to array of text creates invalid migrations
Drizzle TeamDTDrizzle Team / help
3y ago
sql placeholder with an array throws an error
Drizzle TeamDTDrizzle Team / help
2y ago
Define custom migration SQL for drizzle
Drizzle TeamDTDrizzle Team / help
2y ago