exploring/fighting is functional
[sketchy-heroes.git] / prisma / migrations / 20220315145339_relation_rename / migration.sql
1 /*
2   Warnings:
3
4   - You are about to drop the `AuthToken` table. If the table is not empty, all the data it contains will be lost.
5   - You are about to drop the `Monster` table. If the table is not empty, all the data it contains will be lost.
6   - You are about to drop the `MonsterBiome` table. If the table is not empty, all the data it contains will be lost.
7   - You are about to drop the `Player` table. If the table is not empty, all the data it contains will be lost.
8   - You are about to drop the `ZoneBiomes` table. If the table is not empty, all the data it contains will be lost.
9
10 */
11 -- CreateEnum
12 CREATE TYPE "biome" AS ENUM ('PLAINS', 'FIELDS', 'WOODLAND', 'FOREST', 'SWAMP', 'TUNDRA', 'MOUNTAIN', 'CAVE', 'DESERT');
13
14 -- CreateEnum
15 CREATE TYPE "monster_type" AS ENUM ('BEAST', 'FLYING', 'HUMANOID', 'GIANT', 'INSECT', 'UNDEAD');
16
17 -- DropForeignKey
18 ALTER TABLE "AuthToken" DROP CONSTRAINT "AuthToken_playerId_fkey";
19
20 -- DropForeignKey
21 ALTER TABLE "MonsterBiome" DROP CONSTRAINT "MonsterBiome_monsterId_fkey";
22
23 -- DropForeignKey
24 ALTER TABLE "Player" DROP CONSTRAINT "Player_zoneBiomeId_fkey";
25
26 -- DropTable
27 DROP TABLE "AuthToken";
28
29 -- DropTable
30 DROP TABLE "Monster";
31
32 -- DropTable
33 DROP TABLE "MonsterBiome";
34
35 -- DropTable
36 DROP TABLE "Player";
37
38 -- DropTable
39 DROP TABLE "ZoneBiomes";
40
41 -- DropEnum
42 DROP TYPE "Biome";
43
44 -- DropEnum
45 DROP TYPE "MonsterType";
46
47 -- CreateTable
48 CREATE TABLE "zone_biome" (
49     "id" UUID NOT NULL,
50     "playerId" UUID,
51     "biome" "biome" NOT NULL,
52     "maxSteps" INTEGER NOT NULL DEFAULT 500,
53
54     CONSTRAINT "zone_biome_pkey" PRIMARY KEY ("id")
55 );
56
57 -- CreateTable
58 CREATE TABLE "player" (
59     "id" UUID NOT NULL,
60     "username" TEXT NOT NULL,
61     "password" TEXT NOT NULL,
62     "level" INTEGER NOT NULL DEFAULT 1,
63     "currency" INTEGER NOT NULL DEFAULT 0,
64     "pow" INTEGER NOT NULL,
65     "zest" INTEGER NOT NULL,
66     "woosh" INTEGER NOT NULL,
67     "luck" INTEGER NOT NULL,
68     "aha" INTEGER NOT NULL,
69     "wow" INTEGER NOT NULL,
70     "stamina" INTEGER NOT NULL,
71     "hp" INTEGER NOT NULL,
72     "statPoints" INTEGER NOT NULL DEFAULT 0,
73     "exp" INTEGER NOT NULL DEFAULT 0,
74     "zoneBiomeId" UUID NOT NULL,
75     "steps" INTEGER NOT NULL DEFAULT 0,
76
77     CONSTRAINT "player_pkey" PRIMARY KEY ("id")
78 );
79
80 -- CreateTable
81 CREATE TABLE "auth_token" (
82     "token" UUID NOT NULL,
83     "playerId" UUID NOT NULL,
84     "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
85     "updatedAt" TIMESTAMP(3),
86
87     CONSTRAINT "auth_token_pkey" PRIMARY KEY ("token")
88 );
89
90 -- CreateTable
91 CREATE TABLE "monster" (
92     "id" UUID NOT NULL,
93     "name" TEXT NOT NULL,
94     "monsterType" "monster_type"[],
95
96     CONSTRAINT "monster_pkey" PRIMARY KEY ("id")
97 );
98
99 -- CreateTable
100 CREATE TABLE "monster_biome" (
101     "monsterId" UUID NOT NULL,
102     "biome" "biome" NOT NULL,
103     "weight" DECIMAL(65,30) NOT NULL,
104     "time" JSONB NOT NULL,
105
106     CONSTRAINT "monster_biome_pkey" PRIMARY KEY ("monsterId","biome")
107 );
108
109 -- CreateIndex
110 CREATE UNIQUE INDEX "player_username_key" ON "player"("username");
111
112 -- CreateIndex
113 CREATE UNIQUE INDEX "player_zoneBiomeId_key" ON "player"("zoneBiomeId");
114
115 -- CreateIndex
116 CREATE UNIQUE INDEX "auth_token_playerId_key" ON "auth_token"("playerId");
117
118 -- CreateIndex
119 CREATE UNIQUE INDEX "monster_name_key" ON "monster"("name");
120
121 -- AddForeignKey
122 ALTER TABLE "player" ADD CONSTRAINT "player_zoneBiomeId_fkey" FOREIGN KEY ("zoneBiomeId") REFERENCES "zone_biome"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
123
124 -- AddForeignKey
125 ALTER TABLE "auth_token" ADD CONSTRAINT "auth_token_playerId_fkey" FOREIGN KEY ("playerId") REFERENCES "player"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
126
127 -- AddForeignKey
128 ALTER TABLE "monster_biome" ADD CONSTRAINT "monster_biome_monsterId_fkey" FOREIGN KEY ("monsterId") REFERENCES "monster"("id") ON DELETE RESTRICT ON UPDATE CASCADE;