Start Nhost locally:
Make sure you have Docker installed on your computer. It’s required for Nhost to work.
nhost dev command will automatically start a complete Nhost environment locally on your computer using:
- Serverless Functions
You use this local environment to do changes and testing before you deploy your changes to production.
nhost dev also starts the Hasura Console.
It's important that you use the Hasura Console that is started automatically when you do changes. This way, changes are automatically tracked for you.
In the Hasura Console, create a new table
customers with two columns:
When we created the
customers table there was also a migration created automatically. The migration was created at under
$ ls -la nhost/migrations/default
drwxr-xr-x 3 eli staff 96 Feb 7 16:19 .
drwxr-xr-x 3 eli staff 96 Feb 7 16:19 ..
drwxr-xr-x 4 eli staff 128 Feb 7 16:19 1644247179684_create_table_public_customers
This database migration has only been applied locally, meaning, you created the
customers table locally but it does not (yet) exists in production.
To apply the local change to production we need to commit the changes and push it to GitHub. Nhost will then automatically pick up the change in the repository and apply the changes.
You can commit and push files in another terminal while still having
nhost dev running.
git add -A
git commit -m "Initialized Nhost and added a customers table"
Head over to the Deployments tab in the Nhost console to see the deployment.
Once the deployment finishes the
customers table is created in production.
We've now completed the recommended workflow with Nhost:
- Develop locally using the Nhost CLI.
- Push changes to GitHub.
- Nhost deploys changes to production.