titles/drizzle/schema.ts

29 lines
658 B
TypeScript
Raw Permalink Normal View History

2024-05-16 12:37:35 +00:00
import { drizzle } from "drizzle-orm/vercel-postgres";
import { sql } from "@vercel/postgres";
import {
pgTable,
serial,
text,
timestamp,
uniqueIndex,
} from "drizzle-orm/pg-core";
import { InferSelectModel } from "drizzle-orm";
2024-05-16 12:37:35 +00:00
export const UsersTable = pgTable(
"users",
{
id: serial("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull(),
image: text("image").notNull(),
createdAt: timestamp("createdAt").defaultNow().notNull(),
},
(users) => {
return {
uniqueIdx: uniqueIndex("unique_idx").on(users.email),
};
}
);
export type Users = InferSelectModel<typeof UsersTable>;