Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: allow to track all tables/relationships #1418

Open
benoitscherrer opened this issue Jan 20, 2019 · 22 comments
Open

cli: allow to track all tables/relationships #1418

benoitscherrer opened this issue Jan 20, 2019 · 22 comments
Assignees
Labels
c/cli Related to CLI c/v3-cli k/v3-alpha To be supported in DDN Alpha s/triaged This has been reviewed by Hasura v3

Comments

@benoitscherrer
Copy link

When using Hasura with an existing database, it would be super useful to be able to track all tables and all relationship with the cli (instead of having to go in the console in the browser) (eg for scripts or functional tests)

@ecthiender ecthiender added k/enhancement New feature or improve an existing feature c/cli Related to CLI labels Jan 20, 2019
@dsandip
Copy link
Member

dsandip commented Jan 20, 2019

Similar request on Discord but with a schema as an argument for the command. Maybe have the option to specify a specific schema or all? @shahidhk

@dsandip dsandip added this to the v1.0.0-alpha38 milestone Feb 1, 2019
@dsandip dsandip modified the milestones: v1.0.0-alpha39, v1.0.0-alpha40 Feb 28, 2019
@dsandip dsandip assigned arvi3411301 and unassigned shahidhk Feb 28, 2019
@razakpm
Copy link

razakpm commented Mar 15, 2019

@dsandip my existing database has 2 schemas, I like to have track-all table and relationships automatically without any user intervention, Any way for it. atleast waiting that as a CLI command.

@dsandip
Copy link
Member

dsandip commented Mar 15, 2019

@razakpm This should be available in one of the next couple of releases.

@shahidhk shahidhk added the s/wip Status: This issue is a work in progress label Mar 15, 2019
@shahidhk
Copy link
Member

@arvi3411301 Here is the usage:

# track all tables in public schema
hasura metadata track --all-tables [--schema public]

# track all tables and relationships in public schema
hasura metadata track --all-tables --all-relationships

# track only 2 tables and relationships among them
hasura metadata track --table author --table article --all-relationships

# track all tables in schema1 and schema2
hasura metadata track --all-tables --schema schema1 --schema schema2

# track only one table table1 from schema1
hasura metadata track --table table1 --schema schema1

@shahidhk
Copy link
Member

# untrack all tables in a schema
hasura metadata untrack --all-tables --schema schema1

# untrack only 1 table
hasura metadata untrack --table table1 --schema schema1

@rikinsk-zz rikinsk-zz removed this from the v1.0.0-alpha42 milestone Jun 6, 2019
@ghost
Copy link

ghost commented Jun 20, 2019

@shahidhk would it make sense to have this is a start-up options, so that it can be turned on from docker-compose? triggering a cli tool is not exactly convenient in a containerized environment.

@shahidhk
Copy link
Member

@yyunak You can track all tables once using the console, export the metadata and load it on the container using the migrations image. This metadata will be applied every time the server starts. See: https://docs.hasura.io/1.0/graphql/manual/migrations/auto-apply-migrations.html

@c19
Copy link

c19 commented Jul 4, 2019

any progress on this?

hasura metadata track --all-tables is still not available on 1.0.0-beta.2

@shahidhk
Copy link
Member

shahidhk commented Jul 4, 2019

@c19 This is still a work in progress. Some internals were changed in between and the current PR has to be reworked.

@shahidhk
Copy link
Member

We are looking at some architecture changes for code re-use in console and cli. The current PR needs to be re-worked.

@shahidhk shahidhk removed the s/wip Status: This issue is a work in progress label Sep 10, 2019
@marionschleifer marionschleifer added the k/ideas Discuss new ideas / pre-proposals / roadmap label Sep 10, 2019
@benoitscherrer
Copy link
Author

benoitscherrer commented Sep 10, 2019 via email

@dvasdekis
Copy link

+1 to this. In my development environment, my workflow is currently:

  1. Make a schema change within my Postgres environment and forget to update the Hasura metadata
  2. Redeploy my full docker stack
  3. Hasura can't apply its migrations due to incorrect metadata. I have to read the log to see the failure.
  4. Delete the metadata.json file
  5. Redeploy my full docker stack
  6. Click 'track all' on tables and relationships in Hasura
  7. Export the metadata.json to my repo
  8. Redeploy my full docker stack

I would really really really love :) a way for Hasura to start by tracking all views and relationships with admin-only default permissions, and then I only need to add to the metadata migrations to create non-admin permissions on specific views.

@ctwhome
Copy link

ctwhome commented Jul 26, 2020

@arvi3411301 Here is the usage:

# track all tables in public schema
hasura metadata track --all-tables [--schema public]

# track all tables and relationships in public schema
hasura metadata track --all-tables --all-relationships

# track only 2 tables and relationships among them
hasura metadata track --table author --table article --all-relationships

# track all tables in schema1 and schema2
hasura metadata track --all-tables --schema schema1 --schema schema2

# track only one table table1 from schema1
hasura metadata track --table table1 --schema schema1

this doesn't exist anymore

@thelinuxlich
Copy link

Was this given up because of something else?

@jbek7
Copy link

jbek7 commented Apr 5, 2021

This missing feature would help a lot for CI & CD automation.

@86label
Copy link

86label commented Aug 6, 2021

With a schema-first approach, and automating environment creation, not being able to track all tables and relations programatically makes for a very difficult CI/CD setup.

Any plans to allow track all via CLI again?

@sepbot
Copy link

sepbot commented Jul 13, 2023

i was able to get most of the way there by using results of this api: https://hasura.io/docs/latest/api-reference/metadata-api/relationship/#pg-suggest-relationships but even after i track all the suggested relationships that api returns, there are still some more suggested in the console.

i think this where the console puts together the suggestion list. wish that was in the backend instead haha:

const suggestedRelationshipsRaw = (tableName, allSchemas, currentSchema) => {

@manasag
Copy link
Contributor

manasag commented Nov 23, 2023

Thanks everyone for your comments and patience on this issue. We have been closely listening into all the feedback and requests from the community, and have been working on a re-imagined, re-architectured Hasura, that tackles many of these from ground up.
We are pleased to announce that we are launching V3-Alpha of Hasura (Data Delivery Network) on our next Community call on Nov 30.
V3 puts a lot of emphasise on local dev and CI/CD experiences. The V3 CLI and a brand new Visual Studio plugin in V3 is planned to support such requirements, and very soon. Also, the metadata authoring experience is entirely local and decoupled from live APIs, thus allowing you to iterate without affecting your production APIs.
We would request to join this community call to learn more about Hasura V3. Post launch, we will update this issue with relevant details.

@manasag manasag added k/v3-alpha To be supported in DDN Alpha c/v3-cli and removed k/enhancement New feature or improve an existing feature k/ideas Discuss new ideas / pre-proposals / roadmap a/collab-ci-cd labels Nov 23, 2023
@manasag manasag added the s/triaged This has been reviewed by Hasura label Dec 28, 2023
@poka-IT
Copy link

poka-IT commented Feb 19, 2024

Hasura cli v2.37.0, still unable to autotrack new tables or just use CLI to track new tables in DB.
Do you have news about this simple feature? Do you need help??

@poka-IT
Copy link

poka-IT commented Feb 29, 2024

This is a script which track tables, relationships and functions: https://gist.github.com/poka-IT/0214518dc185370f52223c7dae2edffd

Maybe it could help peoples reading here...

@manasag manasag added the v3 label May 22, 2024
@rkosyicisco
Copy link

@poka-IT Hey thanks for the script
There error mentioned while running
/bin/sh: scripts/export-migrations.sh: No such file or directory - can you also please provide the sh script?

@poka-IT
Copy link

poka-IT commented Oct 7, 2024

This is one version of this file I can found: https://git.duniter.org/nodes/duniter-squid/-/raw/a2da6881689701e48020a9ae6820801cd65ee5d0/scripts/export-migrations.sh

Maybe need to adapt, remove the name from $1, and set your .env.

Not so straight forward, sorry about that.

Our .env.example:

HASURA_GRAPHQL_ADMIN_SECRET=my_hasura_password
HASURA_LISTEN_PORT=8080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/cli Related to CLI c/v3-cli k/v3-alpha To be supported in DDN Alpha s/triaged This has been reviewed by Hasura v3
Projects
None yet
Development

No branches or pull requests