le super migration timestamp style on it
This commit is contained in:
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- Added the required column `updatedAt` to the `Category` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `pinnedId` to the `Channel` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `updatedAt` to the `Channel` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `updatedAt` to the `Instance` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `updatedAt` to the `Message` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `updatedAt` to the `Reply` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `updatedAt` to the `Role` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `updatedAt` to the `User` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `updatedAt` to the `UserAuth` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Category" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Channel" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
ADD COLUMN "pinnedId" TEXT,
|
||||||
|
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Instance" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Message" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."MessagePing" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Reply" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Role" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."User" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."UserAuth" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "public"."ChannelPin" (
|
||||||
|
"messageId" TEXT NOT NULL,
|
||||||
|
"channelId" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "ChannelPin_messageId_key" ON "public"."ChannelPin"("messageId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "ChannelPin_channelId_key" ON "public"."ChannelPin"("channelId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "ChannelPin_messageId_channelId_key" ON "public"."ChannelPin"("messageId", "channelId");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "public"."ChannelPin" ADD CONSTRAINT "ChannelPin_messageId_fkey" FOREIGN KEY ("messageId") REFERENCES "public"."Message"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "public"."ChannelPin" ADD CONSTRAINT "ChannelPin_channelId_fkey" FOREIGN KEY ("channelId") REFERENCES "public"."Channel"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Category" ALTER COLUMN "updatedAt" DROP DEFAULT;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Channel" ALTER COLUMN "updatedAt" DROP DEFAULT;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Channel" ALTER COLUMN "pinnedId" DROP NOT NULL;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Instance" ALTER COLUMN "updatedAt" DROP DEFAULT;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Message" ALTER COLUMN "updatedAt" DROP DEFAULT;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Reply" ALTER COLUMN "updatedAt" DROP DEFAULT;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."Role" ALTER COLUMN "updatedAt" DROP DEFAULT;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."User" ALTER COLUMN "updatedAt" DROP DEFAULT;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "public"."UserAuth" ALTER COLUMN "updatedAt" DROP DEFAULT;
|
||||||
@@ -12,11 +12,13 @@ datasource db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Instance {
|
model Instance {
|
||||||
id String @id @default(uuid(7))
|
id String @id @default(uuid(7))
|
||||||
name String
|
name String
|
||||||
icon String?
|
icon String?
|
||||||
Role Role[]
|
createdAt DateTime @default(now())
|
||||||
Category Category[]
|
updatedAt DateTime @updatedAt
|
||||||
|
Role Role[]
|
||||||
|
Category Category[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
@@ -28,6 +30,8 @@ model User {
|
|||||||
banner String?
|
banner String?
|
||||||
admin Boolean
|
admin Boolean
|
||||||
status String // online/offline/dnd/idle/invis
|
status String // online/offline/dnd/idle/invis
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
Role Role[]
|
Role Role[]
|
||||||
UserAuth UserAuth?
|
UserAuth UserAuth?
|
||||||
Message Message[]
|
Message Message[]
|
||||||
@@ -35,20 +39,24 @@ model User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Role {
|
model Role {
|
||||||
User User @relation(fields: [userId], references: [id])
|
User User @relation(fields: [userId], references: [id])
|
||||||
userId String
|
userId String
|
||||||
Instance Instance @relation(fields: [instanceId], references: [id])
|
Instance Instance @relation(fields: [instanceId], references: [id])
|
||||||
instanceId String
|
instanceId String
|
||||||
type String
|
type String
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
@@unique([userId, instanceId])
|
@@unique([userId, instanceId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model UserAuth {
|
model UserAuth {
|
||||||
User User @relation(fields: [userId], references: [id])
|
User User @relation(fields: [userId], references: [id])
|
||||||
userId String
|
userId String
|
||||||
password String // HASHED PASSWORD AS STRING USING SHA-256
|
password String // HASHED PASSWORD AS STRING USING SHA-256
|
||||||
token String? // current user token
|
token String? // current user token
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
@@unique([userId])
|
@@unique([userId])
|
||||||
}
|
}
|
||||||
@@ -59,17 +67,34 @@ model Category {
|
|||||||
instanceId String?
|
instanceId String?
|
||||||
name String
|
name String
|
||||||
position Int
|
position Int
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
Channel Channel[]
|
Channel Channel[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model Channel {
|
model Channel {
|
||||||
id String @id @default(uuid(7))
|
id String @id @default(uuid(7))
|
||||||
type String
|
type String
|
||||||
Category Category? @relation(fields: [categoryId], references: [id])
|
Category Category? @relation(fields: [categoryId], references: [id])
|
||||||
categoryId String?
|
categoryId String?
|
||||||
name String
|
name String
|
||||||
description String
|
description String
|
||||||
|
pinnedId String?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
Message Message[]
|
Message Message[]
|
||||||
|
ChannelPin ChannelPin?
|
||||||
|
}
|
||||||
|
|
||||||
|
model ChannelPin {
|
||||||
|
messageId String @unique
|
||||||
|
channelId String @unique
|
||||||
|
|
||||||
|
Message Message @relation(fields: [messageId], references: [id])
|
||||||
|
Channel Channel @relation(fields: [channelId], references: [id])
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
|
||||||
|
@@unique([messageId, channelId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Message {
|
model Message {
|
||||||
@@ -80,25 +105,31 @@ model Message {
|
|||||||
userId String
|
userId String
|
||||||
deleted Boolean
|
deleted Boolean
|
||||||
text String
|
text String
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
replies Reply? @relation("MessageToReply")
|
replies Reply? @relation("MessageToReply")
|
||||||
repliedTo Reply? @relation("ReplyToMessage")
|
repliedTo Reply? @relation("ReplyToMessage")
|
||||||
MessagePing MessagePing[]
|
MessagePing MessagePing[]
|
||||||
|
ChannelPin ChannelPin?
|
||||||
}
|
}
|
||||||
|
|
||||||
model Reply {
|
model Reply {
|
||||||
message Message @relation("MessageToReply", fields: [messageId], references: [id]) //message text
|
message Message @relation("MessageToReply", fields: [messageId], references: [id]) //message text
|
||||||
messageId String @unique //message id of the reply
|
messageId String @unique //message id of the reply
|
||||||
repliesTo Message @relation("ReplyToMessage", fields: [repliesToId], references: [id]) //message id that this message replies to
|
repliesTo Message @relation("ReplyToMessage", fields: [repliesToId], references: [id]) //message id that this message replies to
|
||||||
repliesToId String @unique //replies to this message id
|
repliesToId String @unique //replies to this message id
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
@@unique([messageId, repliesToId])
|
@@unique([messageId, repliesToId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model MessagePing {
|
model MessagePing {
|
||||||
Message Message @relation(fields: [messageId], references: [id])
|
Message Message @relation(fields: [messageId], references: [id])
|
||||||
messageId String
|
messageId String
|
||||||
PingsUser User @relation(fields: [pingsUserId], references: [id])
|
PingsUser User @relation(fields: [pingsUserId], references: [id])
|
||||||
pingsUserId String
|
pingsUserId String
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
|
||||||
@@unique([messageId, pingsUserId])
|
@@unique([messageId, pingsUserId])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user