boyo
boyo
DTDrizzle Team
Created by boyo on 7/9/2024 in #help
SQLite Timestamp does not allow a default NULL value
As the title says,
updatedAt: integer("updated_at", { mode: "timestamp" })
.default(null)
.$onUpdateFn(() => new Date(new Date().toLocaleString("en-US", { timeZone: "Asia/Taipei" }))),
updatedAt: integer("updated_at", { mode: "timestamp" })
.default(null)
.$onUpdateFn(() => new Date(new Date().toLocaleString("en-US", { timeZone: "Asia/Taipei" }))),
Are there no workarounds for this? Here's the error I get: Argument of type 'null' is not assignable to parameter of type 'SQL<unknown> | Date'.
4 replies
DTDrizzle Team
Created by boyo on 6/9/2024 in #help
Custom type is unknown on Drizzle Studio
Hello, I have created a custom type to store my database salt like this:
import { customType, pgTable, text } from "drizzle-orm/pg-core";

const bytea = customType<{ data: Buffer }>({
dataType() {
return "bytea";
},
});

export const users = pgTable("users", {
id: text("id").notNull().primaryKey(),
email: text("email").notNull().unique(),
passwordHash: text("password_hash").notNull(),
salt: bytea("salt").notNull(),
});
import { customType, pgTable, text } from "drizzle-orm/pg-core";

const bytea = customType<{ data: Buffer }>({
dataType() {
return "bytea";
},
});

export const users = pgTable("users", {
id: text("id").notNull().primaryKey(),
email: text("email").notNull().unique(),
passwordHash: text("password_hash").notNull(),
salt: bytea("salt").notNull(),
});
Later, I noticed an issue in the schema tab of Drizzle ORM where I found this:
export const users = pgTable("users", {
id: text("id").primaryKey().notNull(),
passwordHash: text("password_hash").notNull(),
// TODO: failed to parse database type 'bytea'
salt: unknown("salt").notNull(),
email: text("email").notNull(),
});
export const users = pgTable("users", {
id: text("id").primaryKey().notNull(),
passwordHash: text("password_hash").notNull(),
// TODO: failed to parse database type 'bytea'
salt: unknown("salt").notNull(),
email: text("email").notNull(),
});
Is this a normal occurrence or am I doing something wrong?
1 replies