Unfinished

This commit is contained in:
aronmal 2024-02-18 22:02:52 +01:00
parent 18c6535d1c
commit 6b388729d9
Signed by: aronmal
GPG key ID: 816B7707426FC612
25 changed files with 1598 additions and 2352 deletions

View file

@ -1,10 +1,8 @@
import type { AdapterAccount } from "@auth/core/adapters";
import { relations } from "drizzle-orm";
import {
boolean,
integer,
pgTable,
primaryKey,
serial,
smallint,
text,
@ -13,56 +11,31 @@ import {
} from "drizzle-orm/pg-core";
export const users = pgTable("user", {
id: text("id").notNull().primaryKey(),
id: varchar("id", { length: 24 }).primaryKey(),
discord_id: text("discord_id").notNull(),
name: text("name"),
email: text("email").notNull(),
emailVerified: timestamp("emailVerified", { mode: "date" }),
image: text("image"),
});
export const accounts = pgTable(
"account",
{
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"),
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({
columns: [account.provider, account.providerAccountId],
}),
}),
);
export const sessions = pgTable("session", {
sessionToken: text("sessionToken").notNull().primaryKey(),
userId: text("userId")
id: varchar("id", { length: 24 }).primaryKey(),
userId: varchar("user_id", { length: 24 })
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
expires: timestamp("expires", { mode: "date" }).notNull(),
expiresAt: timestamp("expires_at", {
withTimezone: true,
mode: "date",
}).notNull(),
});
export const verificationTokens = pgTable(
"verificationToken",
{
identifier: text("identifier").notNull(),
token: text("token").notNull(),
expires: timestamp("expires", { mode: "date" }).notNull(),
},
(vt) => ({
compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
}),
);
export const discordTokens = pgTable("tokens", {
userId: varchar("user_id", { length: 24 })
.primaryKey()
.references(() => users.id, { onDelete: "cascade" }),
refreshToken: text("refresh_token").notNull(),
accessToken: text("access_token").notNull(),
expiresAt: timestamp("expires_at", { mode: "date" }).notNull(),
});
export const matchPlannings = pgTable("match_planning", {
id: serial("id").primaryKey(),