code refractor

This commit is contained in:
2024-05-05 02:58:36 +02:00
parent 329c6597be
commit 56ae410fae
15 changed files with 225 additions and 148 deletions

View File

@ -1,9 +0,0 @@
-- CreateTable
CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"email" TEXT NOT NULL,
"name" TEXT
);
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

View File

@ -1,22 +0,0 @@
/*
Warnings:
- You are about to drop the column `email` on the `User` table. All the data in the column will be lost.
- You are about to drop the column `name` on the `User` table. All the data in the column will be lost.
- Added the required column `password` to the `User` table without a default value. This is not possible if the table is not empty.
- Added the required column `username` to the `User` table without a default value. This is not possible if the table is not empty.
*/
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"username" TEXT NOT NULL,
"password" TEXT NOT NULL
);
INSERT INTO "new_User" ("id") SELECT "id" FROM "User";
DROP TABLE "User";
ALTER TABLE "new_User" RENAME TO "User";
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;

View File

@ -0,0 +1,42 @@
-- CreateTable
CREATE TABLE `User` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`username` VARCHAR(191) NOT NULL,
`password` VARCHAR(191) NOT NULL,
`position_x` INTEGER NOT NULL,
`position_y` INTEGER NOT NULL,
`rotation` INTEGER NOT NULL,
`mapId` INTEGER NULL,
UNIQUE INDEX `User_username_key`(`username`),
UNIQUE INDEX `User_mapId_key`(`mapId`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Map` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL,
`tiles` VARCHAR(191) NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Chatlogs` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`userId` INTEGER NOT NULL,
`message` VARCHAR(191) NOT NULL,
`mapId` INTEGER NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `User` ADD CONSTRAINT `User_mapId_fkey` FOREIGN KEY (`mapId`) REFERENCES `Map`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Chatlogs` ADD CONSTRAINT `Chatlogs_mapId_fkey` FOREIGN KEY (`mapId`) REFERENCES `Map`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Chatlogs` ADD CONSTRAINT `Chatlogs_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,4 @@
-- AlterTable
ALTER TABLE `User` MODIFY `position_x` INTEGER NULL,
MODIFY `position_y` INTEGER NULL,
MODIFY `rotation` INTEGER NULL;

View File

@ -0,0 +1,12 @@
/*
Warnings:
- You are about to alter the column `tiles` on the `Map` table. The data in that column could be lost. The data in that column will be cast from `VarChar(191)` to `Json`.
- Added the required column `height` to the `Map` table without a default value. This is not possible if the table is not empty.
- Added the required column `width` to the `Map` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE `Map` ADD COLUMN `height` INTEGER NOT NULL,
ADD COLUMN `width` INTEGER NOT NULL,
MODIFY `tiles` JSON NOT NULL;

View File

@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "sqlite"
provider = "mysql"