Im having some issues when trying to run migrations before starting the payload server. Im using the following command in package.json:
"serve": "payload migrate && node dist/server.js"
, and my Dockerfile looks like this:
FROM base as runtime
ENV NODE_ENV=production
ENV PAYLOAD_CONFIG_PATH=dist/payload.config.js
WORKDIR /home/node/app
COPY package*.json ./
RUN yarn install --production && \
yarn cache clean
COPY --from=builder /home/node/app/dist ./dist
COPY --from=builder /home/node/app/build ./build
EXPOSE 4000
CMD ["yarn", "serve"]
The migrate command finishes successfully but it does not run any migrations. I see that the migration that I expected to be run is in the dist/migrations directory but it does not seem to pick it up.
Is there some configuration or way of telling payload where to look?
I take this as youre not meant to run transpiled migrations:
https://github.com/payloadcms/payload/blob/main/packages/payload/src/database/migrations/readMigrationFiles.ts#L25But does this mean I have to include all of src in my runtime image to be able to run the migrations through typescript?
I'm actually working on a fix for this today 👍
When done it will look in a few places for migrations and also support js files
Great news 🙂 Thanks for letting me know 👍
Will be in the next release:
https://github.com/payloadcms/payload/pull/4292Star
Discord
online
Get dedicated engineering support directly from the Payload team.