feat(saas): update schema for db-per-tenant and per-component FIEL encryption
- Rename Tenant.schemaName to databaseName across all services - Add Subscription and Payment models to Prisma schema - Update FielCredential to per-component IV/tag encryption columns - Switch FIEL encryption key from JWT_SECRET to FIEL_ENCRYPTION_KEY - Add Subscription and Payment shared types - Update JWTPayload to use databaseName Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,17 +29,17 @@ export async function tenantMiddleware(req: Request, res: Response, next: NextFu
|
||||
|
||||
const tenant = await prisma.tenant.findUnique({
|
||||
where: { id: tenantId },
|
||||
select: { schemaName: true, active: true },
|
||||
select: { databaseName: true, active: true },
|
||||
});
|
||||
|
||||
if (!tenant || !tenant.active) {
|
||||
return next(new AppError(403, 'Tenant no encontrado o inactivo'));
|
||||
}
|
||||
|
||||
req.tenantSchema = tenant.schemaName;
|
||||
req.tenantSchema = tenant.databaseName;
|
||||
|
||||
// Set search_path for this request
|
||||
await prisma.$executeRawUnsafe(`SET search_path TO "${tenant.schemaName}", public`);
|
||||
// Set search_path for this request (will be replaced by pool-based approach)
|
||||
await prisma.$executeRawUnsafe(`SET search_path TO "${tenant.databaseName}", public`);
|
||||
|
||||
next();
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user