proc-gen equipment drops from monsters can be picked up
[sketchy-heroes.git] / prisma / migrations / 20220318060910_id_on_monster_biome / migration.sql
1 /*
2   Warnings:
3
4   - You are about to drop the column `dropRate` on the `Monster` table. All the data in the column will be lost.
5   - The primary key for the `MonsterBiome` table will be changed. If it partially fails, the table could be left without primary key constraint.
6   - A unique constraint covering the columns `[monsterId,biome]` on the table `MonsterBiome` will be added. If there are existing duplicate values, this will fail.
7   - The required column `id` was added to the `MonsterBiome` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required.
8
9 */
10 -- AlterTable
11 ALTER TABLE "Monster" DROP COLUMN "dropRate";
12
13 -- AlterTable
14 ALTER TABLE "MonsterBiome" DROP CONSTRAINT "MonsterBiome_pkey",
15 ADD COLUMN     "dropRate" DECIMAL(65,30) NOT NULL DEFAULT 0.1,
16 ADD COLUMN     "id" UUID NOT NULL,
17 ADD CONSTRAINT "MonsterBiome_pkey" PRIMARY KEY ("id");
18
19 -- CreateTable
20 CREATE TABLE "LootTable" (
21     "monsterBiomeId" UUID NOT NULL,
22     "itemId" UUID NOT NULL,
23     "dropRate" DECIMAL(65,30) NOT NULL,
24
25     CONSTRAINT "LootTable_pkey" PRIMARY KEY ("monsterBiomeId","itemId")
26 );
27
28 -- CreateIndex
29 CREATE UNIQUE INDEX "MonsterBiome_monsterId_biome_key" ON "MonsterBiome"("monsterId", "biome");
30
31 -- AddForeignKey
32 ALTER TABLE "LootTable" ADD CONSTRAINT "LootTable_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "Item"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
33
34 -- AddForeignKey
35 ALTER TABLE "LootTable" ADD CONSTRAINT "LootTable_monsterBiomeId_fkey" FOREIGN KEY ("monsterBiomeId") REFERENCES "MonsterBiome"("id") ON DELETE RESTRICT ON UPDATE CASCADE;