mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-03 16:38:34 +02:00
Updated links model and poll page (#206)
* Improved sharing * Updated desktop poll
This commit is contained in:
parent
c4cbf2f6bb
commit
2ead375b42
50 changed files with 955 additions and 1848 deletions
|
@ -0,0 +1,26 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "polls"
|
||||
ADD COLUMN "admin_url_id" TEXT,
|
||||
ADD COLUMN "participant_url_id" TEXT;
|
||||
|
||||
UPDATE polls
|
||||
SET participant_url_id=(SELECT url_id FROM links WHERE polls.url_id=links.poll_id AND links."role"='participant');
|
||||
|
||||
UPDATE polls
|
||||
SET admin_url_id=(SELECT url_id FROM links WHERE polls.url_id=links.poll_id AND links."role"='admin');
|
||||
|
||||
ALTER TABLE "polls"
|
||||
ALTER COLUMN "admin_url_id" SET NOT NULL,
|
||||
ALTER COLUMN "participant_url_id" SET NOT NULL;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "links";
|
||||
|
||||
-- DropEnum
|
||||
DROP TYPE "role";
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "polls_participant_url_id_key" ON "polls"("participant_url_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "polls_admin_url_id_key" ON "polls"("admin_url_id");
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `polls` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to drop the column `url_id` on the `polls` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[id]` on the table `polls` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `id` to the `polls` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropIndex
|
||||
DROP INDEX "Poll_urlId_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "polls_url_id_key";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "polls"
|
||||
RENAME COLUMN "url_id" TO "id";
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "polls_id_key" ON "polls"("id");
|
|
@ -1,11 +1,11 @@
|
|||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
referentialIntegrity = "prisma"
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
provider = "prisma-client-js"
|
||||
previewFeatures = ["referentialIntegrity"]
|
||||
}
|
||||
|
||||
|
@ -29,60 +29,43 @@ enum PollType {
|
|||
}
|
||||
|
||||
model Poll {
|
||||
urlId String @id @unique @map("url_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deadline DateTime?
|
||||
title String
|
||||
type PollType
|
||||
description String?
|
||||
location String?
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String @map("user_id")
|
||||
votes Vote[]
|
||||
timeZone String? @map("time_zone")
|
||||
verified Boolean @default(false)
|
||||
options Option[]
|
||||
participants Participant[]
|
||||
authorName String @default("") @map("author_name")
|
||||
demo Boolean @default(false)
|
||||
comments Comment[]
|
||||
links Link[]
|
||||
legacy Boolean @default(false)
|
||||
closed Boolean @default(false)
|
||||
notifications Boolean @default(false)
|
||||
deleted Boolean @default(false)
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
touchedAt DateTime @default(now()) @map("touched_at")
|
||||
id String @id @unique @map("id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deadline DateTime?
|
||||
title String
|
||||
type PollType
|
||||
description String?
|
||||
location String?
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String @map("user_id")
|
||||
votes Vote[]
|
||||
timeZone String? @map("time_zone")
|
||||
verified Boolean @default(false)
|
||||
options Option[]
|
||||
participants Participant[]
|
||||
authorName String @default("") @map("author_name")
|
||||
demo Boolean @default(false)
|
||||
comments Comment[]
|
||||
legacy Boolean @default(false)
|
||||
closed Boolean @default(false)
|
||||
notifications Boolean @default(false)
|
||||
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")
|
||||
|
||||
@@map("polls")
|
||||
}
|
||||
|
||||
enum Role {
|
||||
admin
|
||||
participant
|
||||
|
||||
@@map("role")
|
||||
}
|
||||
|
||||
model Link {
|
||||
urlId String @id @unique @map("url_id")
|
||||
role Role
|
||||
pollId String @map("poll_id")
|
||||
poll Poll @relation(fields: [pollId], references: [urlId])
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@unique([pollId, role])
|
||||
@@map("links")
|
||||
}
|
||||
|
||||
model Participant {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
userId String? @map("user_id")
|
||||
guestId String? @map("guest_id")
|
||||
poll Poll @relation(fields: [pollId], references: [urlId])
|
||||
poll Poll @relation(fields: [pollId], references: [id])
|
||||
pollId String @map("poll_id")
|
||||
votes Vote[]
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
@ -96,7 +79,7 @@ model Option {
|
|||
id String @id @default(cuid())
|
||||
value String
|
||||
pollId String @map("poll_id")
|
||||
poll Poll @relation(fields: [pollId], references: [urlId])
|
||||
poll Poll @relation(fields: [pollId], references: [id])
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime? @updatedAt @map("updated_at")
|
||||
votes Vote[]
|
||||
|
@ -118,7 +101,7 @@ model Vote {
|
|||
participantId String @map("participant_id")
|
||||
option Option @relation(fields: [optionId], references: [id], onDelete: Cascade)
|
||||
optionId String @map("option_id")
|
||||
poll Poll @relation(fields: [pollId], references: [urlId])
|
||||
poll Poll @relation(fields: [pollId], references: [id])
|
||||
pollId String @map("poll_id")
|
||||
type VoteType @default(yes)
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
@ -130,7 +113,7 @@ model Vote {
|
|||
model Comment {
|
||||
id String @id @default(cuid())
|
||||
content String
|
||||
poll Poll @relation(fields: [pollId], references: [urlId])
|
||||
poll Poll @relation(fields: [pollId], references: [id])
|
||||
pollId String @map("poll_id")
|
||||
authorName String @map("author_name")
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue