Upgrading from Nhost v1 to v2 requires database schema and Hasura metadata changes.
Make sure you have the Nhost CLI installed.
nhost init my-nhost-v2-app cd my-nhost-v2-app
version: 3 to
version: 2 in
nhost/config.yaml. This will update Hasura's configuration version, and we need to downgrade the version when we export migrations and metadata.
nhost/ folder of your app, run:
hasura migrate create init --from-server --endpoint=[v1-endpoint] --admin-secret=[v1-admin-secret] hasura metadata export --endpoint=[v1-endpoint] --admin-secret=[v1-admin-secret]
Make the following changes manually to your migrations.
The migration file is located at
OR REPLACE after
CREATE for the
auth.* tables and functions (if any).
public.users table and everything related to the table such as constraints, triggers, etc.
Update FK references from
auth.users (if any).
Make the following changes manually to your metadata.
The metadata is located at
Delete tracking all tables in the
Delete tracking the
Update all references to
users from the
Start Nhost locally using the CLI. From the root of your app, run:
nhost -d applies your local database migrations and Hasura metadata.
Open Docker UI and restart Hasura Auth and Hasura Storage. Restarting those containers applies new metadata, effectively tracking everything in the
auth and the
Delete the local migrations and metadata.
rm -rf nhost/migrations nhost/metadata
config: 2 to
config: 3 in
nhost/ folder, run the following command:
hasura migrate create init --from-server --endpoint=http://localhost:[hasura-port] --admin-secret=nhost-admin-secret hasura metadata export --endpoint=http://localhost:[hasura-port] --admin-secret=nhost-admin-secret
Note: You cannot use port
1337 in the commands above. You have to use the specific port Hasura uses. Go to the Hasura Console under API and look for the port Hasura is using under GraphQL Endpoint.
You now have a Nhost v2 project locally with correct migrations and metadata.
To fully migrate, you need to transfer data from v1 to v2. This can be done in three steps:
Read data from v1
Modify data so it can be imported to v2
Write data to v2
You can also use TransferGraph, an open source tool from the community that helps you do this.