generated from kir-dev/next-nest-template
-
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 #2 from kir-dev/feature1/add-schema
Done schema creation
- Loading branch information
Showing
8 changed files
with
257 additions
and
37 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
79 changes: 79 additions & 0 deletions
79
apps/backend/prisma/migrations/20240504190930_init_db/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,79 @@ | ||
-- CreateEnum | ||
CREATE TYPE "Priority" AS ENUM ('LOW', 'MEDIUM', 'HIGH'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "Status" AS ENUM ('OPEN', 'IN_PROGRESS', 'DONE'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" SERIAL NOT NULL, | ||
"authSchId" TEXT NOT NULL, | ||
"email" TEXT NOT NULL, | ||
"profilePicture" TEXT, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Group" ( | ||
"id" SERIAL NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"description" TEXT, | ||
|
||
CONSTRAINT "Group_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Event" ( | ||
"id" SERIAL NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"description" TEXT, | ||
"date" TIMESTAMP(3) NOT NULL, | ||
"location" TEXT NOT NULL, | ||
"categoryId" INTEGER NOT NULL, | ||
"priority" "Priority" NOT NULL, | ||
"status" "Status" NOT NULL, | ||
"ownerUserId" INTEGER, | ||
"ownerGroupId" INTEGER, | ||
|
||
CONSTRAINT "Event_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Category" ( | ||
"id" SERIAL NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"description" TEXT, | ||
|
||
CONSTRAINT "Category_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_GroupToUser" ( | ||
"A" INTEGER NOT NULL, | ||
"B" INTEGER NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_GroupToUser_AB_unique" ON "_GroupToUser"("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_GroupToUser_B_index" ON "_GroupToUser"("B"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Event" ADD CONSTRAINT "Event_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "Category"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Event" ADD CONSTRAINT "Event_ownerUserId_fkey" FOREIGN KEY ("ownerUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Event" ADD CONSTRAINT "Event_ownerGroupId_fkey" FOREIGN KEY ("ownerGroupId") REFERENCES "Group"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_GroupToUser" ADD CONSTRAINT "_GroupToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Group"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_GroupToUser" ADD CONSTRAINT "_GroupToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
37 changes: 37 additions & 0 deletions
37
apps/backend/prisma/migrations/20240504195638_adds_role_for_group_users/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,37 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `location` on the `Event` table. All the data in the column will be lost. | ||
- You are about to drop the `_GroupToUser` table. If the table is not empty, all the data it contains will be lost. | ||
*/ | ||
-- CreateEnum | ||
CREATE TYPE "Role" AS ENUM ('ADMIN', 'USER'); | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "_GroupToUser" DROP CONSTRAINT "_GroupToUser_A_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "_GroupToUser" DROP CONSTRAINT "_GroupToUser_B_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Event" DROP COLUMN "location", | ||
ALTER COLUMN "date" SET DEFAULT CURRENT_TIMESTAMP; | ||
|
||
-- DropTable | ||
DROP TABLE "_GroupToUser"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "GroupMembers" ( | ||
"groupId" INTEGER NOT NULL, | ||
"userId" INTEGER NOT NULL, | ||
"role" "Role" NOT NULL DEFAULT 'USER', | ||
|
||
CONSTRAINT "GroupMembers_pkey" PRIMARY KEY ("groupId","userId") | ||
); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "GroupMembers" ADD CONSTRAINT "GroupMembers_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "Group"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "GroupMembers" ADD CONSTRAINT "GroupMembers_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
19 changes: 19 additions & 0 deletions
19
apps/backend/prisma/migrations/20240504195717_event_has_only_one_owner/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,19 @@ | ||
-- DropForeignKey | ||
ALTER TABLE "Event" DROP CONSTRAINT "Event_ownerGroupId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "Event" DROP CONSTRAINT "Event_ownerUserId_fkey"; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Event" ADD CONSTRAINT "Event_ownerUserId_fkey" FOREIGN KEY ("ownerUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Event" ADD CONSTRAINT "Event_ownerGroupId_fkey" FOREIGN KEY ("ownerGroupId") REFERENCES "Group"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- The Event table should have only one owner, either a user or a group. The ownerUserId and ownerGroupId columns should be mutually exclusive. If an event has an ownerUserId, it should not have an ownerGroupId, and vice versa. | ||
ALTER TABLE IF EXISTS "Event" | ||
ADD CONSTRAINT only_one_owner | ||
CHECK ( | ||
("ownerUserId" IS NOT NULL AND "ownerGroupId" IS NULL) OR | ||
("ownerUserId" IS NULL AND "ownerGroupId" IS NOT NULL) | ||
); |
29 changes: 29 additions & 0 deletions
29
apps/backend/prisma/migrations/20240505100416_edit_schame_based_1_issue/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,29 @@ | ||
/* | ||
Warnings: | ||
- The values [OPEN] on the enum `Status` will be removed. If these variants are still used in the database, this will fail. | ||
- You are about to drop the column `date` on the `Event` table. All the data in the column will be lost. | ||
- Added the required column `color` to the `Category` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- AlterEnum | ||
ALTER TYPE "Priority" ADD VALUE 'URGENT'; | ||
|
||
-- AlterEnum | ||
BEGIN; | ||
ALTER TYPE "Status" ADD VALUE 'WAITING_FOR_REVIEW'; | ||
ALTER TYPE "Status" RENAME VALUE 'OPEN' TO 'NOT_STARTED'; | ||
COMMIT; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Category" ADD COLUMN "color" TEXT NOT NULL DEFAULT '#000000'; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Event" DROP COLUMN "date", | ||
ADD COLUMN "endDate" DATE, | ||
ADD COLUMN "endTime" TIME, | ||
ADD COLUMN "location" TEXT, | ||
ADD COLUMN "startDate" DATE NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
ADD COLUMN "startTime" TIME, | ||
ALTER COLUMN "priority" SET DEFAULT 'MEDIUM', | ||
ALTER COLUMN "status" SET DEFAULT 'NOT_STARTED'; |
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,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
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 |
---|---|---|
|
@@ -298,6 +298,11 @@ | |
path-to-regexp "3.2.0" | ||
tslib "2.6.2" | ||
|
||
"@nestjs/mapped-types@*": | ||
version "2.0.5" | ||
resolved "https://registry.yarnpkg.com/@nestjs/mapped-types/-/mapped-types-2.0.5.tgz#485d6b44e19779c98d04e52bd1d2bcc7001df0ea" | ||
integrity sha512-bSJv4pd6EY99NX9CjBIyn4TVDoSit82DUZlL4I3bqNfy5Gt+gXTa86i3I/i0iIV9P4hntcGM5GyO+FhZAhxtyg== | ||
|
||
"@nestjs/platform-express@^10.3.8": | ||
version "10.3.8" | ||
resolved "https://registry.yarnpkg.com/@nestjs/platform-express/-/platform-express-10.3.8.tgz#e8458cb1d1931589d5438d7b6075aa31634417d3" | ||
|
@@ -1156,11 +1161,6 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: | |
dependencies: | ||
color-convert "^2.0.1" | ||
|
||
ansi-styles@^6.1.0: | ||
version "6.2.1" | ||
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" | ||
integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== | ||
|
||
any-promise@^1.0.0: | ||
version "1.3.0" | ||
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" | ||
|
@@ -1923,11 +1923,6 @@ doctrine@^3.0.0: | |
dependencies: | ||
esutils "^2.0.2" | ||
|
||
eastasianwidth@^0.2.0: | ||
version "0.2.0" | ||
resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" | ||
integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== | ||
|
||
[email protected]: | ||
version "1.1.1" | ||
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" | ||
|
@@ -4727,7 +4722,7 @@ streamsearch@^1.1.0: | |
resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764" | ||
integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== | ||
|
||
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.2.0, string-width@^4.2.3: | ||
"string-width-cjs@npm:string-width@^4.2.0": | ||
version "4.2.3" | ||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" | ||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== | ||
|
@@ -4736,7 +4731,7 @@ streamsearch@^1.1.0: | |
is-fullwidth-code-point "^3.0.0" | ||
strip-ansi "^6.0.1" | ||
|
||
string-width@^4.1.0: | ||
string-width@4.1.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3, string-width@^5.1.2: | ||
version "4.1.0" | ||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.1.0.tgz#ba846d1daa97c3c596155308063e075ed1c99aff" | ||
integrity sha512-NrX+1dVVh+6Y9dnQ19pR0pP4FiEIlUvdTGn8pw6CKTNq5sgib2nIhmUNT5TAmhWmvKr3WcxBcP3E8nWezuipuQ== | ||
|
@@ -4745,15 +4740,6 @@ string-width@^4.1.0: | |
is-fullwidth-code-point "^3.0.0" | ||
strip-ansi "^5.2.0" | ||
|
||
string-width@^5.0.1, string-width@^5.1.2: | ||
version "5.1.2" | ||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" | ||
integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== | ||
dependencies: | ||
eastasianwidth "^0.2.0" | ||
emoji-regex "^9.2.2" | ||
strip-ansi "^7.0.1" | ||
|
||
string.prototype.matchall@^4.0.10: | ||
version "4.0.11" | ||
resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.11.tgz#1092a72c59268d2abaad76582dccc687c0297e0a" | ||
|
@@ -4814,7 +4800,7 @@ string_decoder@~1.1.1: | |
dependencies: | ||
safe-buffer "~5.1.0" | ||
|
||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: | ||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1": | ||
version "6.0.1" | ||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" | ||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== | ||
|
@@ -4828,6 +4814,13 @@ strip-ansi@^5.2.0: | |
dependencies: | ||
ansi-regex "^4.1.0" | ||
|
||
strip-ansi@^6.0.0, strip-ansi@^6.0.1: | ||
version "6.0.1" | ||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" | ||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== | ||
dependencies: | ||
ansi-regex "^5.0.1" | ||
|
||
strip-ansi@^7.0.1: | ||
version "7.1.0" | ||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" | ||
|
@@ -5431,24 +5424,15 @@ which@^2.0.1: | |
string-width "^4.1.0" | ||
strip-ansi "^6.0.0" | ||
|
||
wrap-ansi@^6.0.1, wrap-ansi@^6.2.0: | ||
version "6.2.0" | ||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" | ||
integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA== | ||
wrap-ansi@7.0.0, wrap-ansi@^6.0.1, wrap-ansi@^6.2.0, wrap-ansi@^8.1.0: | ||
version "7.0.0" | ||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" | ||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== | ||
dependencies: | ||
ansi-styles "^4.0.0" | ||
string-width "^4.1.0" | ||
strip-ansi "^6.0.0" | ||
|
||
wrap-ansi@^8.1.0: | ||
version "8.1.0" | ||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" | ||
integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== | ||
dependencies: | ||
ansi-styles "^6.1.0" | ||
string-width "^5.0.1" | ||
strip-ansi "^7.0.1" | ||
|
||
wrappy@1: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" | ||
|