discord-ticket-bot/prisma/migrations/20240805230451_fixes/migration.sql

59 lines
3.1 KiB
MySQL
Raw Permalink Normal View History

/*
Warnings:
- You are about to drop the column `tickerRoleId` on the `Role` table. All the data in the column will be lost.
- You are about to drop the column `worlLoadStatus` on the `Settings` table. All the data in the column will be lost.
- The primary key for the `Ticket` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `Ticket` table. All the data in the column will be lost.
- The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `User` table. All the data in the column will be lost.
- Added the required column `ticketRoleId` to the `Role` table without a default value. This is not possible if the table is not empty.
- Added the required column `workLoadStatus` to the `Settings` table without a default value. This is not possible if the table is not empty.
- Made the column `userId` on table `Ticket` required. This step will fail if there are existing NULL values in that column.
*/
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Role" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"welcomeRoleId" TEXT NOT NULL,
"ticketRoleId" TEXT NOT NULL
);
INSERT INTO "new_Role" ("id", "welcomeRoleId") SELECT "id", "welcomeRoleId" FROM "Role";
DROP TABLE "Role";
ALTER TABLE "new_Role" RENAME TO "Role";
CREATE TABLE "new_Settings" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"welcomeChannelId" TEXT NOT NULL,
"feedbackChannelId" TEXT NOT NULL,
"portfolioChannelId" TEXT NOT NULL,
"makeAnOrderChannelId" TEXT NOT NULL,
"priceChannelId" TEXT NOT NULL,
"workLoadChannelId" TEXT NOT NULL,
"workLoadStatus" TEXT NOT NULL,
"workloadMessageId" TEXT NOT NULL
);
INSERT INTO "new_Settings" ("feedbackChannelId", "id", "makeAnOrderChannelId", "portfolioChannelId", "priceChannelId", "welcomeChannelId", "workLoadChannelId", "workloadMessageId") SELECT "feedbackChannelId", "id", "makeAnOrderChannelId", "portfolioChannelId", "priceChannelId", "welcomeChannelId", "workLoadChannelId", "workloadMessageId" FROM "Settings";
DROP TABLE "Settings";
ALTER TABLE "new_Settings" RENAME TO "Settings";
CREATE TABLE "new_Ticket" (
"channelId" TEXT NOT NULL,
"closed" BOOLEAN NOT NULL,
"userId" TEXT NOT NULL,
CONSTRAINT "Ticket_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("discordId") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_Ticket" ("channelId", "closed", "userId") SELECT "channelId", "closed", "userId" FROM "Ticket";
DROP TABLE "Ticket";
ALTER TABLE "new_Ticket" RENAME TO "Ticket";
CREATE UNIQUE INDEX "Ticket_channelId_key" ON "Ticket"("channelId");
CREATE TABLE "new_User" (
"discordId" TEXT NOT NULL
);
INSERT INTO "new_User" ("discordId") SELECT "discordId" FROM "User";
DROP TABLE "User";
ALTER TABLE "new_User" RENAME TO "User";
CREATE UNIQUE INDEX "User_discordId_key" ON "User"("discordId");
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;