forked from epicweb-dev/epic-stack
-
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.
- Loading branch information
1 parent
88ee7cf
commit f3706b3
Showing
5 changed files
with
115 additions
and
94 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 |
---|---|---|
@@ -1,7 +1,18 @@ | ||
Copyright © 2023 Kent C. Dodds | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the “Software”), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,146 @@ | ||
-- CreateTable | ||
CREATE TABLE "File" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"blob" BLOB NOT NULL, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL | ||
); | ||
CREATE TABLE | ||
"File" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"blob" BLOB NOT NULL, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Image" ( | ||
"fileId" TEXT NOT NULL, | ||
"contentType" TEXT NOT NULL, | ||
"altText" TEXT, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
CONSTRAINT "Image_fileId_fkey" FOREIGN KEY ("fileId") REFERENCES "File" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
CREATE TABLE | ||
"Image" ( | ||
"fileId" TEXT NOT NULL, | ||
"contentType" TEXT NOT NULL, | ||
"altText" TEXT, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
CONSTRAINT "Image_fileId_fkey" FOREIGN KEY ("fileId") REFERENCES "File" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Role" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"name" TEXT NOT NULL, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL | ||
); | ||
CREATE TABLE | ||
"Role" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"name" TEXT NOT NULL, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Permission" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"name" TEXT NOT NULL, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL | ||
); | ||
CREATE TABLE | ||
"Permission" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"name" TEXT NOT NULL, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"email" TEXT NOT NULL, | ||
"username" TEXT NOT NULL, | ||
"name" TEXT, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
"imageId" TEXT, | ||
CONSTRAINT "User_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "Image" ("fileId") ON DELETE SET NULL ON UPDATE CASCADE | ||
); | ||
CREATE TABLE | ||
"User" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"email" TEXT NOT NULL, | ||
"username" TEXT NOT NULL, | ||
"name" TEXT, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
"imageId" TEXT, | ||
CONSTRAINT "User_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "Image" ("fileId") ON DELETE SET NULL ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Password" ( | ||
"hash" TEXT NOT NULL, | ||
"userId" TEXT NOT NULL, | ||
CONSTRAINT "Password_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
CREATE TABLE | ||
"Password" ( | ||
"hash" TEXT NOT NULL, | ||
"userId" TEXT NOT NULL, | ||
CONSTRAINT "Password_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Session" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"userId" TEXT NOT NULL, | ||
"expirationDate" DATETIME NOT NULL, | ||
CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
CREATE TABLE | ||
"Session" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"userId" TEXT NOT NULL, | ||
"expirationDate" DATETIME NOT NULL, | ||
CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Note" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"title" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
"ownerId" TEXT NOT NULL, | ||
CONSTRAINT "Note_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
CREATE TABLE | ||
"Note" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"title" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
"ownerId" TEXT NOT NULL, | ||
CONSTRAINT "Note_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_RoleToUser" ( | ||
"A" TEXT NOT NULL, | ||
"B" TEXT NOT NULL, | ||
CONSTRAINT "_RoleToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
CONSTRAINT "_RoleToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
CREATE TABLE | ||
"_RoleToUser" ( | ||
"A" TEXT NOT NULL, | ||
"B" TEXT NOT NULL, | ||
CONSTRAINT "_RoleToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
CONSTRAINT "_RoleToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_PermissionToRole" ( | ||
"A" TEXT NOT NULL, | ||
"B" TEXT NOT NULL, | ||
CONSTRAINT "_PermissionToRole_A_fkey" FOREIGN KEY ("A") REFERENCES "Permission" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
CONSTRAINT "_PermissionToRole_B_fkey" FOREIGN KEY ("B") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
CREATE TABLE | ||
"_PermissionToRole" ( | ||
"A" TEXT NOT NULL, | ||
"B" TEXT NOT NULL, | ||
CONSTRAINT "_PermissionToRole_A_fkey" FOREIGN KEY ("A") REFERENCES "Permission" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
CONSTRAINT "_PermissionToRole_B_fkey" FOREIGN KEY ("B") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "File_id_key" ON "File"("id"); | ||
CREATE UNIQUE INDEX "File_id_key" ON "File" ("id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Image_fileId_key" ON "Image"("fileId"); | ||
CREATE UNIQUE INDEX "Image_fileId_key" ON "Image" ("fileId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Role_id_key" ON "Role"("id"); | ||
CREATE UNIQUE INDEX "Role_id_key" ON "Role" ("id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Role_name_key" ON "Role"("name"); | ||
CREATE UNIQUE INDEX "Role_name_key" ON "Role" ("name"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Permission_id_key" ON "Permission"("id"); | ||
CREATE UNIQUE INDEX "Permission_id_key" ON "Permission" ("id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Permission_name_key" ON "Permission"("name"); | ||
CREATE UNIQUE INDEX "Permission_name_key" ON "Permission" ("name"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); | ||
CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
CREATE UNIQUE INDEX "User_email_key" ON "User" ("email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); | ||
CREATE UNIQUE INDEX "User_username_key" ON "User" ("username"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_imageId_key" ON "User"("imageId"); | ||
CREATE UNIQUE INDEX "User_imageId_key" ON "User" ("imageId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Password_userId_key" ON "Password"("userId"); | ||
CREATE UNIQUE INDEX "Password_userId_key" ON "Password" ("userId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Note_id_key" ON "Note"("id"); | ||
CREATE UNIQUE INDEX "Note_id_key" ON "Note" ("id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_RoleToUser_AB_unique" ON "_RoleToUser"("A", "B"); | ||
CREATE UNIQUE INDEX "_RoleToUser_AB_unique" ON "_RoleToUser" ("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_RoleToUser_B_index" ON "_RoleToUser"("B"); | ||
CREATE INDEX "_RoleToUser_B_index" ON "_RoleToUser" ("B"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_PermissionToRole_AB_unique" ON "_PermissionToRole"("A", "B"); | ||
CREATE UNIQUE INDEX "_PermissionToRole_AB_unique" ON "_PermissionToRole" ("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_PermissionToRole_B_index" ON "_PermissionToRole"("B"); | ||
CREATE INDEX "_PermissionToRole_B_index" ON "_PermissionToRole" ("B"); |