X-Git-Url: https://git.xangelo.ca/?p=sketchy-heroes.git;a=blobdiff_plain;f=prisma%2Fmigrations%2F20220317054135_create_item_config%2Fmigration.sql;fp=prisma%2Fmigrations%2F20220317054135_create_item_config%2Fmigration.sql;h=0c4b9355a722c0ab9d7172a67d151312a4b93aed;hp=0000000000000000000000000000000000000000;hb=b5d3cc37fddebff8dcdf1ef0cdd3a626811f14d3;hpb=20dc560a75cfd6ddc8a66956315a30001779ec24 diff --git a/prisma/migrations/20220317054135_create_item_config/migration.sql b/prisma/migrations/20220317054135_create_item_config/migration.sql new file mode 100644 index 0000000..0c4b935 --- /dev/null +++ b/prisma/migrations/20220317054135_create_item_config/migration.sql @@ -0,0 +1,41 @@ +-- CreateEnum +CREATE TYPE "InventoryType" AS ENUM ('HELM', 'R_SHOULDER', 'L_SHOULDER', 'TORSO', 'R_ARM', 'L_ARM', 'LEGS', 'L_FOOT', 'R_FOOT'); + +-- CreateEnum +CREATE TYPE "Rarity" AS ENUM ('COMMON', 'UNCOMMON', 'RARE'); + +-- CreateTable +CREATE TABLE "Item" ( + "id" UUID NOT NULL, + "name" TEXT NOT NULL, + "type" "InventoryType"[], + "durability" INTEGER NOT NULL DEFAULT 0, + "minLevelDrop" INTEGER NOT NULL DEFAULT 1, + "availableRarity" "Rarity"[], + "statModifiers" JSONB NOT NULL, + + CONSTRAINT "Item_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Inventory" ( + "id" UUID NOT NULL, + "playerId" UUID NOT NULL, + "itemId" UUID NOT NULL, + "maxDurability" INTEGER NOT NULL DEFAULT 1, + "currentDurability" INTEGER NOT NULL DEFAULT 1, + "type" "InventoryType"[], + "statModifiers" JSONB NOT NULL, + "stackable" BOOLEAN NOT NULL DEFAULT false, + + CONSTRAINT "Inventory_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Item_name_key" ON "Item"("name"); + +-- AddForeignKey +ALTER TABLE "Inventory" ADD CONSTRAINT "Inventory_playerId_fkey" FOREIGN KEY ("playerId") REFERENCES "Player"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Inventory" ADD CONSTRAINT "Inventory_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "Item"("id") ON DELETE RESTRICT ON UPDATE CASCADE;