<p>I'm deploying a NodeJS project that uses PostgreSQL with Prisma to Kubernetes. I created the <code>Dockerfile</code> and I'm building the docker image to Docker Hub:</p>
<pre><code>FROM node:lts-slim

WORKDIR /app

# Add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
ENV NODE_ENV=production

RUN apt-get update

# Install Chromium
RUN apt-get install chromium -y

# Install yarn
RUN apt-get install yarn -y

COPY package.json /app/package.json
RUN yarn install --silent

# Add app
COPY . /app

# Generate prisma
RUN yarn run generate

# Build the app
RUN yarn build

EXPOSE 4000

# Start the app
CMD [&quot;yarn&quot;, &quot;run&quot;, &quot;start&quot;]

</code></pre>
<p>I want to use CI/CD, so I would need to check if the PostgreSQL is updated. This can be done with <code>npx prisma migrate resolve --preview-feature</code></p>
<p>I thought on always running the <code>prisma migrate</code> to check if the DB is updated, since if a new build changes the <code>schema</code>, the DB should reflect it.</p>
<p>Since K8S pods are ephemeral, is it right to add the <code>npx prisma migrate resolve --preview-feature</code> to the <code>start</code> script, so everytime the app starts, it also checks the DB? I don't think running the <code>prisma migrate</code> all the time is good, but what would it be the solution?</p>
<p>Thanks in advance!</p>

Otavio Bonder
<p>In this case, I would suggest running <code>prisma migrate deploy</code> as mentioned <a href="https://www.prisma.io/docs/reference/api-reference/command-reference/#migrate-deploy" rel="noreferrer">here</a> in your CI/CD step before deploying the application so that you do not need to perform it on every start script which is not ideal in this case.</p>
<p>This migrations just need to be executed once and can be added to your pre-deploy step in your pipeline.</p>
