这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@arvi3411301
Copy link
Member

@arvi3411301 arvi3411301 commented Mar 26, 2019

Description

CLI will be having the below command in order to track and untrack tables, relationships across schemas.

# 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

# track all tables relationships, but export as migration
hasura metadata track --export-as-migration
# untrack all tables in a schema
hasura metadata untrack --all-tables --schema schema1

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

Affected components

  • CLI
  • Docs

Related Issues

#1418

Solution and Design

Steps to test and verify

Limitations, known bugs & workarounds

Table and relationships across schemas cannot be tracked

@arvi3411301 arvi3411301 added c/cli Related to CLI s/wip Status: This issue is a work in progress labels Mar 26, 2019
@netlify
Copy link

netlify bot commented Mar 26, 2019

Deploy preview for hasura-docs ready!

Built with commit 0596a44

https://deploy-preview-1876--hasura-docs.netlify.com

@hasura-bot
Copy link
Contributor

Review app for commit 56551e9 deployed to Heroku: https://hge-ci-pull-1876.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1876-56551e9

@hasura-bot
Copy link
Contributor

Review app for commit 2e68cb3 deployed to Heroku: https://hge-ci-pull-1876.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1876-2e68cb3

@karthikvt26
Copy link
Contributor

karthikvt26 commented Mar 27, 2019

./hasura-dev metadata track --table table_1 --table table_2 --all-relationships

screenshot 808

The issue is table_2 has a foreign key to table_3 and the command is trying to track that too.

This issue is there on console too tracked in #1882

  1. Trying to track the already tracked table responds with a success message.

➜ ./hasura-dev metadata track --table table_1 --table table_2

screenshot 810

@arvi3411301 @shahidhk

  1. ./hasura-dev metadata untrack --table table1

INFO untrack command executed successfully

table1 doesn't exist. Should it say that?

@arvi3411301
Copy link
Member Author

arvi3411301 commented Mar 27, 2019

@shahidhk What should we do in this case? Track only the relationships with the reference table name matches the --table flag?

@arvi3411301
Copy link
Member Author

@karthikvt26 Is the relationships name generated is according to the console?

@karthikvt26
Copy link
Contributor

@arvi3411301 Yes

@shahidhk
Copy link
Member

  1. We should only track relations across the tables and schema that are being tracked.
  2. Trying to track a table that is already tracked should succeed, but with a message saying the table is already tracked.
  3. Tracking a table that doesn't exist should fail.

Also, while tracking all tables relations etc, the logs should clearly output what is tracked.

@arvi3411301 arvi3411301 marked this pull request as ready for review March 29, 2019 10:24
@arvi3411301 arvi3411301 requested a review from shahidhk as a code owner March 29, 2019 10:24
@hasura-bot
Copy link
Contributor

Review app for commit 4027118 deployed to Heroku: https://hge-ci-pull-1876.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1876-4027118

@rikinsk-zz
Copy link

Trying to track a table that is already tracked should succeed, but with a message saying the table is already tracked.

Will this also work for the track metadata API. Currently on SQL page if the checkbox is tracked and the table is already tracked the entire operation fails

@hasura-bot
Copy link
Contributor

Review app for commit 81852c8 deployed to Heroku: https://hge-ci-pull-1876.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1876-81852c8

@arvi3411301
Copy link
Member Author

@karthikvt26 I had fixed column conflicts. Can you try again if this build fixes all issues?

@hasura-bot
Copy link
Contributor

Review app for commit de663c8 deployed to Heroku: https://hge-ci-pull-1876.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1876-de663c8

@hasura-bot
Copy link
Contributor

Review app for commit 474ab73 deployed to Heroku: https://hge-ci-pull-1876.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1876-474ab73

@karthikvt26
Copy link
Contributor

@arvi3411301 Running with --table and --all-relationship option is not tracking the relationships

➜  my-project ./hasura-dev metadata track --table table_1  --all-relationships
ERRO auto-update failed, run 'hasura update-cli' to update manually  error="cannot update from a non-semver version: pull1876-474ab73"
INFO tables/relationships tracked successfully    
➜  my-project ./hasura-dev metadata track --table table_2  --all-relationships
ERRO auto-update failed, run 'hasura update-cli' to update manually  error="cannot update from a non-semver version: pull1876-474ab73"
INFO tables/relationships tracked successfully    

screenshot 834
screenshot 833

@arvi3411301
Copy link
Member Author

arvi3411301 commented Apr 4, 2019

@karthikvt26 In order to track relationships across tables, you need to specify --table table2.

So, the command will be

hasura metadata track --table table1 --table table2 --all-relationships

@karthikvt26
Copy link
Contributor

Ok the message is slightly confusing then (table/relationships tracked successfully)

@arvi3411301
Copy link
Member Author

arvi3411301 commented Apr 4, 2019

@karthikvt26 We will be adding info/warn messages if something is missing.

Something like,

WARN: relationship referencing to table2 (cols) from table1 (cols) cannot be created since --table table2 is missing from command.

But at the end, table/relationships tracked successfully will be displayed to the user if there are metadata actions present in the bulk query.

@karthikvt26
Copy link
Contributor

karthikvt26 commented Apr 4, 2019

@arvi3411301 No no can we add logs as

  1. INFO tables tracked successfully
  2. INFO relationships tracked successfully (will not be there if no relationships are tracked)

@shahidhk

@hasura-bot
Copy link
Contributor

Review app for commit 85265d3 deployed to Heroku: https://hge-ci-pull-1876.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1876-85265d3

@hasura-bot
Copy link
Contributor

Review app for commit 6fe34aa deployed to Heroku: https://hge-ci-pull-1876.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1876-6fe34aa

@dsandip dsandip added this to the release-candidates milestone Apr 15, 2019
@hasura-bot
Copy link
Contributor

Review app for commit 0596a44 deployed to Heroku: https://hge-ci-pull-1876.herokuapp.com
Docker image for server: hasura/graphql-engine:pull1876-0596a44

@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-1876.herokuapp.com is deleted

@arvi3411301 arvi3411301 deleted the issue-1418 branch June 20, 2019 10:19
@shahidhk
Copy link
Member

@arvi3411301 Why was this closed?

@arvi3411301
Copy link
Member Author

@shahidhk need to rewrite everything. Will open a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c/cli Related to CLI s/wip Status: This issue is a work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants