-
Notifications
You must be signed in to change notification settings - Fork 5
[PCN-133] add setup #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: testing
Are you sure you want to change the base?
[PCN-133] add setup #186
Changes from 7 commits
32e8e4a
fb696fa
aa162c5
afe48b9
e18d36f
a8931e1
5b1ad75
6c4d9d2
9ee1be8
545b514
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| -- CreateTable | ||
| CREATE TABLE "Post" ( | ||
| "id" TEXT NOT NULL, | ||
| "title" TEXT NOT NULL, | ||
| "content" TEXT NOT NULL, | ||
| "imageUrl" TEXT NOT NULL, | ||
| "authorId" TEXT NOT NULL, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
|
||
| CONSTRAINT "Post_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "Post" ADD CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| Warnings: | ||
|
|
||
| - You are about to drop the `Post` table. If the table is not empty, all the data it contains will be lost. | ||
|
|
||
| */ | ||
| -- DropForeignKey | ||
| ALTER TABLE "Post" DROP CONSTRAINT "Post_authorId_fkey"; | ||
|
|
||
| -- DropTable | ||
| DROP TABLE "Post"; | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "Setup" ( | ||
| "id" TEXT NOT NULL, | ||
| "title" TEXT NOT NULL, | ||
| "content" TEXT NOT NULL, | ||
| "imageUrl" TEXT NOT NULL, | ||
| "authorId" TEXT NOT NULL, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
|
||
| CONSTRAINT "Setup_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "Setup" ADD CONSTRAINT "Setup_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Veo que esta PR incluye 3 migrations. Lo ideal es que una PR tenga solo una migration. Lo que podes hacer es borrar estas 3 y crear una nueva. Esa nueva que crees, va a tener todos los cambios necesarios para hacer en la base. Avisame y lo vemos por Discord.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. La elimine y la modifique en una sola PR. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| Warnings: | ||
|
|
||
| - A unique constraint covering the columns `[userId,setupId]` on the table `Like` will be added. If there are existing duplicate values, this will fail. | ||
|
|
||
| */ | ||
| -- AlterTable | ||
| ALTER TABLE "Like" ADD COLUMN "setupId" TEXT, | ||
| ALTER COLUMN "adviseId" DROP NOT NULL; | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "Like_userId_setupId_key" ON "Like"("userId", "setupId"); | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "Like" ADD CONSTRAINT "Like_setupId_fkey" FOREIGN KEY ("setupId") REFERENCES "Setup"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ model User { | |
| linkedinUrl String? | ||
| sessions Session[] | ||
| advises Advise[] | ||
| setups Setup[] | ||
| languages UserLanguage[] | ||
| comments Comment[] | ||
| likes Like[] | ||
|
|
@@ -51,6 +52,21 @@ model Advise { | |
| updatedAt DateTime @updatedAt | ||
| } | ||
|
|
||
| model Setup { | ||
| id String @id @default(cuid()) | ||
| title String | ||
| content String | ||
| imageUrl String | ||
|
|
||
| author User @relation(fields: [authorId], references: [id]) | ||
| authorId String | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Que opinas de que el nombre del campo sea owner en lugar de author? |
||
|
|
||
| likes Like[] | ||
|
|
||
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @updatedAt | ||
| } | ||
|
|
||
| model Comment { | ||
| id String @id @default(cuid()) | ||
| content String | ||
|
|
@@ -111,13 +127,17 @@ model Image { | |
| model Like { | ||
| id String @id @default(cuid()) | ||
| userId String | ||
| adviseId String | ||
| adviseId String? | ||
| setupId String? | ||
|
|
||
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
| advise Advise @relation(fields: [adviseId], references: [id], onDelete: Cascade) | ||
| advise Advise? @relation(fields: [adviseId], references: [id], onDelete: Cascade) | ||
| setup Setup? @relation(fields: [setupId], references: [id], onDelete: Cascade) | ||
|
|
||
| createdAt DateTime @default(now()) | ||
| updatedAt DateTime @updatedAt | ||
|
|
||
| @@unique([userId, adviseId]) | ||
| @@unique([userId, setupId]) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.