mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-21 12:56:21 +02:00
⬆️ v3.0.0 (#704)
This commit is contained in:
parent
735056f25f
commit
c22b3abc4d
385 changed files with 19912 additions and 5250 deletions
|
@ -0,0 +1,39 @@
|
|||
-- CreateEnum
|
||||
CREATE TYPE "time_format" AS ENUM ('hours12', 'hours24');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "polls" ADD COLUMN "event_id" TEXT,
|
||||
ADD COLUMN "selected_option_id" TEXT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "user_preferences" (
|
||||
"user_id" TEXT NOT NULL,
|
||||
"time_zone" TEXT,
|
||||
"week_start" INTEGER,
|
||||
"time_format" "time_format",
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "user_preferences_pkey" PRIMARY KEY ("user_id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "events" (
|
||||
"id" TEXT NOT NULL,
|
||||
"poll_id" TEXT NOT NULL,
|
||||
"user_id" TEXT NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"start" TIMESTAMP(0) NOT NULL,
|
||||
"duration_minutes" INTEGER NOT NULL DEFAULT 0,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "events_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "events_poll_id_key" ON "events"("poll_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "events_poll_id_idx" ON "events" USING HASH ("poll_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "events_user_id_idx" ON "events" USING HASH ("user_id");
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `option_id` to the `events` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "events" ADD COLUMN "option_id" TEXT NOT NULL;
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `selected_option_id` on the `polls` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "polls" DROP COLUMN "selected_option_id";
|
|
@ -9,6 +9,13 @@ generator client {
|
|||
binaryTargets = ["native"]
|
||||
}
|
||||
|
||||
enum TimeFormat {
|
||||
hours12
|
||||
hours24
|
||||
|
||||
@@map("time_format")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
|
@ -18,10 +25,31 @@ model User {
|
|||
comments Comment[]
|
||||
polls Poll[]
|
||||
watcher Watcher[]
|
||||
events Event[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
// model UserPaymentData {
|
||||
// userId String @id @map("user_id")
|
||||
// subscriptionId String @map("subscription_id")
|
||||
// subscriptionPlanId String @map("subscription_plan_id")
|
||||
// subscriptionEndDate DateTime @map("subscription_end_date")
|
||||
// subscriptionStatus String @map("subscription_status")
|
||||
// subscriptionUpdateUrl String @map("subscription_update_url")
|
||||
// subscriptionCancelUrl String @map("subscription_cancel_url")
|
||||
// }
|
||||
|
||||
model UserPreferences {
|
||||
userId String @id @map("user_id")
|
||||
timeZone String? @map("time_zone")
|
||||
weekStart Int? @map("week_start")
|
||||
timeFormat TimeFormat? @map("time_format")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@map("user_preferences")
|
||||
}
|
||||
|
||||
model Poll {
|
||||
id String @id @unique @map("id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
@ -39,18 +67,38 @@ model Poll {
|
|||
watchers Watcher[]
|
||||
demo Boolean @default(false)
|
||||
comments Comment[]
|
||||
legacy Boolean @default(false)
|
||||
closed Boolean @default(false)
|
||||
legacy Boolean @default(false) // @deprecated
|
||||
closed Boolean @default(false) // we use this to indicate whether a poll is paused
|
||||
deleted Boolean @default(false)
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
touchedAt DateTime @default(now()) @map("touched_at")
|
||||
participantUrlId String @unique @map("participant_url_id")
|
||||
adminUrlId String @unique @map("admin_url_id")
|
||||
eventId String? @map("event_id")
|
||||
event Event?
|
||||
|
||||
@@index([userId], type: Hash)
|
||||
@@map("polls")
|
||||
}
|
||||
|
||||
model Event {
|
||||
id String @id @default(cuid())
|
||||
pollId String @unique @map("poll_id")
|
||||
userId String @map("user_id")
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
poll Poll @relation(fields: [pollId], references: [id])
|
||||
optionId String @map("option_id")
|
||||
title String
|
||||
start DateTime @db.Timestamp(0)
|
||||
duration Int @default(0) @map("duration_minutes")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@index([pollId], type: Hash)
|
||||
@@index([userId], type: Hash)
|
||||
@@map("events")
|
||||
}
|
||||
|
||||
|
||||
model Watcher {
|
||||
id Int @id @default(autoincrement())
|
||||
userId String @map("user_id")
|
||||
|
@ -80,12 +128,12 @@ model Participant {
|
|||
}
|
||||
|
||||
model Option {
|
||||
id String @id @default(cuid())
|
||||
start DateTime @db.Timestamp(0)
|
||||
duration Int @default(0) @map("duration_minutes")
|
||||
pollId String @map("poll_id")
|
||||
poll Poll @relation(fields: [pollId], references: [id])
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
id String @id @default(cuid())
|
||||
start DateTime @db.Timestamp(0)
|
||||
duration Int @default(0) @map("duration_minutes")
|
||||
pollId String @map("poll_id")
|
||||
poll Poll @relation(fields: [pollId], references: [id])
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@index([pollId], type: Hash)
|
||||
@@map("options")
|
||||
|
|
|
@ -37,7 +37,7 @@ async function main() {
|
|||
id: user.id,
|
||||
},
|
||||
},
|
||||
timeZone: "America/New_York",
|
||||
timeZone: duration !== 0 ? "America/New_York" : undefined,
|
||||
options: {
|
||||
create: faker.date
|
||||
.betweens(
|
||||
|
@ -48,6 +48,7 @@ async function main() {
|
|||
.map((date) => {
|
||||
// rounded to nearest 15 minutes
|
||||
date.setMinutes(Math.round(date.getMinutes() / 15) * 15);
|
||||
date.setSeconds(0);
|
||||
return {
|
||||
start: date,
|
||||
duration,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue