From d53d7a2b6a53e76038ec5b335e58deb01e311b78 Mon Sep 17 00:00:00 2001 From: Joonas Date: Sat, 11 Feb 2023 19:43:48 +0200 Subject: [PATCH] add logging and also add dates to the channel table --- commands/join.js | 1 + commands/part.js | 1 + .../migration.sql | 20 +++++++++++++++++++ prisma/schema.prisma | 3 +++ 4 files changed, 25 insertions(+) create mode 100644 prisma/migrations/20230211174119_channel_dates/migration.sql diff --git a/commands/join.js b/commands/join.js index 39a3ac9..a94163c 100644 --- a/commands/join.js +++ b/commands/join.js @@ -20,6 +20,7 @@ const command = { return; } + console.log("Joining channel: " + msg.senderUsername); const storeChannel = await prisma.channel.create({ data: { name: msg.senderUsername, diff --git a/commands/part.js b/commands/part.js index e7c3474..9a2c971 100644 --- a/commands/part.js +++ b/commands/part.js @@ -14,6 +14,7 @@ const command = { return; } + console.log("Parting channel: " + msg.senderUsername); const partChannel = await prisma.channel.delete({ where: { name: msg.senderUsername, diff --git a/prisma/migrations/20230211174119_channel_dates/migration.sql b/prisma/migrations/20230211174119_channel_dates/migration.sql new file mode 100644 index 0000000..5b1d116 --- /dev/null +++ b/prisma/migrations/20230211174119_channel_dates/migration.sql @@ -0,0 +1,20 @@ +/* + Warnings: + + - Added the required column `updatedAt` to the `Channel` table without a default value. This is not possible if the table is not empty. + +*/ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Channel" ( + "id" TEXT NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_Channel" ("id", "name") SELECT "id", "name" FROM "Channel"; +DROP TABLE "Channel"; +ALTER TABLE "new_Channel" RENAME TO "Channel"; +CREATE UNIQUE INDEX "Channel_name_key" ON "Channel"("name"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 6a43ebb..f9c6705 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -13,6 +13,9 @@ datasource db { model Channel { id String @id @default(uuid()) name String @unique + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt } model User {