hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
31.11k stars 2.76k forks source link

[Feature Request] Move table from a schema to another #2776

Open mnlbox opened 5 years ago

mnlbox commented 5 years ago

Hi guys, I created some table in public schema and now I want to move that table to a new schema. I think this is a very useful feature that we can move table from one schema to another in console.
Please vote up this if you agree with this. :wink:

mrcampbell commented 5 years ago

I love this! I know it can be done with SQL, but if Hasura could migrate it, it could update relationships and the meta tables (hdb_*) automatically.

rakeshkky commented 4 years ago

@mnlbox @Mrcampbell You can run the ALTER TABLE .. query in the Run SQL section of the console and move the table from one schema to another schema. The server will take care of migrating relationship/permission definition in the metadata tables (hdb_*) :slightly_smiling_face:

Example:-

-- move table "foo" from public to test schema
alter table foo set schema test;

However, altering multiple tables' schema (in the same query) may result in an error if tables have relationships defined on each other. See https://github.com/hasura/graphql-engine/issues/3059

The console should support moving tables across schemas under the Modify section in UI.

mnlbox commented 4 years ago

@rakeshkky Any plan for this in roadmap?

rakeshkky commented 4 years ago

@mnlbox We'll add support to console in upcoming weeks. Till then you can try manually moving a table from one schema to another using ALTER .. statement in SQL section of console UI (DATA -> SQL)

mnlbox commented 4 years ago

@rakeshkky Any update on this feature?

mikiastilahun commented 1 month ago

@rakeshkky This feature would be very helpful.