Assign user to workspace on signin

This commit is contained in:
Charles Bochet
2023-04-24 14:50:48 +02:00
parent a5bfeef2d6
commit 6d2c8bbdf9
36 changed files with 547 additions and 34 deletions

View File

@ -0,0 +1,8 @@
import { Module } from '@nestjs/common';
import { PrismaService } from './prisma.service';
@Module({
providers: [PrismaService],
exports: [PrismaService],
})
export class PrismaModule {}

View File

@ -0,0 +1,15 @@
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
async onModuleInit() {
await this.$connect();
}
async enableShutdownHooks(app: INestApplication) {
this.$on('beforeExit', async () => {
await app.close();
});
}
}

View File

@ -0,0 +1,30 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("SERVER_DATABASE_URL")
}
model WorkspaceMember {
id Int @id @default(autoincrement())
created_at DateTime @default(now())
updated_at DateTime @updatedAt
deleted_at DateTime?
user_id String @unique
workspace_id Int
@@map("workspace_members")
}
model Workspace {
id Int @id @default(autoincrement())
created_at DateTime @default(now())
updated_at DateTime @updatedAt
deleted_at DateTime?
domain_name String @unique
display_name String
@@map("workspaces")
}