我发现这个过程运作良好。
创建一个干净的空本地 postgresql 数据库和 Hasura 实例。要更新现有的本地数据库,请将其删除并重新创建。
从现有的 Hasura 服务器中转储模式和数据(按照@protob 的答案,但clean_output设置了这样就不必对输出进行手动更改。有关详细信息,请参阅pgdump 。
curl --location --request POST 'https://example.com/v1alpha1/pg_dump' \
--header 'Content-Type: application/json' \
--header 'X-Hasura-Role: admin' \
--header 'Content-Type: text/plain' \
--header 'x-hasura-admin-secret: {SECRET}' \
--data-raw '{ "opts": ["-O", "-x","--inserts", "--schema", "public"], "clean_output": true}' > hasura-db.sql
Run Code Online (Sandbox Code Playgroud)
本地导入架构和数据:
psql -h localhost -U postgres < hasura-db.sql
Run Code Online (Sandbox Code Playgroud)
本地数据库拥有所有迁移,因为我们复制了最新的架构,因此只需将它们标记为已应用:
curl --location --request POST 'https://example.com/v1alpha1/pg_dump' \
--header 'Content-Type: application/json' \
--header 'X-Hasura-Role: admin' \
--header 'Content-Type: text/plain' \
--header 'x-hasura-admin-secret: {SECRET}' \
--data-raw '{ "opts": ["-O", "-x","--inserts", "--schema", "public"], "clean_output": true}' > hasura-db.sql
Run Code Online (Sandbox Code Playgroud)
现在最终使用 hasura CLI 应用 Hasura 元数据:
hasura metadata apply
Run Code Online (Sandbox Code Playgroud)
享受您的新实例吧!
| 归档时间: |
|
| 查看次数: |
1809 次 |
| 最近记录: |