mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-01 18:21:52 +02:00
🌐 Better way to store times (#1037)
This commit is contained in:
parent
7b996aa24f
commit
08729168d2
14 changed files with 150 additions and 29 deletions
|
@ -0,0 +1,27 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "options" ADD COLUMN "start_time" TIMESTAMP(0);
|
||||
|
||||
-- migration.sql
|
||||
DO
|
||||
$do$
|
||||
DECLARE
|
||||
poll_record RECORD;
|
||||
BEGIN
|
||||
FOR poll_record IN SELECT id, "time_zone" FROM polls
|
||||
LOOP
|
||||
IF poll_record."time_zone" IS NULL OR poll_record."time_zone" = '' THEN
|
||||
UPDATE options
|
||||
SET "start_time" = "start"
|
||||
WHERE "poll_id" = poll_record.id;
|
||||
ELSE
|
||||
UPDATE options
|
||||
SET "start_time" = ("start"::TIMESTAMP WITHOUT TIME ZONE) AT TIME ZONE poll_record.time_zone
|
||||
WHERE "poll_id" = poll_record.id;
|
||||
END IF;
|
||||
END LOOP;
|
||||
END
|
||||
$do$;
|
||||
|
||||
-- Make start_time not null
|
||||
ALTER TABLE "options" ALTER COLUMN "start_time" SET NOT NULL;
|
||||
|
|
@ -196,7 +196,8 @@ model Participant {
|
|||
|
||||
model Option {
|
||||
id String @id @default(cuid())
|
||||
start DateTime @db.Timestamp(0)
|
||||
start DateTime @db.Timestamp(0) // @deprecated - use startTime
|
||||
startTime DateTime @db.Timestamp(0) @map("start_time")
|
||||
duration Int @default(0) @map("duration_minutes")
|
||||
pollId String @map("poll_id")
|
||||
poll Poll @relation(fields: [pollId], references: [id])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue