iCode
iCode14mo ago

basic workflow

Hello! I just have some basic questions on the workflow on convex. What I mean by that is this, once you have a project in production, how do you then iterate on that project (add features, change schema,etc.) with out affecting production? Do you have two convex projects, one for prod, and one for dev? If so, how do you merge your dev changes to prod when ready?
5 Replies
erquhart
erquhart14mo ago
Hey there! Each Convex project has a development and production environment that are completely separate. The general flow is to run the dev server, which uses the dev environment, make your changes, and then when you're ready, deploy to production. You can think of deploys as immutable, so there's nothing to merge. When you deploy, you're deploying just your convex code. If something in your code does not align with your data, breaks schema, etc, the deploy will fail.
iCode
iCodeOP14mo ago
oh nice! How does it handle table changes? Like if i add a column or table. Do i need to run some kind of migration script, or does it do that for me?
erquhart
erquhart14mo ago
Migrations are facilitated through regular convex functions I typically write a migration function, run it in dev, and then run it in production after deploy Sometimes you'll have to do two deploys - for example if you add a new column that should be required, the initial deploy to production will have to leave it optional, then you run a function to populate the field (the migration), then you deploy a change making the field required in production. That said, the basic act of adding a table or column, removing, etc, only requires changing your schema. If you add a table or change a table in your schema and then deploy, convex will make it happen in the database. If it's not possible (like adding a new, empty column and making it required), the deploy will fail.
erquhart
erquhart14mo ago
More on the schema here: https://docs.convex.dev/database/schemas To start, you can just use convex without a schema, and then add the schema when you know how your data will be shaped. It's a really nice way to ease into a new project. If it's a trivial project or you just like living life on the wild side, you can even opt out of using a schema altogether.
Schemas | Convex Developer Hub
Schema validation keeps your Convex data neat and tidy. It also gives you end-to-end TypeScript type safety!
iCode
iCodeOP14mo ago
really appreciate you taking the time to answer my questions! This makes total sense. Looking forward to trying these things out!

Did you find this page helpful?