co-authored by
Gunshin
Unverified
parent
45f6d06cc9
commit
8a96ea8573
+51
-3
@@ -3,6 +3,7 @@ import {
|
||||
boolean,
|
||||
integer,
|
||||
jsonb,
|
||||
numeric,
|
||||
pgEnum,
|
||||
pgSchema,
|
||||
pgTable,
|
||||
@@ -11,6 +12,7 @@ import {
|
||||
timestamp,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { uuidv7 } from "uuidv7";
|
||||
import type { SlipokResponse } from "@/app/(ui)/rubgram/api";
|
||||
import { bytea } from "./custom";
|
||||
|
||||
export const element = pgEnum("character_element", [
|
||||
@@ -102,22 +104,68 @@ export const artifactSettings = artifact.table("settings", {
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Artifact
|
||||
//#region Endgame
|
||||
export const endgame = pgSchema("endgame");
|
||||
|
||||
export const endgameServer = endgame.enum("server", ["as", "eu", "us", "tw"]);
|
||||
export const endgameService = endgame.enum("service", [
|
||||
"abyss",
|
||||
"theater",
|
||||
"stygian",
|
||||
]);
|
||||
|
||||
export const endgameSubmissions = endgame.table("submissions", {
|
||||
id: text().primaryKey().$defaultFn(uuidv7),
|
||||
name: text().notNull(),
|
||||
user: text().notNull(),
|
||||
expires: timestamp().$defaultFn(() => new Date(Date.now() + 15 * 60 * 1000)), // 15 minutes to pay
|
||||
user: text()
|
||||
.notNull()
|
||||
.references(() => endgameDiscord.uid, {
|
||||
onDelete: "cascade",
|
||||
onUpdate: "cascade",
|
||||
}),
|
||||
expires: timestamp().$defaultFn(() => new Date(Date.now() + 20 * 60 * 1000)), // 20 minutes to pay
|
||||
queue: serial(),
|
||||
server: endgameServer().notNull(),
|
||||
service: endgameService().array().notNull(),
|
||||
price: integer().notNull(), // calculated on submission
|
||||
slip: text().references(() => endgameSlips.id), // not paid = null
|
||||
checked: boolean().notNull().default(false),
|
||||
});
|
||||
|
||||
// deleted submissions
|
||||
export const endgameArchive = endgame.table("archive", {
|
||||
id: text().primaryKey().$defaultFn(uuidv7),
|
||||
name: text().notNull(),
|
||||
user: text()
|
||||
.notNull()
|
||||
.references(() => endgameDiscord.uid, {
|
||||
onDelete: "cascade",
|
||||
onUpdate: "cascade",
|
||||
}),
|
||||
server: endgameServer().notNull(),
|
||||
service: endgameService().array().notNull(),
|
||||
});
|
||||
|
||||
export const endgameSlips = endgame.table("slips", {
|
||||
id: text().primaryKey().$defaultFn(uuidv7),
|
||||
slip: bytea().notNull(),
|
||||
ref: text().unique().notNull(),
|
||||
amount: numeric().notNull(),
|
||||
data: jsonb().$type<SlipokResponse>().notNull(),
|
||||
});
|
||||
|
||||
export const endgameSettings = endgame.table("settings", {
|
||||
id: boolean().primaryKey().default(true),
|
||||
locked: boolean().notNull().default(false),
|
||||
limit: integer().notNull().default(-1),
|
||||
free: integer().notNull().default(0),
|
||||
});
|
||||
|
||||
export const endgameDiscord = endgame.table("discord", {
|
||||
uid: text().primaryKey(), // user snowflake
|
||||
display: text().notNull(),
|
||||
username: text().notNull(),
|
||||
token: text().notNull().$defaultFn(uuidv7), // for accessing existing user with cookie.
|
||||
});
|
||||
|
||||
//#endregion
|
||||
|
||||
Reference in New Issue
Block a user