X
Xata3w ago
brettski

What is the general SDLC when using Xata?

We are starting a new project utilizing Xata. I am not understanding the ways to build out our data structure. Can this be done and maintained in code, or is all the data structure configured in the Xata.io UI? At this point we are looking to use Xata natively and not with an ORM like Drizzle.
6 Replies
tsg
tsg3w ago
In that case, yes, you’d create the schema using the UI and then when you run xata pull or run the code generator it is saved in the xata.ts file. You can then use the types in your code
brettski
brettski3w ago
Is there a way to define the schema in code and push it? This way all changes, code and schema live in the repo, tagged at that version, etc.
tsg
tsg3w ago
You can do xata schema dump and xata schema load which work with JSON. So you can have a schema.json file that can always be loaded. This is what we typically do in our open source projects. But also if you follow the workflow above, you will have the schema in the repo, embedded in the xata.ts file.
brettski
brettski3w ago
Thank you @tsg ; I appreciate your time. It feels different having the datastore updated prior to a deployment. I am not sure how I would deploy to a staging/preview environment and then a production environment. How do I ensure I don't miss any datastore settings, e.g., constraints, relationships, etc.? Thus, I am assuming that I am going into the UI to manually update the preview datastore and then manually update the production datastore.
I am not sure how I would deploy to a staging/preview environment and then a production environment. How do I ensure I don't miss any datastore settings, e.g., constraints, relationships, etc.?
Any suggestions? Could this be covered with the xata schema load workflow?
tsg
tsg3w ago
sorry, forgot to come back here. The general workflow idea with the Xata SDK is: * you create a development branch, and use that while developing. * you modify the schema via UI as you'd like to. * when you do xata pull, your xata.ts is generated but also a set of migration files are stored in .xata/migrations. * when you merge the git branch, the new migrations will show up in .xata/migrations in the main branch. * a xata push there (this is normally done during deployment by CI/CD) will bring the DB up to date. It is documented here: https://xata.io/docs/getting-started/workflow The reason I mentioned xata schema dump / xata schema load is in case you want a full point-in-time representation of the schema in the repository. We do this usually for our open source projects, to bootstrap the project easier. Note that this works best as long as you are using the Xata SDK, like you mentioned. If you prefer to use SQL and an ORM like Drizzle or Prisma, it might be better to follow their way of storing migrations and the like.
PR based workflow
Learn about core the Xata workflow, branching, and migrations using GitHub with Netlify or Vercel
brettski
brettski2w ago
Thank you!
Want results from more Discord servers?
Add your server