diff --git a/package.json b/package.json index cfc1846..c58f2a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ava", - "version": "2.1.0", + "version": "2.1.1", "private": true, "scripts": { "dev": "vite dev", diff --git a/prisma/migrations/20241123022340_update_emailhashes/migration.sql b/prisma/migrations/20241123022340_update_emailhashes/migration.sql deleted file mode 100644 index 9abdbcb..0000000 --- a/prisma/migrations/20241123022340_update_emailhashes/migration.sql +++ /dev/null @@ -1,26 +0,0 @@ -/* - Warnings: - - - The primary key for the `EmailHashes` table will be changed. If it partially fails, the table could be left without primary key constraint. - -*/ --- RedefineTables -PRAGMA defer_foreign_keys=ON; -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_EmailHashes" ( - "forUserId" TEXT NOT NULL, - "email" TEXT NOT NULL DEFAULT 'unknown:${uuid()}', - "sha256" BLOB NOT NULL, - "md5" BLOB NOT NULL, - "isPrimaryForUserId" TEXT, - CONSTRAINT "EmailHashes_forUserId_fkey" FOREIGN KEY ("forUserId") REFERENCES "User" ("userId") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "EmailHashes_isPrimaryForUserId_fkey" FOREIGN KEY ("isPrimaryForUserId") REFERENCES "User" ("userId") ON DELETE SET NULL ON UPDATE CASCADE -); -INSERT INTO "new_EmailHashes" ("forUserId", "md5", "sha256") SELECT "forUserId", "md5", "sha256" FROM "EmailHashes"; -DROP TABLE "EmailHashes"; -ALTER TABLE "new_EmailHashes" RENAME TO "EmailHashes"; -CREATE UNIQUE INDEX "EmailHashes_email_key" ON "EmailHashes"("email"); -CREATE UNIQUE INDEX "EmailHashes_isPrimaryForUserId_key" ON "EmailHashes"("isPrimaryForUserId"); -CREATE UNIQUE INDEX "EmailHashes_sha256_md5_key" ON "EmailHashes"("sha256", "md5"); -PRAGMA foreign_keys=ON; -PRAGMA defer_foreign_keys=OFF; diff --git a/prisma/migrations/20241123022424_add_id/migration.sql b/prisma/migrations/20241123034939_edit_emailhashes/migration.sql similarity index 69% rename from prisma/migrations/20241123022424_add_id/migration.sql rename to prisma/migrations/20241123034939_edit_emailhashes/migration.sql index 7d88a21..18e9db1 100644 --- a/prisma/migrations/20241123022424_add_id/migration.sql +++ b/prisma/migrations/20241123034939_edit_emailhashes/migration.sql @@ -1,6 +1,8 @@ /* Warnings: + - The primary key for the `EmailHashes` table will be changed. If it partially fails, the table could be left without primary key constraint. + - The required column `email` was added to the `EmailHashes` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required. - The required column `id` was added to the `EmailHashes` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required. */ @@ -10,14 +12,14 @@ PRAGMA foreign_keys=OFF; CREATE TABLE "new_EmailHashes" ( "id" TEXT NOT NULL PRIMARY KEY, "forUserId" TEXT NOT NULL, - "email" TEXT NOT NULL DEFAULT 'unknown:${uuid()}', + "email" TEXT NOT NULL, "sha256" BLOB NOT NULL, "md5" BLOB NOT NULL, "isPrimaryForUserId" TEXT, CONSTRAINT "EmailHashes_forUserId_fkey" FOREIGN KEY ("forUserId") REFERENCES "User" ("userId") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "EmailHashes_isPrimaryForUserId_fkey" FOREIGN KEY ("isPrimaryForUserId") REFERENCES "User" ("userId") ON DELETE SET NULL ON UPDATE CASCADE ); -INSERT INTO "new_EmailHashes" ("email", "forUserId", "isPrimaryForUserId", "md5", "sha256") SELECT "email", "forUserId", "isPrimaryForUserId", "md5", "sha256" FROM "EmailHashes"; +INSERT INTO "new_EmailHashes" ("forUserId", "md5", "sha256") SELECT "forUserId", "md5", "sha256" FROM "EmailHashes"; DROP TABLE "EmailHashes"; ALTER TABLE "new_EmailHashes" RENAME TO "EmailHashes"; CREATE UNIQUE INDEX "EmailHashes_email_key" ON "EmailHashes"("email"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e86c2d6..759db7c 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -57,7 +57,7 @@ model EmailHashes { forUserId String user User @relation(fields: [forUserId], references: [userId]) - email String @unique @default("unknown:${uuid()}") + email String @unique @default(uuid()) sha256 Bytes md5 Bytes