Vonyc
Vonyc
Explore posts from servers
DTDrizzle Team
Created by Vonyc on 7/23/2023 in #help
Error when calling drizzle-kit push:pg again
@Andrew Sherman Hello, with drizzle-kit: v0.19.12 drizzle-orm: v0.27.2 Everything is working well now. Thank you ❤️ . I close the issue on github
5 replies
DTDrizzle Team
Created by Vonyc on 7/23/2023 in #help
Error when calling drizzle-kit push:pg again
config:
/** @internal */
export const users = pgTable("users", {
id: text("id").notNull().primaryKey(),
name: text("name"),
email: text("email").notNull(),
emailVerified: timestamp("emailVerified", { mode: "date" }),
image: text("image"),
})

/** @internal */
export const accounts = pgTable(
"accounts",
{
userId: text("userId")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
type: text("type").$type<AdapterAccount["type"]>().notNull(),
provider: text("provider").notNull(),
providerAccountId: text("providerAccountId").notNull(),
refresh_token: text("refresh_token"),
access_token: text("access_token"),
created_at: integer("created_at"),
expires_at: integer("expires_at"),
token_type: text("token_type"),
scope: text("scope"),
id_token: text("id_token"),
session_state: text("session_state"),
},
(account) => ({
compoundKey: primaryKey(account.provider, account.providerAccountId),
})
)

/** @internal */
export const sessions = pgTable("sessions", {
sessionToken: text("sessionToken").notNull().primaryKey(),
userId: text("userId")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
expires: timestamp("expires", { mode: "date" }).notNull(),
})

/** @internal */
export const verificationTokens = pgTable(
"verificationToken",
{
identifier: text("identifier").notNull(),
token: text("token").notNull(),
expires: timestamp("expires", { mode: "date" }).notNull(),
},
(vt) => ({
compoundKey: primaryKey(vt.identifier, vt.token),
})
)

/** @internal */
export const schema = { users, accounts, sessions, verificationTokens }
export type DefaultSchema = typeof schema
/** @internal */
export const users = pgTable("users", {
id: text("id").notNull().primaryKey(),
name: text("name"),
email: text("email").notNull(),
emailVerified: timestamp("emailVerified", { mode: "date" }),
image: text("image"),
})

/** @internal */
export const accounts = pgTable(
"accounts",
{
userId: text("userId")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
type: text("type").$type<AdapterAccount["type"]>().notNull(),
provider: text("provider").notNull(),
providerAccountId: text("providerAccountId").notNull(),
refresh_token: text("refresh_token"),
access_token: text("access_token"),
created_at: integer("created_at"),
expires_at: integer("expires_at"),
token_type: text("token_type"),
scope: text("scope"),
id_token: text("id_token"),
session_state: text("session_state"),
},
(account) => ({
compoundKey: primaryKey(account.provider, account.providerAccountId),
})
)

/** @internal */
export const sessions = pgTable("sessions", {
sessionToken: text("sessionToken").notNull().primaryKey(),
userId: text("userId")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
expires: timestamp("expires", { mode: "date" }).notNull(),
})

/** @internal */
export const verificationTokens = pgTable(
"verificationToken",
{
identifier: text("identifier").notNull(),
token: text("token").notNull(),
expires: timestamp("expires", { mode: "date" }).notNull(),
},
(vt) => ({
compoundKey: primaryKey(vt.identifier, vt.token),
})
)

/** @internal */
export const schema = { users, accounts, sessions, verificationTokens }
export type DefaultSchema = typeof schema
5 replies
DTDrizzle Team
Created by Vonyc on 6/16/2023 in #help
How to check if is not null
im trying it,
await db.query.users.findFirst({where: (users, { eq }) => and(eq(users.name, 'test'), isNotNull(users.name)});
await db.query.users.findFirst({where: (users, { eq }) => and(eq(users.name, 'test'), isNotNull(users.name)});
but it still return users without name :/ may be bug?
4 replies