diff --git a/package.json b/package.json index d7365ebae..491c43089 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "db:validateSchema": "docker exec -it tripbot npx prisma validate", "db:generateClient": "npx prisma generate && docker exec -it tripbot npx prisma generate", "db:pushDev": "docker exec -it tripbot npx prisma db push && npm run tripbot:db:generate", - "db:migrateDev": "docker exec -it tripbot npx prisma migrate dev -n quotes", + "db:migrateDev": "docker exec -it tripbot npx prisma migrate dev -n ai_ui_update", "db:seed": "docker exec -it tripbot npx prisma db seed", "## PGADMIN ##": "", "pgadmin": "docker compose --project-name tripbot up -d --force-recreate --build tripbot_pgadmin", diff --git a/src/prisma/tripbot/migrations/20240217152141_quotes/migration.sql b/src/prisma/tripbot/migrations/20240217164428_ai_ui_update/migration.sql similarity index 68% rename from src/prisma/tripbot/migrations/20240217152141_quotes/migration.sql rename to src/prisma/tripbot/migrations/20240217164428_ai_ui_update/migration.sql index 0be30e712..c0bb7de2b 100644 --- a/src/prisma/tripbot/migrations/20240217152141_quotes/migration.sql +++ b/src/prisma/tripbot/migrations/20240217164428_ai_ui_update/migration.sql @@ -2,7 +2,6 @@ Warnings: - The values [GPT-4,DAVINCI,CURIE,BABBAGE,ADA,GPT-3.5-TURBO-1106,GPT-4-1106-PREVIEW,GPT-4-1106-VISION-PREVIEW,DALL-E-2] on the enum `ai_model` will be removed. If these variants are still used in the database, this will fail. - - A unique constraint covering the columns `[channel_id]` on the table `ai_channels` will be added. If there are existing duplicate values, this will fail. - Added the required column `guild_id` to the `ai_channels` table without a default value. This is not possible if the table is not empty. */ @@ -16,12 +15,6 @@ ALTER TYPE "ai_model_new" RENAME TO "ai_model"; DROP TYPE "ai_model_old"; COMMIT; --- Drop the unique constraint -ALTER TABLE ai_channels DROP CONSTRAINT aichannels_channelid_personaid_unique; - --- DropIndex -DROP INDEX "aichannels_channelid_personaid_unique"; - -- AlterTable ALTER TABLE "ai_channels" ADD COLUMN "guild_id" TEXT NOT NULL; @@ -35,9 +28,3 @@ ADD COLUMN "upvotes" INTEGER NOT NULL DEFAULT 0; ALTER TABLE "users" ADD COLUMN "ai_history_google" TEXT, ADD COLUMN "ai_history_openai" TEXT, ADD COLUMN "ai_terms_agree" BOOLEAN NOT NULL DEFAULT false; - --- CreateIndex -CREATE UNIQUE INDEX "aichannels_channelid_unique" ON "ai_channels"("channel_id"); - --- AddForeignKey -ALTER TABLE "ai_channels" ADD CONSTRAINT "aichannels_guildid_foreign" FOREIGN KEY ("guild_id") REFERENCES "discord_guilds"("id") ON DELETE NO ACTION ON UPDATE NO ACTION; diff --git a/src/prisma/tripbot/schema.prisma b/src/prisma/tripbot/schema.prisma index 60e96d0d1..98d2e8acc 100644 --- a/src/prisma/tripbot/schema.prisma +++ b/src/prisma/tripbot/schema.prisma @@ -207,7 +207,7 @@ model discord_guilds { reaction_roles reaction_roles[] ai_moderation ai_moderation? user_actions user_actions[] - ai_channels ai_channels[] + // ai_channels ai_channels[] } model drug_articles { @@ -440,9 +440,11 @@ model ai_channels { persona_id String @db.Uuid ai_personas ai_personas @relation(fields: [persona_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "aichannels_personaid_foreign") - discord_guilds discord_guilds @relation(fields: [guild_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "aichannels_guildid_foreign") + // discord_guilds discord_guilds @relation(fields: [guild_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "aichannels_guildid_foreign") - @@unique([channel_id], map: "aichannels_channelid_unique") + // @@unique([channel_id], map: "aichannels_channelid_unique") + + @@unique([channel_id, persona_id], map: "aichannels_channelid_personaid_unique") } model ai_moderation {