mirror of
https://github.com/Floriansylvain/SnippetsManager.git
synced 2026-08-19 11:43:15 +02:00
Added user_id on Category
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- Added the required column `user_id` to the `Category` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE `Category` ADD COLUMN `user_id` INTEGER NOT NULL;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE `Category` ADD CONSTRAINT `Category_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
@@ -8,7 +8,7 @@ datasource db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
email String
|
email String
|
||||||
password String
|
password String
|
||||||
name String
|
name String
|
||||||
@@ -16,6 +16,7 @@ model User {
|
|||||||
created_at DateTime
|
created_at DateTime
|
||||||
updated_at DateTime
|
updated_at DateTime
|
||||||
Snippet Snippet[]
|
Snippet Snippet[]
|
||||||
|
Category Category[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model Snippet {
|
model Snippet {
|
||||||
@@ -37,6 +38,8 @@ model Snippet {
|
|||||||
model Category {
|
model Category {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
name String
|
name String
|
||||||
|
user_id Int
|
||||||
|
user User @relation(fields: [user_id], references: [id])
|
||||||
Snippet Snippet[]
|
Snippet Snippet[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user