forked from wishonia/wishonia
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce unique constraints and cascade deletions for Article.
Added unique constraints on "userId, promptedTopic" and "userId, title" in the Article table. Updated foreign key relationships to cascade on delete and update for associated tables. These changes improve data integrity and consistency across related entities.
- Loading branch information
Showing
4 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,5 @@ next-env.d.ts | |
/test-results/ | ||
/dumps/ | ||
|
||
.trigger | ||
.trigger | ||
/.vscode |
17 changes: 17 additions & 0 deletions
17
prisma/migrations/20240914023136_delete_articles/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- DropForeignKey | ||
ALTER TABLE "ArticleGenerationOptions" DROP CONSTRAINT "ArticleGenerationOptions_articleId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "ArticleSearchResult" DROP CONSTRAINT "ArticleSearchResult_articleId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "ArticleSource" DROP CONSTRAINT "ArticleSource_articleId_fkey"; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ArticleSource" ADD CONSTRAINT "ArticleSource_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ArticleSearchResult" ADD CONSTRAINT "ArticleSearchResult_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ArticleGenerationOptions" ADD CONSTRAINT "ArticleGenerationOptions_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
12 changes: 12 additions & 0 deletions
12
prisma/migrations/20240914023340_unique_articles/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
Warnings: | ||
- A unique constraint covering the columns `[userId,promptedTopic]` on the table `Article` will be added. If there are existing duplicate values, this will fail. | ||
- A unique constraint covering the columns `[userId,title]` on the table `Article` will be added. If there are existing duplicate values, this will fail. | ||
*/ | ||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Article_userId_promptedTopic_key" ON "Article"("userId", "promptedTopic"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Article_userId_title_key" ON "Article"("userId", "title"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters