-
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.
Merge pull request #45 from Longridge-High-School/feat-unique-asset-f…
…ields feat: unique asset fields, closes #41
- Loading branch information
Showing
7 changed files
with
218 additions
and
12 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
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
20 changes: 20 additions & 0 deletions
20
prisma/migrations/20241009135947_add_unique_to_asset_field/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,20 @@ | ||
-- RedefineTables | ||
PRAGMA defer_foreign_keys=ON; | ||
PRAGMA foreign_keys=OFF; | ||
CREATE TABLE "new_AssetField" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"order" INTEGER NOT NULL, | ||
"helperText" TEXT NOT NULL DEFAULT '', | ||
"displayOnTable" BOOLEAN NOT NULL DEFAULT false, | ||
"hidden" BOOLEAN NOT NULL DEFAULT false, | ||
"unique" INTEGER NOT NULL DEFAULT 0, | ||
"assetId" TEXT NOT NULL, | ||
"fieldId" TEXT NOT NULL, | ||
CONSTRAINT "AssetField_assetId_fkey" FOREIGN KEY ("assetId") REFERENCES "Asset" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
CONSTRAINT "AssetField_fieldId_fkey" FOREIGN KEY ("fieldId") REFERENCES "Field" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
INSERT INTO "new_AssetField" ("assetId", "displayOnTable", "fieldId", "helperText", "hidden", "id", "order") SELECT "assetId", "displayOnTable", "fieldId", "helperText", "hidden", "id", "order" FROM "AssetField"; | ||
DROP TABLE "AssetField"; | ||
ALTER TABLE "new_AssetField" RENAME TO "AssetField"; | ||
PRAGMA foreign_keys=ON; | ||
PRAGMA defer_foreign_keys=OFF; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- @param {String} $1:entryId The ID of the entry being checked | ||
-- @param {String} $2:fieldId The ID of the field being checked | ||
-- @param {String} $3:value The value to be checked | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
Value | ||
WHERE | ||
Value.entryId IN (SELECT Entry.id FROM Entry WHERE Entry.assetId = (SELECT Asset.id FROM Asset WHERE Asset.id = (SELECT Entry.assetId FROM Entry WHERE Entry.id = $1))) | ||
AND | ||
Value.fieldId = $2 | ||
AND | ||
Value.value = $3 |