X-Git-Url: https://git.xangelo.ca/?p=sketchy-heroes.git;a=blobdiff_plain;f=prisma%2Fmigrations%2F20220315145640_relation_unrename%2Fmigration.sql;fp=prisma%2Fmigrations%2F20220315145640_relation_unrename%2Fmigration.sql;h=1e6c5cef11bde989bab8505aee6eb4b5f20d62c7;hp=0000000000000000000000000000000000000000;hb=7aa7248bc4f3f59a002beb98fa889a9da3c25866;hpb=9cec2c639563092ed050716db1e7e4657f937bf5 diff --git a/prisma/migrations/20220315145640_relation_unrename/migration.sql b/prisma/migrations/20220315145640_relation_unrename/migration.sql new file mode 100644 index 0000000..1e6c5ce --- /dev/null +++ b/prisma/migrations/20220315145640_relation_unrename/migration.sql @@ -0,0 +1,128 @@ +/* + Warnings: + + - You are about to drop the `auth_token` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `monster` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `monster_biome` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `player` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `zone_biome` table. If the table is not empty, all the data it contains will be lost. + +*/ +-- CreateEnum +CREATE TYPE "Biome" AS ENUM ('PLAINS', 'FIELDS', 'WOODLAND', 'FOREST', 'SWAMP', 'TUNDRA', 'MOUNTAIN', 'CAVE', 'DESERT'); + +-- CreateEnum +CREATE TYPE "MonsterType" AS ENUM ('BEAST', 'FLYING', 'HUMANOID', 'GIANT', 'INSECT', 'UNDEAD'); + +-- DropForeignKey +ALTER TABLE "auth_token" DROP CONSTRAINT "auth_token_playerId_fkey"; + +-- DropForeignKey +ALTER TABLE "monster_biome" DROP CONSTRAINT "monster_biome_monsterId_fkey"; + +-- DropForeignKey +ALTER TABLE "player" DROP CONSTRAINT "player_zoneBiomeId_fkey"; + +-- DropTable +DROP TABLE "auth_token"; + +-- DropTable +DROP TABLE "monster"; + +-- DropTable +DROP TABLE "monster_biome"; + +-- DropTable +DROP TABLE "player"; + +-- DropTable +DROP TABLE "zone_biome"; + +-- DropEnum +DROP TYPE "biome"; + +-- DropEnum +DROP TYPE "monster_type"; + +-- CreateTable +CREATE TABLE "ZoneBiomes" ( + "id" UUID NOT NULL, + "playerId" UUID, + "biome" "Biome" NOT NULL, + "maxSteps" INTEGER NOT NULL DEFAULT 500, + + CONSTRAINT "ZoneBiomes_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Player" ( + "id" UUID NOT NULL, + "username" TEXT NOT NULL, + "password" TEXT NOT NULL, + "level" INTEGER NOT NULL DEFAULT 1, + "currency" INTEGER NOT NULL DEFAULT 0, + "pow" INTEGER NOT NULL, + "zest" INTEGER NOT NULL, + "woosh" INTEGER NOT NULL, + "luck" INTEGER NOT NULL, + "aha" INTEGER NOT NULL, + "wow" INTEGER NOT NULL, + "stamina" INTEGER NOT NULL, + "hp" INTEGER NOT NULL, + "statPoints" INTEGER NOT NULL DEFAULT 0, + "exp" INTEGER NOT NULL DEFAULT 0, + "zoneBiomeId" UUID NOT NULL, + "steps" INTEGER NOT NULL DEFAULT 0, + + CONSTRAINT "Player_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "AuthToken" ( + "token" UUID NOT NULL, + "playerId" UUID NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3), + + CONSTRAINT "AuthToken_pkey" PRIMARY KEY ("token") +); + +-- CreateTable +CREATE TABLE "Monster" ( + "id" UUID NOT NULL, + "name" TEXT NOT NULL, + "monsterType" "MonsterType"[], + + CONSTRAINT "Monster_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "MonsterBiome" ( + "monsterId" UUID NOT NULL, + "biome" "Biome" NOT NULL, + "weight" DECIMAL(65,30) NOT NULL, + "time" JSONB NOT NULL, + + CONSTRAINT "MonsterBiome_pkey" PRIMARY KEY ("monsterId","biome") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Player_username_key" ON "Player"("username"); + +-- CreateIndex +CREATE UNIQUE INDEX "Player_zoneBiomeId_key" ON "Player"("zoneBiomeId"); + +-- CreateIndex +CREATE UNIQUE INDEX "AuthToken_playerId_key" ON "AuthToken"("playerId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Monster_name_key" ON "Monster"("name"); + +-- AddForeignKey +ALTER TABLE "Player" ADD CONSTRAINT "Player_zoneBiomeId_fkey" FOREIGN KEY ("zoneBiomeId") REFERENCES "ZoneBiomes"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "AuthToken" ADD CONSTRAINT "AuthToken_playerId_fkey" FOREIGN KEY ("playerId") REFERENCES "Player"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "MonsterBiome" ADD CONSTRAINT "MonsterBiome_monsterId_fkey" FOREIGN KEY ("monsterId") REFERENCES "Monster"("id") ON DELETE RESTRICT ON UPDATE CASCADE;