Added LobyMembership DB eintraege
This commit is contained in:
parent
987a917896
commit
cc1a27e1c9
@ -1,7 +1,8 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
function GamesPage() {
|
function GamesPage() {
|
||||||
return <div>GamesPage</div>;
|
return (
|
||||||
|
<div>Games</div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default GamesPage;
|
export default GamesPage;
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import {
|
|||||||
} from "@/server/api/trpc";
|
} from "@/server/api/trpc";
|
||||||
import { lobbyPatchSchema } from "@/lib/validations/lobby";
|
import { lobbyPatchSchema } from "@/lib/validations/lobby";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
|
import { time } from "console";
|
||||||
|
|
||||||
export const lobbyRouter = createTRPCRouter({
|
export const lobbyRouter = createTRPCRouter({
|
||||||
// queries
|
// queries
|
||||||
@ -134,6 +135,9 @@ export const lobbyRouter = createTRPCRouter({
|
|||||||
.values({
|
.values({
|
||||||
lobbyId: input.lobbyId,
|
lobbyId: input.lobbyId,
|
||||||
userId: ctx.session.user.id,
|
userId: ctx.session.user.id,
|
||||||
|
isReady: false,
|
||||||
|
joinedAt: new Date(),
|
||||||
|
role: "member",
|
||||||
})
|
})
|
||||||
.returning()
|
.returning()
|
||||||
)[0];
|
)[0];
|
||||||
|
|||||||
@ -16,9 +16,13 @@ export const lobbies = createTable("lobby", (d) => ({
|
|||||||
.primaryKey()
|
.primaryKey()
|
||||||
.notNull()
|
.notNull()
|
||||||
.$defaultFn(() => createId()),
|
.$defaultFn(() => createId()),
|
||||||
name: d.varchar({ length: 255 }),
|
name: d
|
||||||
maxMembers: d.integer().notNull().default(0),
|
.varchar({ length: 255 })
|
||||||
|
.notNull(),
|
||||||
|
maxMembers: d
|
||||||
|
.integer()
|
||||||
|
.notNull()
|
||||||
|
.default(0),
|
||||||
createdById: d
|
createdById: d
|
||||||
.varchar({ length: 255 })
|
.varchar({ length: 255 })
|
||||||
.notNull()
|
.notNull()
|
||||||
@ -53,6 +57,15 @@ export const lobbyMembers = createTable(
|
|||||||
.varchar({ length: 255 })
|
.varchar({ length: 255 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => lobbies.id, { onDelete: "cascade" }),
|
.references(() => lobbies.id, { onDelete: "cascade" }),
|
||||||
|
joinedAt: d
|
||||||
|
.timestamp("created_at", { withTimezone: true })
|
||||||
|
.notNull(),
|
||||||
|
role: d
|
||||||
|
.varchar({ length: 255 })
|
||||||
|
.notNull(),
|
||||||
|
isReady: d
|
||||||
|
.boolean()
|
||||||
|
.notNull(),
|
||||||
}),
|
}),
|
||||||
(t) => [primaryKey({ columns: [t.lobbyId, t.userId] })],
|
(t) => [primaryKey({ columns: [t.lobbyId, t.userId] })],
|
||||||
);
|
);
|
||||||
@ -68,6 +81,7 @@ export const lobbyMembersRelations = relations(lobbyMembers, ({ one }) => ({
|
|||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
export const users = createTable("user", (d) => ({
|
export const users = createTable("user", (d) => ({
|
||||||
id: d
|
id: d
|
||||||
.varchar({ length: 255 })
|
.varchar({ length: 255 })
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user