40 lines
1.6 KiB
MySQL
40 lines
1.6 KiB
MySQL
|
-- CreateTable
|
||
|
CREATE TABLE "FriendRequest" (
|
||
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||
|
"senderUsername" TEXT NOT NULL,
|
||
|
"receiverUsername" TEXT NOT NULL,
|
||
|
"status" TEXT NOT NULL DEFAULT 'pending',
|
||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
CONSTRAINT "FriendRequest_senderUsername_fkey" FOREIGN KEY ("senderUsername") REFERENCES "user" ("username") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||
|
CONSTRAINT "FriendRequest_receiverUsername_fkey" FOREIGN KEY ("receiverUsername") REFERENCES "user" ("username") ON DELETE RESTRICT ON UPDATE CASCADE
|
||
|
);
|
||
|
|
||
|
-- CreateTable
|
||
|
CREATE TABLE "Message" (
|
||
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||
|
"content" TEXT NOT NULL,
|
||
|
"nonce" TEXT NOT NULL,
|
||
|
"senderUsername" TEXT NOT NULL,
|
||
|
"receiverUsername" TEXT NOT NULL,
|
||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
"pubKey" TEXT NOT NULL,
|
||
|
CONSTRAINT "Message_senderUsername_fkey" FOREIGN KEY ("senderUsername") REFERENCES "user" ("username") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||
|
CONSTRAINT "Message_receiverUsername_fkey" FOREIGN KEY ("receiverUsername") REFERENCES "user" ("username") ON DELETE RESTRICT ON UPDATE CASCADE
|
||
|
);
|
||
|
|
||
|
-- CreateTable
|
||
|
CREATE TABLE "user" (
|
||
|
"username" TEXT NOT NULL PRIMARY KEY,
|
||
|
"email" TEXT NOT NULL,
|
||
|
"password" TEXT NOT NULL,
|
||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
"updatedAt" DATETIME NOT NULL,
|
||
|
"pubKey" TEXT NOT NULL
|
||
|
);
|
||
|
|
||
|
-- CreateIndex
|
||
|
CREATE UNIQUE INDEX "user_email_key" ON "user"("email");
|
||
|
|
||
|
-- CreateIndex
|
||
|
CREATE UNIQUE INDEX "user_pubKey_key" ON "user"("pubKey");
|