Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✨ Add EventType model and migration (#2377)

Luke Vellaa760af5187d6
diff --git a/apps/web/src/lib/location.ts b/apps/web/src/lib/location.ts
new file mode 100644
index 000000000..41acfc959
--- /dev/null
+++ b/apps/web/src/lib/location.ts
@@ -0,0 +1,21 @@
+import { z } from "zod";
+
+const inPersonLocationSchema = z.object({
+ type: z.literal("in_person"),
+ address: z.string().min(1),
+ placeId: z.string().optional(),
+});
+
+const customLinkLocationSchema = z.object({
+ type: z.literal("custom_link"),
+ url: z.url(),
+ text: z.string().optional(),
+});
+
+export const locationSchema = z.discriminatedUnion("type", [
+ inPersonLocationSchema,
+ customLinkLocationSchema,
+]);
+
+export type Location = z.infer<typeof locationSchema>;
+export type LocationType = Location["type"];
diff --git a/packages/database/prisma/migrations/20260514141310_add_event_type/migration.sql b/packages/database/prisma/migrations/20260514141310_add_event_type/migration.sql
new file mode 100644
index 000000000..313f97f4e
--- /dev/null
+++ b/packages/database/prisma/migrations/20260514141310_add_event_type/migration.sql
@@ -0,0 +1,29 @@
+-- CreateTable
+CREATE TABLE "event_types" (
+ "id" TEXT NOT NULL,
+ "space_id" TEXT NOT NULL,
+ "host_id" TEXT NOT NULL,
+ "name" TEXT NOT NULL,
+ "duration_minutes" INTEGER NOT NULL,
+ "capacity" INTEGER,
+ "description" TEXT,
+ "location" JSONB,
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updated_at" TIMESTAMP(3) NOT NULL,
+ "deleted" BOOLEAN NOT NULL DEFAULT false,
+ "deleted_at" TIMESTAMP(3),
+
+ CONSTRAINT "event_types_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateIndex
+CREATE INDEX "event_types_space_id_idx" ON "event_types"("space_id");
+
+-- CreateIndex
+CREATE INDEX "event_types_host_id_idx" ON "event_types"("host_id");
+
+-- AddForeignKey
+ALTER TABLE "event_types" ADD CONSTRAINT "event_types_space_id_fkey" FOREIGN KEY ("space_id") REFERENCES "spaces"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "event_types" ADD CONSTRAINT "event_types_host_id_fkey" FOREIGN KEY ("host_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/packages/database/prisma/models/event-type.prisma b/packages/database/prisma/models/event-type.prisma
new file mode 100644
index 000000000..6b40651c2
--- /dev/null
+++ b/packages/database/prisma/models/event-type.prisma
@@ -0,0 +1,22 @@
+model EventType {
+ id String @id @default(cuid())
+ spaceId String @map("space_id")
+ hostId String @map("host_id")
+ name String
+ duration Int @map("duration_minutes")
+ capacity Int?
+ description String?
+ location Json?
+
+ createdAt DateTime @default(now()) @map("created_at")
+ updatedAt DateTime @updatedAt @map("updated_at")
+ deleted Boolean @default(false)
+ deletedAt DateTime? @map("deleted_at")
+
+ space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade)
+ host User @relation(fields: [hostId], references: [id], onDelete: Cascade)
+
+ @@index([spaceId])
+ @@index([hostId])
+ @@map("event_types")
+}
diff --git a/packages/database/prisma/models/space.prisma b/packages/database/prisma/models/space.prisma
index 8aeda49c8..593d306d8 100644
--- a/packages/database/prisma/models/space.prisma
+++ b/packages/database/prisma/models/space.prisma
@@ -12,6 +12,7 @@ model Space {
owner User @relation("UserSpaces", fields: [ownerId], references: [id], onDelete: Cascade)
polls Poll[]
scheduledEvents ScheduledEvent[]
+ eventTypes EventType[]
subscriptions Subscription[] @relation("SpaceToSubscription")
members SpaceMember[]
diff --git a/packages/database/prisma/models/user.prisma b/packages/database/prisma/models/user.prisma
index 3328b0b37..1040ef7d8 100644
--- a/packages/database/prisma/models/user.prisma
+++ b/packages/database/prisma/models/user.prisma
@@ -72,6 +72,7 @@ model User {
pollViews PollView[]
scheduledEvents ScheduledEvent[]
scheduledEventInvites ScheduledEventInvite[]
+ hostedEventTypes EventType[]
calendarConnections CalendarConnection[]
credentials Credential[]