Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
import { sql } from "drizzle-orm";
import {
integer,
primaryKey,
sqliteTable,
text,
} from "drizzle-orm/sqlite-core";
import type { AdapterAccountType } from "next-auth/adapters";
export const viewer = sqliteTable("viewer", {
id: integer("id").primaryKey(),
name: text("name"),
email: text("email").unique(),
emailVerified: integer("emailVerified", { mode: "timestamp" }),
image: text("image"),
createdAt: integer("created_at", { mode: "timestamp" }).default(
sql`(strftime('%s', 'now'))`,
),
updatedAt: integer("updated_at", { mode: "timestamp" }).default(
sql`(strftime('%s', 'now'))`,
),
});
export const viewerSession = sqliteTable("viewer_session", {
sessionToken: text("session_token").primaryKey(),
userId: integer("user_id")
.notNull()
.references(() => viewer.id, { onDelete: "cascade" }),
expires: integer("expires", { mode: "timestamp_ms" }).notNull(),
});
export const viewerAccounts = sqliteTable(
"viewer_accounts",
{
userId: text("user_id")
.notNull()
.references(() => viewer.id, { onDelete: "cascade" }),
type: text("type").$type<AdapterAccountType>().notNull(),
provider: text("provider").notNull(),
providerAccountId: text("providerAccountId").notNull(),
refresh_token: text("refresh_token"),
access_token: text("access_token"),
expires_at: integer("expires_at"),
token_type: text("token_type"),
scope: text("scope"),
id_token: text("id_token"),
session_state: text("session_state"),
},
(account) => [
primaryKey({
columns: [account.provider, account.providerAccountId],
}),
],
);