57 lines
2.1 KiB
SQL
57 lines
2.1 KiB
SQL
/*
|
|
Warnings:
|
|
|
|
- You are about to drop the column `created_at` on the `Message` table. All the data in the column will be lost.
|
|
- You are about to drop the column `updated_at` on the `Message` table. All the data in the column will be lost.
|
|
- You are about to drop the `_recipients` table. If the table is not empty, all the data it contains will be lost.
|
|
- Added the required column `conversation_id` to the `Message` table without a default value. This is not possible if the table is not empty.
|
|
|
|
*/
|
|
-- DropForeignKey
|
|
ALTER TABLE "_recipients" DROP CONSTRAINT "_recipients_A_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "_recipients" DROP CONSTRAINT "_recipients_B_fkey";
|
|
|
|
-- AlterTable
|
|
ALTER TABLE "Message" DROP COLUMN "created_at",
|
|
DROP COLUMN "updated_at",
|
|
ADD COLUMN "conversation_id" TEXT NOT NULL,
|
|
ADD COLUMN "sentAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
|
|
|
-- DropTable
|
|
DROP TABLE "_recipients";
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "Conversation" (
|
|
"id" TEXT NOT NULL,
|
|
"name" TEXT,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "Participant" (
|
|
"id" TEXT NOT NULL,
|
|
"benutzer_id" TEXT NOT NULL,
|
|
"conversation_id" TEXT NOT NULL,
|
|
"joined_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT "Participant_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "Conversation_id_key" ON "Conversation"("id");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "Participant_benutzer_id_conversation_id_key" ON "Participant"("benutzer_id", "conversation_id");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Message" ADD CONSTRAINT "Message_conversation_id_fkey" FOREIGN KEY ("conversation_id") REFERENCES "Conversation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Participant" ADD CONSTRAINT "Participant_benutzer_id_fkey" FOREIGN KEY ("benutzer_id") REFERENCES "benutzer"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Participant" ADD CONSTRAINT "Participant_conversation_id_fkey" FOREIGN KEY ("conversation_id") REFERENCES "Conversation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|