Michael Reh
12/31/2020, 8:54 AMnikolasburk
1.) Is there any best practise how to check for a K8S readiness check if the client can access the DB ?I'm not super familiar with Kubernetes unfortunately, can you maybe elaborate a bit on your question? Are you wondering if a
PrismaClient
instance has an open DB connection or what exactly are you trying to find out?
2.) can the client create the DB if the DB etc doesn't exists instead of doing a manual prisma migrateĀ or is the best the mount the SQL to postgres ( as I am using postgres ) ?
PrismaClient
currently is mostly used to perform data manipulation queries, but not to create/migrate the actual DB and its schema. So yeah, you probably need to either run raw SQL commands or run the prisma migrate
CLI commands programmatically in Node.js.
Does that help? šKeith Stolte
12/31/2020, 2:25 PMserver.applyMiddleware({
app,
cors: {
origin: [
'values here',
],
},
onHealthCheck: () => {
return new Promise(async (resolve, reject) => {
const result = await prisma.$queryRaw`SELECT 1+1 as serverCheck`;
if (result[0].serverCheck === 2) {
resolve();
} else {
reject();
}
});
},
});
This will then respond to requests from /.well-known/apollo/server-health with either 200 or 500 response code.
Not sure if the above helps at all for what you are looking for.