itslekan
itslekan4w ago

My current working solution is to go to

My current working solution is to go to prod after deployment and run the convex function using the dashboard
14 Replies
erquhart
erquhart4w ago
I think you're looking for migrations: https://www.convex.dev/components/migrations
Convex
Migrations
Framework for long running data migrations of live data.
erquhart
erquhart4w ago
As far as when your production backend updates compared to your frontend, the general approach is to make non-breaking updates to your backend. It's really tough to try and guarantee one is deployed before/after the other. I may be missing something about your use case, let me know if so.
itslekan
itslekanOP4w ago
Okay I just saw this flag --prod so what if I do something like this in my package.json
"scripts": {
"dev": "concurrently \"bun dev:backend\" \"bun dev:frontend\"",
"build": "next build",
"start": "next start",
"dev:backend": "convex dev",
"dev:frontend": "next dev",
"prebuild": "convex dev --run init --until-success --prod",
"predev": "convex dev --run init --until-success",
"lint": "next lint"
},
"scripts": {
"dev": "concurrently \"bun dev:backend\" \"bun dev:frontend\"",
"build": "next build",
"start": "next start",
"dev:backend": "convex dev",
"dev:frontend": "next dev",
"prebuild": "convex dev --run init --until-success --prod",
"predev": "convex dev --run init --until-success",
"lint": "next lint"
},
so specifically that prebuild
erquhart
erquhart4w ago
Assuming that init function is successfully running your migrations, that should work (or running whatever you want to run on deploy to prod)
itslekan
itslekanOP4w ago
yh init runs something let's call it a migration it just seeds my database if something are missing the prebuild says convex DEV though I asked the convex ai and there isn't some convex prod cli command
erquhart
erquhart4w ago
oh duh yeah not dev you just want to run the function convex run
erquhart
erquhart4w ago
CLI | Convex Developer Hub
The Convex command-line interface (CLI) is your interface for managing Convex
itslekan
itslekanOP4w ago
Okay thank you so much I think I understand now
erquhart
erquhart4w ago
"prebuild": "convex run init --prod"
itslekan
itslekanOP4w ago
yh exactly
Starlord
Starlord4w ago
how does app know if it has to connect to dev or prod environment? based on process.env?
erquhart
erquhart4w ago
yeah environment variables well, typically anyway. Your client goes off of the url you pass to the convex client, which is typically CONVEX_URL or something. Your local dev cli uses CONVEX_DEPLOYMENT I believe, which is set in your .env.local during local dev
Starlord
Starlord4w ago
ok understand. because i run currently only in dev deployment and my production environment app still can connect to dev automatically without problem
erquhart
erquhart4w ago
Yeah they're both cloud instances

Did you find this page helpful?