diff --git a/prisma/.gitignore b/prisma/.gitignore index 03f6f26..87f333a 100644 --- a/prisma/.gitignore +++ b/prisma/.gitignore @@ -1,2 +1,2 @@ *.db -*.db-journal \ No newline at end of file +*.db-journal diff --git a/prisma/migrations/20221021150615_shoproles_model/migration.sql b/prisma/migrations/20221021150615_shoproles_model/migration.sql index 1859cc1..3d9bab2 100644 --- a/prisma/migrations/20221021150615_shoproles_model/migration.sql +++ b/prisma/migrations/20221021150615_shoproles_model/migration.sql @@ -13,4 +13,5 @@ CREATE TABLE "GuildShopRoles" ( ); -- CreateIndex -CREATE UNIQUE INDEX "GuildShopRoles_guildId_channelId_key" ON "GuildShopRoles"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_channelId_key" ON "GuildShopRoles" ("guildId", "channelId"); diff --git a/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql b/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql index 5631656..f3a4e3a 100644 --- a/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql @@ -1,11 +1,12 @@ /* - Warnings: + Warnings: - - You are about to drop the column `channelId` on the `GuildShopRoles` table. All the data in the column will be lost. - -*/ + - You are about to drop the column `channelId` on the `GuildShopRoles` table. All the data in the column will be lost. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -17,9 +18,25 @@ CREATE TABLE "new_GuildShopRoles" ( CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; diff --git a/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql b/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql index 8a3fe75..52dc513 100644 --- a/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -10,11 +11,29 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_guildId_userId_fkey" FOREIGN KEY ("guildId", "userId") REFERENCES "GuildMember" ("guildId", "userId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_guildId_userId_fkey" FOREIGN KEY ("guildId", + "userId") REFERENCES "GuildMember" ("guildId", + "userId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; diff --git a/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql b/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql index 88d1d66..555cf58 100644 --- a/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -10,11 +11,29 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", + "guildId") REFERENCES "GuildMember" ("userId", + "guildId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; diff --git a/prisma/migrations/20221021172156_int_to_bigint/migration.sql b/prisma/migrations/20221021172156_int_to_bigint/migration.sql index 187923d..8ba2555 100644 --- a/prisma/migrations/20221021172156_int_to_bigint/migration.sql +++ b/prisma/migrations/20221021172156_int_to_bigint/migration.sql @@ -1,25 +1,26 @@ /* - Warnings: + Warnings: - - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - -*/ + - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildCounter" ( "guildId" TEXT NOT NULL, "channelId" TEXT NOT NULL, @@ -29,10 +30,24 @@ CREATE TABLE "new_GuildCounter" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") SELECT "channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt" FROM "GuildCounter"; + +INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") +SELECT + "channelId", + "count", + "createdAt", + "guildId", + "triggerWord", + "updatedAt" +FROM + "GuildCounter"; + DROP TABLE "GuildCounter"; + ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; -CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); + CREATE TABLE "new_GuildMember" ( "userId" TEXT NOT NULL, "guildId" TEXT NOT NULL, @@ -43,10 +58,24 @@ CREATE TABLE "new_GuildMember" ( CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") SELECT "createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId" FROM "GuildMember"; + +INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") +SELECT + "createdAt", + "creditsEarned", + "guildId", + "pointsEarned", + "updatedAt", + "userId" +FROM + "GuildMember"; + DROP TABLE "GuildMember"; + ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; -CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); + +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -57,12 +86,29 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", + "guildId") REFERENCES "GuildMember" ("userId", + "guildId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + CREATE TABLE "new_Cooldown" ( "guildId" TEXT NOT NULL, "userId" TEXT NOT NULL, @@ -73,10 +119,24 @@ CREATE TABLE "new_Cooldown" ( CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; + +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") +SELECT + "cooldown", + "createdAt", + "guildId", + "timeoutId", + "updatedAt", + "userId" +FROM + "Cooldown"; + DROP TABLE "Cooldown"; + ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; -CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); + +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -84,27 +144,27 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" BIGINT NOT NULL DEFAULT 1, "creditsTimeout" BIGINT NOT NULL DEFAULT 5, "creditsWorkRate" BIGINT NOT NULL DEFAULT 25, "creditsWorkTimeout" BIGINT NOT NULL DEFAULT 86400, "creditsMinimumLength" BIGINT NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" BIGINT NOT NULL DEFAULT 1, "pointsTimeout" BIGINT NOT NULL DEFAULT 5, "pointsMinimumLength" BIGINT NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "apiCpggUrlIv" TEXT, "apiCpggUrlContent" TEXT, "apiCpggTokenIv" TEXT, "apiCpggTokenContent" TEXT, - "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "auditsChannelId" TEXT, - "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "shopRolesPricePerHour" BIGINT NOT NULL DEFAULT 5, - "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "welcomeJoinChannelId" TEXT, "welcomeJoinChannelMessage" TEXT, "welcomeLeaveChannelId" TEXT, @@ -112,19 +172,73 @@ CREATE TABLE "new_Guild" ( "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage" FROM "Guild"; + +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") +SELECT + "apiCpggTokenContent", + "apiCpggTokenIv", + "apiCpggUrlContent", + "apiCpggUrlIv", + "auditsChannelId", + "auditsEnabled", + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "embedColorError", + "embedColorSuccess", + "embedColorWait", + "embedFooterIcon", + "embedFooterText", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "shopRolesEnabled", + "shopRolesPricePerHour", + "updatedAt", + "welcomeEnabled", + "welcomeJoinChannelId", + "welcomeJoinChannelMessage", + "welcomeLeaveChannelId", + "welcomeLeaveChannelMessage" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + CREATE TABLE "new_User" ( "id" TEXT NOT NULL, "reputationsEarned" BIGINT NOT NULL DEFAULT 0, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") SELECT "createdAt", "id", "reputationsEarned", "updatedAt" FROM "User"; + +INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") +SELECT + "createdAt", + "id", + "reputationsEarned", + "updatedAt" +FROM + "User"; + DROP TABLE "User"; + ALTER TABLE "new_User" RENAME TO "User"; -CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); + +CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; diff --git a/prisma/migrations/20221021172345_bigint_to_int/migration.sql b/prisma/migrations/20221021172345_bigint_to_int/migration.sql index 978ac5c..29f4f08 100644 --- a/prisma/migrations/20221021172345_bigint_to_int/migration.sql +++ b/prisma/migrations/20221021172345_bigint_to_int/migration.sql @@ -1,35 +1,48 @@ /* - Warnings: + Warnings: - - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - -*/ + - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_User" ( "id" TEXT NOT NULL, "reputationsEarned" INTEGER NOT NULL DEFAULT 0, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") SELECT "createdAt", "id", "reputationsEarned", "updatedAt" FROM "User"; + +INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") +SELECT + "createdAt", + "id", + "reputationsEarned", + "updatedAt" +FROM + "User"; + DROP TABLE "User"; + ALTER TABLE "new_User" RENAME TO "User"; -CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); + +CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); + CREATE TABLE "new_GuildCounter" ( "guildId" TEXT NOT NULL, "channelId" TEXT NOT NULL, @@ -39,10 +52,24 @@ CREATE TABLE "new_GuildCounter" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") SELECT "channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt" FROM "GuildCounter"; + +INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") +SELECT + "channelId", + "count", + "createdAt", + "guildId", + "triggerWord", + "updatedAt" +FROM + "GuildCounter"; + DROP TABLE "GuildCounter"; + ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; -CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); + CREATE TABLE "new_GuildMember" ( "userId" TEXT NOT NULL, "guildId" TEXT NOT NULL, @@ -53,10 +80,24 @@ CREATE TABLE "new_GuildMember" ( CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") SELECT "createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId" FROM "GuildMember"; + +INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") +SELECT + "createdAt", + "creditsEarned", + "guildId", + "pointsEarned", + "updatedAt", + "userId" +FROM + "GuildMember"; + DROP TABLE "GuildMember"; + ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; -CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); + +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -67,12 +108,29 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", + "guildId") REFERENCES "GuildMember" ("userId", + "guildId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -80,27 +138,27 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "apiCpggUrlIv" TEXT, "apiCpggUrlContent" TEXT, "apiCpggTokenIv" TEXT, "apiCpggTokenContent" TEXT, - "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "auditsChannelId" TEXT, - "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, - "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "welcomeJoinChannelId" TEXT, "welcomeJoinChannelMessage" TEXT, "welcomeLeaveChannelId" TEXT, @@ -108,10 +166,51 @@ CREATE TABLE "new_Guild" ( "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage" FROM "Guild"; + +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") +SELECT + "apiCpggTokenContent", + "apiCpggTokenIv", + "apiCpggUrlContent", + "apiCpggUrlIv", + "auditsChannelId", + "auditsEnabled", + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "embedColorError", + "embedColorSuccess", + "embedColorWait", + "embedFooterIcon", + "embedFooterText", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "shopRolesEnabled", + "shopRolesPricePerHour", + "updatedAt", + "welcomeEnabled", + "welcomeJoinChannelId", + "welcomeJoinChannelMessage", + "welcomeLeaveChannelId", + "welcomeLeaveChannelMessage" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + CREATE TABLE "new_Cooldown" ( "guildId" TEXT NOT NULL, "userId" TEXT NOT NULL, @@ -122,9 +221,24 @@ CREATE TABLE "new_Cooldown" ( CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; + +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") +SELECT + "cooldown", + "createdAt", + "guildId", + "timeoutId", + "updatedAt", + "userId" +FROM + "Cooldown"; + DROP TABLE "Cooldown"; + ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; -CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); + +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml index e5e5c47..6fcf33d 100644 --- a/prisma/migrations/migration_lock.toml +++ b/prisma/migrations/migration_lock.toml @@ -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" \ No newline at end of file +provider = "sqlite" diff --git a/src/handlers/database/index.ts b/src/handlers/database/index.ts index 287669a..c4e22e4 100644 --- a/src/handlers/database/index.ts +++ b/src/handlers/database/index.ts @@ -1,3 +1,3 @@ import { PrismaClient } from '@prisma/client' -export default new PrismaClient() \ No newline at end of file +export default new PrismaClient()