-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prisma: add prizes and battles migrations
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
libs/prisma/src/schemas/migrations/20240815045215_prizes_and_battles_1/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the `BattleRecord` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `UserExperience` table. If the table is not empty, all the data it contains will be lost. | ||
*/ | ||
-- CreateEnum | ||
CREATE TYPE "ActivationCodeType" AS ENUM ('STEAM'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "PrizeStatus" AS ENUM ('PENDING', 'ACTIVE', 'REDEEMED', 'EXPIRED'); | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "ActivationCode" DROP CONSTRAINT "ActivationCode_itemId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "BattleRecord" DROP CONSTRAINT "BattleRecord_battleId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "UserExperience" DROP CONSTRAINT "UserExperience_userId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "ActivationCode" ADD COLUMN "imageUrl" TEXT NOT NULL DEFAULT '', | ||
ADD COLUMN "type" "ActivationCodeType" NOT NULL DEFAULT 'STEAM', | ||
ALTER COLUMN "itemId" DROP NOT NULL; | ||
|
||
-- AlterTable | ||
ALTER TABLE "BattleParticipation" ADD COLUMN "mvp" "MvpReason"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "User" ADD COLUMN "experience" INTEGER NOT NULL DEFAULT 0; | ||
|
||
-- DropTable | ||
DROP TABLE "BattleRecord"; | ||
|
||
-- DropTable | ||
DROP TABLE "UserExperience"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "Prize" ( | ||
"id" SERIAL NOT NULL, | ||
"status" "PrizeStatus" NOT NULL DEFAULT 'PENDING', | ||
"discount" DOUBLE PRECISION NOT NULL DEFAULT 0, | ||
"purchasedAt" TIMESTAMP(3), | ||
"userId" TEXT, | ||
"value" INTEGER NOT NULL, | ||
"codeId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Prize_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Prize_codeId_key" ON "Prize"("codeId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ActivationCode" ADD CONSTRAINT "ActivationCode_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "Item"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Prize" ADD CONSTRAINT "Prize_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Prize" ADD CONSTRAINT "Prize_codeId_fkey" FOREIGN KEY ("codeId") REFERENCES "ActivationCode"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
2 changes: 2 additions & 0 deletions
2
libs/prisma/src/schemas/migrations/20240815045324_prizes_and_battles_2/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterEnum | ||
ALTER TYPE "NotificationType" ADD VALUE 'PRIZE'; |