Added tags to GET snippet routes

This commit is contained in:
Florian Sylvain
2023-02-03 00:50:24 +01:00
parent 58b7fecd25
commit 6a8de0039c
5 changed files with 146 additions and 42 deletions
@@ -0,0 +1,17 @@
-- DropForeignKey
ALTER TABLE `Snippet` DROP FOREIGN KEY `Snippet_category_id_fkey`;
-- DropForeignKey
ALTER TABLE `Snippet_tag` DROP FOREIGN KEY `Snippet_tag_snippet_id_fkey`;
-- DropForeignKey
ALTER TABLE `Snippet_tag` DROP FOREIGN KEY `Snippet_tag_tag_id_fkey`;
-- AddForeignKey
ALTER TABLE `Snippet` ADD CONSTRAINT `Snippet_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `Category`(`id`) ON DELETE SET NULL ON UPDATE SET NULL;
-- AddForeignKey
ALTER TABLE `Snippet_tag` ADD CONSTRAINT `Snippet_tag_tag_id_fkey` FOREIGN KEY (`tag_id`) REFERENCES `Tag`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Snippet_tag` ADD CONSTRAINT `Snippet_tag_snippet_id_fkey` FOREIGN KEY (`snippet_id`) REFERENCES `Snippet`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+3 -3
View File
@@ -30,7 +30,7 @@ model Snippet {
user_id Int
user User @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
category_id Int?
category Category? @relation(fields: [category_id], references: [id])
category Category? @relation(fields: [category_id], references: [id], onDelete: SetNull, onUpdate: SetNull)
language_id Int
language Language @relation(fields: [language_id], references: [id])
Snippet_tag Snippet_tag[]
@@ -52,9 +52,9 @@ model Language {
model Snippet_tag {
tag_id Int
tag Tag @relation(fields: [tag_id], references: [id])
tag Tag @relation(fields: [tag_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
snippet_id Int
snippet Snippet @relation(fields: [snippet_id], references: [id])
snippet Snippet @relation(fields: [snippet_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@id([tag_id, snippet_id])
}