Added access_code column to teams.

This commit is contained in:
Mike Cao 2022-12-27 00:00:31 -08:00
parent dff105c747
commit aef7326f4c
3 changed files with 40 additions and 8 deletions

View File

@ -0,0 +1,27 @@
/*
Warnings:
- You are about to alter the column `share_id` on the `website` table. The data in that column could be lost. The data in that column will be cast from `VarChar(64)` to `VarChar(50)`.
- A unique constraint covering the columns `[access_code]` on the table `team` will be added. If there are existing duplicate values, this will fail.
*/
-- AlterTable
ALTER TABLE "team" ADD COLUMN "access_code" VARCHAR(50);
-- AlterTable
ALTER TABLE "website" ALTER COLUMN "share_id" SET DATA TYPE VARCHAR(50);
-- CreateIndex
CREATE UNIQUE INDEX "team_access_code_key" ON "team"("access_code");
-- CreateIndex
CREATE INDEX "team_user_id_idx" ON "team"("user_id");
-- CreateIndex
CREATE INDEX "team_access_code_idx" ON "team"("access_code");
-- CreateIndex
CREATE INDEX "team_user_team_id_idx" ON "team_user"("team_id");
-- CreateIndex
CREATE INDEX "team_user_user_id_idx" ON "team_user"("user_id");

View File

@ -43,7 +43,7 @@ model Website {
id String @id @unique @map("website_id") @db.Uuid
name String @db.VarChar(100)
domain String? @db.VarChar(500)
shareId String? @unique @map("share_id") @db.VarChar(64)
shareId String? @unique @map("share_id") @db.VarChar(50)
revId Int @default(0) @map("rev_id") @db.Integer
userId String? @map("user_id") @db.Uuid
teamId String? @map("team_id") @db.Uuid
@ -79,16 +79,19 @@ model WebsiteEvent {
}
model Team {
id String @id() @unique() @map("team_id") @db.Uuid
name String @db.VarChar(50)
userId String @map("user_id") @db.Uuid
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
updatedAt DateTime? @map("updated_at") @db.Timestamptz(6)
deletedAt DateTime? @map("deleted_at") @db.Timestamptz(6)
id String @id() @unique() @map("team_id") @db.Uuid
name String @db.VarChar(50)
userId String @map("user_id") @db.Uuid
accessCode String? @unique @map("access_code") @db.VarChar(50)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
updatedAt DateTime? @map("updated_at") @db.Timestamptz(6)
deletedAt DateTime? @map("deleted_at") @db.Timestamptz(6)
teamUsers TeamUser[]
Website Website[]
@@index([userId])
@@index([accessCode])
@@map("team")
}
@ -104,5 +107,7 @@ model TeamUser {
team Team @relation(fields: [teamId], references: [id])
user User @relation(fields: [userId], references: [id])
@@index([teamId])
@@index([userId])
@@map("team_user")
}

View File

@ -204,7 +204,7 @@ async function findFirst(data) {
}
async function connect() {
if (!clickhouse) {
if (enabled && !clickhouse) {
clickhouse = process.env.CLICKHOUSE_URL && (global[CLICKHOUSE] || getClient());
}