-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unique constraint to Hacker and update relations (#66)
* Add unique constraint to Hacker and update relations This commit ensures that each hacker-user pairing for a hackathon is unique by adding a new unique constraint on the `Hacker` table. It also modifies the `User` model to reflect a one-to-many relationship with `Hacker` instead of a one-to-one relationship. * Remove unique constraint from HackerApplication model The unique constraint on the combined fields userId and hackathonId in the HackerApplication model has been removed. This change allows for multiple entries with the same userId and hackathonId combination. The modification addresses issues related to duplicative data entries for users in the same hackathon. * Remove unique index on Hacker table This commit drops the unique index "Hacker_userId_hackathonId_key". This change allows multiple records with the same combination of userId and hackathonId. * ``` feat: add composite unique constraint to Hacker model Introduce a composite unique constraint on userId and hackathonId in the Hacker model to ensure unique applications per user per hackathon. Also, update related application logic to accommodate the new constraint. ``` * feat: add composite unique index to Hacker table Ensure unique constraint on userId and hackathonId columns. This prevents duplicate entries and enforces data integrity for hacker-hackathon pairs. * feat: include hackathonId in getApplicationFormStep Added hackathonId parameter to getApplicationFormStep function to better filter hacker records. This change ensures that hackers are correctly associated with their respective hackathons. * feat: add hackathonId to session and form step retrieval Integrated the retrieval of the active hackathon ID into hacker session validation and form step data fetching. This ensures that operations are scoped to the current active hackathon. * refactor: streamline hacker session and application handling Removed unnecessary hackathon ID check in requireHackerSession and updated query to order by creation date. Enhanced isApplicationComplete to include detailed application and hacker validation.
- Loading branch information
1 parent
f9b4d6d
commit f1e7b99
Showing
9 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
prisma/migrations/20241015130402_change_unique_hacker/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,11 @@ | ||
/* | ||
Warnings: | ||
- A unique constraint covering the columns `[userId,hackathonId]` on the table `Hacker` will be added. If there are existing duplicate values, this will fail. | ||
*/ | ||
-- DropIndex | ||
DROP INDEX "Hacker_userId_key"; | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Hacker_userId_hackathonId_key" ON "Hacker"("userId", "hackathonId"); |
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,2 @@ | ||
-- DropIndex | ||
DROP INDEX "Hacker_userId_hackathonId_key"; |
8 changes: 8 additions & 0 deletions
8
prisma/migrations/20241015134428_change_unique_hacker_to_composite/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,8 @@ | ||
/* | ||
Warnings: | ||
- A unique constraint covering the columns `[userId,hackathonId]` on the table `Hacker` will be added. If there are existing duplicate values, this will fail. | ||
*/ | ||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Hacker_userId_hackathonId_key" ON "Hacker"("userId", "hackathonId"); |
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
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
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
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
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
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