Files
Superuser ff98547dbb init: me-web 个人简历前端
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 20:10:54 +08:00

47 lines
1.4 KiB
TypeScript

import {
mysqlTable,
mysqlEnum,
serial,
varchar,
text,
timestamp,
// bigint,
} from "drizzle-orm/mysql-core";
export const users = mysqlTable("users", {
id: serial("id").primaryKey(),
unionId: varchar("unionId", { length: 255 }).notNull().unique(),
name: varchar("name", { length: 255 }),
email: varchar("email", { length: 320 }),
avatar: text("avatar"),
role: mysqlEnum("role", ["user", "admin"]).default("user").notNull(),
createdAt: timestamp("createdAt").defaultNow().notNull(),
updatedAt: timestamp("updatedAt")
.defaultNow()
.notNull()
.$onUpdate(() => new Date()),
lastSignInAt: timestamp("lastSignInAt").defaultNow().notNull(),
});
export type User = typeof users.$inferSelect;
export type InsertUser = typeof users.$inferInsert;
export const documents = mysqlTable("documents", {
id: serial("id").primaryKey(),
title: varchar("title", { length: 255 }).notNull(),
slug: varchar("slug", { length: 255 }).notNull().unique(),
excerpt: text("excerpt"),
content: text("content").notNull(),
coverImage: text("coverImage"),
tags: text("tags"),
published: mysqlEnum("published", ["draft", "published"]).default("published").notNull(),
createdAt: timestamp("createdAt").defaultNow().notNull(),
updatedAt: timestamp("updatedAt")
.defaultNow()
.notNull()
.$onUpdate(() => new Date()),
});
export type Document = typeof documents.$inferSelect;
export type InsertDocument = typeof documents.$inferInsert;