2024-05-09 22:03:21 +02:00

47 lines
1.7 KiB
SQL

/*
Warnings:
- You are about to drop the column `mapId` on the `Chatlogs` table. All the data in the column will be lost.
- You are about to drop the column `mapId` on the `User` table. All the data in the column will be lost.
- You are about to drop the `Map` table. If the table is not empty, all the data it contains will be lost.
- A unique constraint covering the columns `[zoneId]` on the table `User` will be added. If there are existing duplicate values, this will fail.
- Added the required column `zoneId` to the `Chatlogs` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE `Chatlogs` DROP FOREIGN KEY `Chatlogs_mapId_fkey`;
-- DropForeignKey
ALTER TABLE `User` DROP FOREIGN KEY `User_mapId_fkey`;
-- AlterTable
ALTER TABLE `Chatlogs` DROP COLUMN `mapId`,
ADD COLUMN `zoneId` INTEGER NOT NULL;
-- AlterTable
ALTER TABLE `User` DROP COLUMN `mapId`,
ADD COLUMN `zoneId` INTEGER NULL;
-- DropTable
DROP TABLE `Map`;
-- CreateTable
CREATE TABLE `Zone` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL,
`width` INTEGER NOT NULL,
`height` INTEGER NOT NULL,
`tiles` JSON NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateIndex
CREATE UNIQUE INDEX `User_zoneId_key` ON `User`(`zoneId`);
-- AddForeignKey
ALTER TABLE `User` ADD CONSTRAINT `User_zoneId_fkey` FOREIGN KEY (`zoneId`) REFERENCES `Zone`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Chatlogs` ADD CONSTRAINT `Chatlogs_zoneId_fkey` FOREIGN KEY (`zoneId`) REFERENCES `Zone`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;