56 lines
1.8 KiB
SQL
56 lines
1.8 KiB
SQL
/*
|
|
Warnings:
|
|
|
|
- You are about to drop the `ConnectedDispatch` table. If the table is not empty, all the data it contains will be lost.
|
|
- You are about to drop the `ReportMessage` table. If the table is not empty, all the data it contains will be lost.
|
|
|
|
*/
|
|
-- DropForeignKey
|
|
ALTER TABLE "ConnectedDispatch" DROP CONSTRAINT "ConnectedDispatch_userId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "ReportMessage" DROP CONSTRAINT "ReportMessage_reportedId_fkey";
|
|
|
|
-- DropForeignKey
|
|
ALTER TABLE "ReportMessage" DROP CONSTRAINT "ReportMessage_senderId_fkey";
|
|
|
|
-- DropTable
|
|
DROP TABLE "ConnectedDispatch";
|
|
|
|
-- DropTable
|
|
DROP TABLE "ReportMessage";
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "ConnectedDispatcher" (
|
|
"id" SERIAL NOT NULL,
|
|
"userId" TEXT NOT NULL,
|
|
"publicUser" JSONB NOT NULL,
|
|
"lastHeartbeat" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"loginTime" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"esimatedLogoutTime" TIMESTAMP(3),
|
|
"logoutTime" TIMESTAMP(3),
|
|
|
|
CONSTRAINT "ConnectedDispatcher_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "Report" (
|
|
"id" SERIAL NOT NULL,
|
|
"text" TEXT NOT NULL,
|
|
"senderId" TEXT NOT NULL,
|
|
"reportedId" TEXT NOT NULL,
|
|
"timestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"reviewed" BOOLEAN NOT NULL DEFAULT false,
|
|
|
|
CONSTRAINT "Report_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "ConnectedDispatcher" ADD CONSTRAINT "ConnectedDispatcher_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Report" ADD CONSTRAINT "Report_senderId_fkey" FOREIGN KEY ("senderId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Report" ADD CONSTRAINT "Report_reportedId_fkey" FOREIGN KEY ("reportedId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|