Add messaging
This commit is contained in:
parent
23128f25e1
commit
5733975aa0
29 changed files with 986 additions and 8 deletions
21
prisma/migrations/20260111121740_message/migration.sql
Normal file
21
prisma/migrations/20260111121740_message/migration.sql
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE "Message" (
|
||||
"id" TEXT NOT NULL,
|
||||
"text" TEXT NOT NULL,
|
||||
"editHistory" TEXT[],
|
||||
"edited" BOOLEAN NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"channelId" TEXT NOT NULL,
|
||||
"creationDate" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "Message_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Message_id_key" ON "Message"("id");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Message" ADD CONSTRAINT "Message_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Message" ADD CONSTRAINT "Message_channelId_fkey" FOREIGN KEY ("channelId") REFERENCES "Channel"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
3
prisma/migrations/20260111124811_message_1/migration.sql
Normal file
3
prisma/migrations/20260111124811_message_1/migration.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "Message" ALTER COLUMN "editHistory" SET DEFAULT ARRAY[]::TEXT[],
|
||||
ALTER COLUMN "edited" SET DEFAULT false;
|
||||
16
prisma/migrations/20260111125054_message_2/migration.sql
Normal file
16
prisma/migrations/20260111125054_message_2/migration.sql
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `userId` on the `Message` table. All the data in the column will be lost.
|
||||
- Added the required column `ownerId` to the `Message` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Message" DROP CONSTRAINT "Message_userId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Message" DROP COLUMN "userId",
|
||||
ADD COLUMN "ownerId" TEXT NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Message" ADD CONSTRAINT "Message_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
|
@ -28,6 +28,7 @@ model Channel {
|
|||
community Community @relation(fields: [communityId], references: [id], onDelete: Cascade)
|
||||
communityId String
|
||||
creationDate DateTime @default(now())
|
||||
messages Message[]
|
||||
}
|
||||
|
||||
model Role {
|
||||
|
|
@ -55,6 +56,7 @@ model User {
|
|||
ownedCommunities Community[] @relation(name: "OwnerCommunityToUser")
|
||||
communities Community[] @relation(name: "MembersCommunitiesToUsers")
|
||||
roles Role[] @relation(name: "UsersRolesToUsers")
|
||||
messages Message[]
|
||||
}
|
||||
|
||||
model Session {
|
||||
|
|
@ -76,3 +78,15 @@ model Invite {
|
|||
creationDate DateTime @default(now())
|
||||
expirationDate DateTime?
|
||||
}
|
||||
|
||||
model Message {
|
||||
id String @id @unique @default(uuid())
|
||||
text String
|
||||
editHistory String[] @default([])
|
||||
edited Boolean @default(false)
|
||||
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
|
||||
ownerId String
|
||||
channel Channel @relation(fields: [channelId], references: [id], onDelete: Cascade)
|
||||
channelId String
|
||||
creationDate DateTime @default(now())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue