Is possible to run migrations in Pages build command?
I'm not sure what is the right flow to run D1 migrations... If I understand it correctly so far, you have to:
Push migrations with a command:
npx wrangler d1 migrations apply db-name
as a wrangler command from the local env to make changes in the prod. DB
and then push the changed app code (wich rely on new DB schema) to git.
Shouldn't be a migration run right after the deployment in the "build command" like:
npm run build && npx wrangler d1 migrations apply db-name
Is this possible?
I tried the comamnd and got the error:
After creating CLOUDFLARE_API_TOKEN env var I get this error:
4 Replies
hey, is there any answer to this?
The way I've tackled this issue is by using github actions to deploy and push to pages, and then run a command after which runs migrations
This is my example preview deployment,yml
awesome thanks
Replace the preCommands
npx @cloudflare/next-on-pages@1
with npm run build
or whatever :awesome: