© 2026 Hedgehog Software, LLC

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

Custom column type with default not working?

I tried to add a new column with a custom type and a default value.
but for some reason when I tried to
db push
db push
, it warned me that it didn't have a default value and that it would truncate the tables.
Am I doing something wrong?
const unsignedBigInt = customType<{
  data: number;
  // I also tried this ↓ https://orm.drizzle.team/docs/custom-types#examples
  // notNull: true;
  // default: true;
}>({
  dataType() {
    return "bigint UNSIGNED";
  },
});

export const myTable = mysqlTable("MyTable", {
  id: varchar("id", { length: 191 }).primaryKey().notNull(),
  //...
  // ↓ this was added ↓
  usage: unsignedBigInt("usage").default(0).notNull(),
});
const unsignedBigInt = customType<{
  data: number;
  // I also tried this ↓ https://orm.drizzle.team/docs/custom-types#examples
  // notNull: true;
  // default: true;
}>({
  dataType() {
    return "bigint UNSIGNED";
  },
});

export const myTable = mysqlTable("MyTable", {
  id: varchar("id", { length: 191 }).primaryKey().notNull(),
  //...
  // ↓ this was added ↓
  usage: unsignedBigInt("usage").default(0).notNull(),
});


· You're about to add not-null usage column without default value, which contains 3 items
· You're about to add not-null usage column without default value, which contains 3 items
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

Custom column type
Drizzle TeamDTDrizzle Team / help
16mo ago
Typescript error with custom column type
Drizzle TeamDTDrizzle Team / help
3y ago
Cant get custom type to work with default value
Drizzle TeamDTDrizzle Team / help
16mo ago
Column primary key not working
Drizzle TeamDTDrizzle Team / help
3y ago