Skip to content

Commit

Permalink
Merge pull request #3 from Rocketseat/chore/update-table-case
Browse files Browse the repository at this point in the history
chore: add snake case to table names
  • Loading branch information
gabrielbuzziv committed Mar 22, 2022
2 parents 61b48ef + c7aadf8 commit f5b925e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
CREATE TYPE "VideoEventType" AS ENUM ('PLAY', 'PAUSE', 'JUMP', 'SPEED_CHANGE');

-- CreateTable
CREATE TABLE "VideoWatchTime" (
CREATE TABLE "video_watch_time" (
"id" TEXT NOT NULL,
"session_id" TEXT NOT NULL,
"video_id" TEXT NOT NULL,
Expand All @@ -14,11 +14,11 @@ CREATE TABLE "VideoWatchTime" (
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "VideoWatchTime_pkey" PRIMARY KEY ("id")
CONSTRAINT "video_watch_time_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "VideoEvent" (
CREATE TABLE "video_event" (
"id" TEXT NOT NULL,
"session_id" TEXT NOT NULL,
"watch_time_id" TEXT NOT NULL,
Expand All @@ -29,11 +29,11 @@ CREATE TABLE "VideoEvent" (
"type" "VideoEventType" NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "VideoEvent_pkey" PRIMARY KEY ("id")
CONSTRAINT "video_event_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "VideoEvent_id_created_at_key" ON "VideoEvent"("id", "created_at");
CREATE UNIQUE INDEX "video_event_id_created_at_key" ON "video_event"("id", "created_at");

-- AddForeignKey
ALTER TABLE "VideoEvent" ADD CONSTRAINT "VideoEvent_watch_time_id_fkey" FOREIGN KEY ("watch_time_id") REFERENCES "VideoWatchTime"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "video_event" ADD CONSTRAINT "video_event_watch_time_id_fkey" FOREIGN KEY ("watch_time_id") REFERENCES "video_watch_time"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
3 changes: 3 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ model VideoWatchTime {
updated_at DateTime @default(now()) @updatedAt
events VideoEvent[]
@@map("video_watch_time")
}

enum VideoEventType {
Expand All @@ -44,4 +46,5 @@ model VideoEvent {
created_at DateTime @default(now())
@@unique([id, created_at])
@@map("video_event")
}

0 comments on commit f5b925e

Please sign in to comment.