Graphql-engine: Allow rearranging columns in the underlying postgres table via console

Created on 18 Feb 2019  ·  8Comments  ·  Source: hasura/graphql-engine

It'd be nice.

console server ideas

Most helpful comment

It's not a high priority thing at all. Just a cool feature idea. Definitely fix bugs and such first.

It affects me because I mess around with my table structures _a lot_ in development, and sometimes I'll have a table with some foreign keys or other extra-relevant information, and that data will be hard to find within dozens of less-important columns.

For instance, say I have a Users table with:

id | first_name | last_name | bio | auth_token | street_address | city | state | zip_code | etc | etc | etc

And then I go _"Oops, I wish I would've put email on there. I'll use that all the time and would like to be able to see this field frequently while browsing this table."_

So ideally I'd just put it at the very beginning of the column list like so:

id | *email* | first_name | last_name | bio | auth_token | street_address | city | state | zip_code | etc | etc | etc

Then coworkers and I could spot it and reference it easily.

But in its current state I'd have to drop the entire table manually, recreate it, etc.

Basically, the same reason as everyone else who has Googled for a solution to this except Hasura is actually in a position to build this into your Console.

Again, these little features add up to make a really amazing product. I might be showing a friend Hasura, and shift around some columns, and they'll be like "Wait, did you just rearrange columns in Postgres just by clicking/dragging? Nice!" and you'll have a convert. 🤷‍♂️

All 8 comments

Would also be nice if one could disable a column for not showing (for example JSON columns with large content...). It can get pretty difficult to work with if you have a lot of data in there...

@rikinsk The PR doesn't really address the original issue.

In the review app, it looks like you can click an arrow to collapse columns (a - and + icon would better represent this btw), but the original issue would allow dragging and dropping columns to rearrange them.

It wouldn't just be a clientside change either. Hasura would need to:

  1. Create a new table with the columns in the correct position—with some name that a user couldn't reasonably have (e.g. ________ASDFQWERTY____________).
  2. Migrate table data to that new table.
  3. Delete old table.
  4. Rename new table to whatever old table was named.
  5. Do all of this in a transaction to protect integrity.

I wouldn't do it from the "Browse" view either. I'd do it in the "Modify" view, and add a "Save" button with a loading animation to confirm the re-ordering.

I know it's a lot of effort for what seems like a little benefit, but re-ordering columns in Postgres would be a really nice touch.

These little features add up and will really set Hasura apart.

Request to re-open this issue please.

@corysimmons Just to help us prioritize, how does the order of columns in Postgres affect you?

It's not a high priority thing at all. Just a cool feature idea. Definitely fix bugs and such first.

It affects me because I mess around with my table structures _a lot_ in development, and sometimes I'll have a table with some foreign keys or other extra-relevant information, and that data will be hard to find within dozens of less-important columns.

For instance, say I have a Users table with:

id | first_name | last_name | bio | auth_token | street_address | city | state | zip_code | etc | etc | etc

And then I go _"Oops, I wish I would've put email on there. I'll use that all the time and would like to be able to see this field frequently while browsing this table."_

So ideally I'd just put it at the very beginning of the column list like so:

id | *email* | first_name | last_name | bio | auth_token | street_address | city | state | zip_code | etc | etc | etc

Then coworkers and I could spot it and reference it easily.

But in its current state I'd have to drop the entire table manually, recreate it, etc.

Basically, the same reason as everyone else who has Googled for a solution to this except Hasura is actually in a position to build this into your Console.

Again, these little features add up to make a really amazing product. I might be showing a friend Hasura, and shift around some columns, and they'll be like "Wait, did you just rearrange columns in Postgres just by clicking/dragging? Nice!" and you'll have a convert. 🤷‍♂️

@coco98 Any news or progress on this?

This is not something we plan to pick up anytime soon.

Just to clarify, this issue is for making the column order changes peristed on to the postgres table.

We will soon be adding support for persisting column order and collapsed status on the Browse rows section of console (#3390) so that it doesn't have to be done eveytime one visits it.

It's also possible to run a few SQL statements via the console to do this manually in the meantime: https://wiki.postgresql.org/wiki/Alter_column_position

It might require changing a few other related things manually though!

Closed for now!
We are working on #3390 which should alleviate some of the problems on this thread.
For a manual fix, refer to: https://wiki.postgresql.org/wiki/Alter_column_position

Was this page helpful?
0 / 5 - 0 ratings

Related issues

codepunkt picture codepunkt  ·  3Comments

hooopo picture hooopo  ·  3Comments

cpursley picture cpursley  ·  3Comments

Fortidude picture Fortidude  ·  3Comments

bogdansoare picture bogdansoare  ·  3Comments