added event collector
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Chat" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"pubkey" TEXT NOT NULL,
|
||||
"createdAt" INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Chat_pubkey_key" ON "Chat"("pubkey");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Chat_pubkey_idx" ON "Chat"("pubkey");
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `accountId` to the `Chat` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `accountId` to the `Channel` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- RedefineTables
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_Chat" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"pubkey" TEXT NOT NULL,
|
||||
"createdAt" INTEGER NOT NULL,
|
||||
"accountId" INTEGER NOT NULL,
|
||||
CONSTRAINT "Chat_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
INSERT INTO "new_Chat" ("createdAt", "id", "pubkey") SELECT "createdAt", "id", "pubkey" FROM "Chat";
|
||||
DROP TABLE "Chat";
|
||||
ALTER TABLE "new_Chat" RENAME TO "Chat";
|
||||
CREATE UNIQUE INDEX "Chat_pubkey_key" ON "Chat"("pubkey");
|
||||
CREATE INDEX "Chat_pubkey_idx" ON "Chat"("pubkey");
|
||||
CREATE TABLE "new_Channel" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"eventId" TEXT NOT NULL,
|
||||
"content" TEXT NOT NULL,
|
||||
"accountId" INTEGER NOT NULL,
|
||||
CONSTRAINT "Channel_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
INSERT INTO "new_Channel" ("content", "eventId", "id") SELECT "content", "eventId", "id" FROM "Channel";
|
||||
DROP TABLE "Channel";
|
||||
ALTER TABLE "new_Channel" RENAME TO "Channel";
|
||||
CREATE UNIQUE INDEX "Channel_eventId_key" ON "Channel"("eventId");
|
||||
CREATE INDEX "Channel_eventId_idx" ON "Channel"("eventId");
|
||||
PRAGMA foreign_key_check;
|
||||
PRAGMA foreign_keys=ON;
|
||||
@@ -21,6 +21,8 @@ model Account {
|
||||
plebs Pleb[]
|
||||
messages Message[]
|
||||
notes Note[]
|
||||
chats Chat[]
|
||||
channels Channel[]
|
||||
|
||||
@@index([pubkey])
|
||||
}
|
||||
@@ -66,11 +68,25 @@ model Message {
|
||||
@@index([pubkey, createdAt])
|
||||
}
|
||||
|
||||
model Chat {
|
||||
id Int @id @default(autoincrement())
|
||||
pubkey String @unique
|
||||
createdAt Int
|
||||
|
||||
Account Account @relation(fields: [accountId], references: [id])
|
||||
accountId Int
|
||||
|
||||
@@index([pubkey])
|
||||
}
|
||||
|
||||
model Channel {
|
||||
id Int @id @default(autoincrement())
|
||||
eventId String @unique
|
||||
content String
|
||||
|
||||
Account Account @relation(fields: [accountId], references: [id])
|
||||
accountId Int
|
||||
|
||||
@@index([eventId])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user