mirror of
https://github.com/SrIzan10/hctv.git
synced 2026-06-06 00:56:56 +00:00
feat: bot accounts (without api stuff)
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "BotAccounts" (
|
||||
"id" TEXT NOT NULL,
|
||||
"displayName" TEXT NOT NULL,
|
||||
"slug" TEXT NOT NULL,
|
||||
"description" TEXT NOT NULL,
|
||||
"pfpUrl" TEXT NOT NULL,
|
||||
"channelId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "BotAccounts_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ApiKey" (
|
||||
"id" TEXT NOT NULL,
|
||||
"key" TEXT NOT NULL,
|
||||
"botAccountId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "ApiKey_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "BotAccounts_slug_key" ON "BotAccounts"("slug");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BotAccounts_channelId_idx" ON "BotAccounts"("channelId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BotAccounts_slug_idx" ON "BotAccounts"("slug");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ApiKey_key_key" ON "ApiKey"("key");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "ApiKey_botAccountId_idx" ON "ApiKey"("botAccountId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BotAccounts" ADD CONSTRAINT "BotAccounts_channelId_fkey" FOREIGN KEY ("channelId") REFERENCES "Channel"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ApiKey" ADD CONSTRAINT "ApiKey_botAccountId_fkey" FOREIGN KEY ("botAccountId") REFERENCES "BotAccounts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `channelId` on the `BotAccounts` table. All the data in the column will be lost.
|
||||
- Added the required column `ownerId` to the `BotAccounts` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "BotAccounts" DROP CONSTRAINT "BotAccounts_channelId_fkey";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "BotAccounts_channelId_idx";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "BotAccounts" DROP COLUMN "channelId",
|
||||
ADD COLUMN "ownerId" TEXT NOT NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BotAccounts_ownerId_idx" ON "BotAccounts"("ownerId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BotAccounts" ADD CONSTRAINT "BotAccounts_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `updatedAt` to the `BotAccounts` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "BotAccounts" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL;
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `BotAccounts` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "ApiKey" DROP CONSTRAINT "ApiKey_botAccountId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "BotAccounts" DROP CONSTRAINT "BotAccounts_ownerId_fkey";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "BotAccounts";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "BotAccount" (
|
||||
"id" TEXT NOT NULL,
|
||||
"displayName" TEXT NOT NULL,
|
||||
"slug" TEXT NOT NULL,
|
||||
"description" TEXT NOT NULL,
|
||||
"pfpUrl" TEXT NOT NULL,
|
||||
"ownerId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "BotAccount_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "BotAccount_slug_key" ON "BotAccount"("slug");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BotAccount_ownerId_idx" ON "BotAccount"("ownerId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BotAccount_slug_idx" ON "BotAccount"("slug");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BotAccount" ADD CONSTRAINT "BotAccount_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ApiKey" ADD CONSTRAINT "ApiKey_botAccountId_fkey" FOREIGN KEY ("botAccountId") REFERENCES "BotAccount"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "BotAccount" ALTER COLUMN "description" SET DEFAULT 'A hctv bot account';
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `ApiKey` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "ApiKey" DROP CONSTRAINT "ApiKey_botAccountId_fkey";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "ApiKey";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "BotApiKey" (
|
||||
"id" TEXT NOT NULL,
|
||||
"key" TEXT NOT NULL,
|
||||
"botAccountId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "BotApiKey_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "BotApiKey_key_key" ON "BotApiKey"("key");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BotApiKey_botAccountId_idx" ON "BotApiKey"("botAccountId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BotApiKey" ADD CONSTRAINT "BotApiKey_botAccountId_fkey" FOREIGN KEY ("botAccountId") REFERENCES "BotAccount"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `name` to the `BotApiKey` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "BotApiKey" ADD COLUMN "name" TEXT NOT NULL;
|
||||
@@ -5,55 +5,56 @@
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../generated/client"
|
||||
provider = "prisma-client-js"
|
||||
output = "../generated/client"
|
||||
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
directUrl = env("DATABASE_DIRECT_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
slack_id String
|
||||
pfpUrl String
|
||||
hasOnboarded Boolean @default(false)
|
||||
id String @id @default(cuid())
|
||||
slack_id String
|
||||
pfpUrl String
|
||||
hasOnboarded Boolean @default(false)
|
||||
|
||||
personalChannel Channel? @relation("PersonalChannel", fields: [personalChannelId], references: [id])
|
||||
personalChannelId String? @unique
|
||||
personalChannel Channel? @relation("PersonalChannel", fields: [personalChannelId], references: [id])
|
||||
personalChannelId String? @unique
|
||||
|
||||
ownedChannels Channel[] @relation("ChannelOwner")
|
||||
managedChannels Channel[] @relation("ChannelManagers")
|
||||
sessions Session[]
|
||||
streams StreamInfo[]
|
||||
followers Follow[] @relation("UserFollows")
|
||||
ownedChannels Channel[] @relation("ChannelOwner")
|
||||
managedChannels Channel[] @relation("ChannelManagers")
|
||||
sessions Session[]
|
||||
streams StreamInfo[]
|
||||
followers Follow[] @relation("UserFollows")
|
||||
botAccounts BotAccount[]
|
||||
|
||||
@@index([personalChannelId])
|
||||
}
|
||||
|
||||
model Channel {
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
description String @default("A hctv channel")
|
||||
pfpUrl String
|
||||
pfpUrl String
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
personalFor User? @relation("PersonalChannel")
|
||||
|
||||
owner User @relation("ChannelOwner", fields: [ownerId], references: [id])
|
||||
ownerId String
|
||||
managers User[] @relation("ChannelManagers")
|
||||
streamInfo StreamInfo[]
|
||||
followers Follow[] @relation("ChannelFollowers")
|
||||
streamKey StreamKey?
|
||||
obsChatGrantToken String @unique @default(cuid())
|
||||
is247 Boolean @default(false)
|
||||
|
||||
owner User @relation("ChannelOwner", fields: [ownerId], references: [id])
|
||||
ownerId String
|
||||
managers User[] @relation("ChannelManagers")
|
||||
streamInfo StreamInfo[]
|
||||
followers Follow[] @relation("ChannelFollowers")
|
||||
streamKey StreamKey?
|
||||
obsChatGrantToken String @unique @default(cuid())
|
||||
is247 Boolean @default(false)
|
||||
|
||||
@@index([ownerId])
|
||||
}
|
||||
|
||||
@@ -65,20 +66,20 @@ model Session {
|
||||
}
|
||||
|
||||
model StreamInfo {
|
||||
id String @id @default(cuid())
|
||||
username String @unique
|
||||
id String @id @default(cuid())
|
||||
username String @unique
|
||||
title String
|
||||
thumbnail String
|
||||
viewers Int
|
||||
category String
|
||||
startedAt DateTime
|
||||
isLive Boolean
|
||||
|
||||
|
||||
channelId String
|
||||
channel Channel @relation(fields: [channelId], references: [id])
|
||||
|
||||
ownedBy User @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
ownedBy User @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
|
||||
enableNotifications Boolean @default(true)
|
||||
|
||||
@@ -88,13 +89,13 @@ model StreamInfo {
|
||||
model Follow {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
user User @relation("UserFollows", fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
|
||||
channel Channel @relation("ChannelFollowers", fields: [channelId], references: [id], onDelete: Cascade)
|
||||
|
||||
user User @relation("UserFollows", fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
|
||||
channel Channel @relation("ChannelFollowers", fields: [channelId], references: [id], onDelete: Cascade)
|
||||
channelId String
|
||||
|
||||
|
||||
notifyStream Boolean @default(false)
|
||||
|
||||
@@unique([userId, channelId])
|
||||
@@ -103,9 +104,37 @@ model Follow {
|
||||
}
|
||||
|
||||
model StreamKey {
|
||||
id String @id @default(cuid())
|
||||
key String @unique
|
||||
id String @id @default(cuid())
|
||||
key String @unique
|
||||
|
||||
channelId String @unique
|
||||
channel Channel @relation(fields: [channelId], references: [id])
|
||||
}
|
||||
channelId String @unique
|
||||
channel Channel @relation(fields: [channelId], references: [id])
|
||||
}
|
||||
|
||||
model BotAccount {
|
||||
id String @id @default(cuid())
|
||||
displayName String
|
||||
slug String @unique
|
||||
description String @default("A hctv bot account")
|
||||
pfpUrl String
|
||||
owner User @relation(fields: [ownerId], references: [id])
|
||||
ownerId String
|
||||
apiKeys BotApiKey[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([ownerId])
|
||||
@@index([slug])
|
||||
}
|
||||
|
||||
model BotApiKey {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
key String @unique
|
||||
botAccount BotAccount @relation(fields: [botAccountId], references: [id], onDelete: Cascade)
|
||||
botAccountId String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([botAccountId])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user