X-Git-Url: https://git.xangelo.ca/?p=sketchy-heroes.git;a=blobdiff_plain;f=prisma%2Fmigrations%2F20220318060910_id_on_monster_biome%2Fmigration.sql;fp=prisma%2Fmigrations%2F20220318060910_id_on_monster_biome%2Fmigration.sql;h=777ee4c9e1edf2b8953c24b3b39e18e77c4f29cd;hp=0000000000000000000000000000000000000000;hb=b5d3cc37fddebff8dcdf1ef0cdd3a626811f14d3;hpb=20dc560a75cfd6ddc8a66956315a30001779ec24 diff --git a/prisma/migrations/20220318060910_id_on_monster_biome/migration.sql b/prisma/migrations/20220318060910_id_on_monster_biome/migration.sql new file mode 100644 index 0000000..777ee4c --- /dev/null +++ b/prisma/migrations/20220318060910_id_on_monster_biome/migration.sql @@ -0,0 +1,35 @@ +/* + Warnings: + + - You are about to drop the column `dropRate` on the `Monster` table. All the data in the column will be lost. + - The primary key for the `MonsterBiome` table will be changed. If it partially fails, the table could be left without primary key constraint. + - A unique constraint covering the columns `[monsterId,biome]` on the table `MonsterBiome` will be added. If there are existing duplicate values, this will fail. + - 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. + +*/ +-- AlterTable +ALTER TABLE "Monster" DROP COLUMN "dropRate"; + +-- AlterTable +ALTER TABLE "MonsterBiome" DROP CONSTRAINT "MonsterBiome_pkey", +ADD COLUMN "dropRate" DECIMAL(65,30) NOT NULL DEFAULT 0.1, +ADD COLUMN "id" UUID NOT NULL, +ADD CONSTRAINT "MonsterBiome_pkey" PRIMARY KEY ("id"); + +-- CreateTable +CREATE TABLE "LootTable" ( + "monsterBiomeId" UUID NOT NULL, + "itemId" UUID NOT NULL, + "dropRate" DECIMAL(65,30) NOT NULL, + + CONSTRAINT "LootTable_pkey" PRIMARY KEY ("monsterBiomeId","itemId") +); + +-- CreateIndex +CREATE UNIQUE INDEX "MonsterBiome_monsterId_biome_key" ON "MonsterBiome"("monsterId", "biome"); + +-- AddForeignKey +ALTER TABLE "LootTable" ADD CONSTRAINT "LootTable_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "Item"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "LootTable" ADD CONSTRAINT "LootTable_monsterBiomeId_fkey" FOREIGN KEY ("monsterBiomeId") REFERENCES "MonsterBiome"("id") ON DELETE RESTRICT ON UPDATE CASCADE;