Graphql-engine: enable automatic addition of commonly used fields when creating tables

Created on 24 Jan 2019  ·  9Comments  ·  Source: hasura/graphql-engine

Corresponds to idea's raised in #1077.

Currently can be implemented with a default now() for created_at and an update trigger for updated_at. Nevertheless, this has to be added manually for every table.

Add an option to be ticked by the developer in the console when creating a table that adds these fields, default and trigger automatically.

console intermediate mockup-required 🖊️ medium wip

Most helpful comment

Commonly used fields:
1) created_at (timestamp; defaults to now())
2) updated_at (timestamp; is set by trigger to now())
3) Primary Key - Id (Integer auto-increment; automatically added as PKey)
4) Primary Key - UUID (UUID; defaults to gen_random_uuid(); automatically added as PKey)

All 9 comments

I see (for now already) two options to alter the console:

  1. add a checkbox 'add created and updated timestamps' to the checkboxes while creating a table
  2. add a button to the modify table page 'add created and update timestamps'
  3. more....

The first only enables the user to add them at creation time of the table. The second enables the user to add them at anytime but requires some more logic to check if the fields where already added previously.

@tombroens, @0x777 Any news about this?
I think it can be very useful. :wink:

You can use this for now till we add it in the console:

Commonly used fields:
1) created_at (timestamp; defaults to now())
2) updated_at (timestamp; is set by trigger to now())
3) Primary Key - Id (Integer auto-increment; automatically added as PKey)
4) Primary Key - UUID (UUID; defaults to gen_random_uuid(); automatically added as PKey)

@dsandip, @wawhal Maybe relate: #1936, #1980
Add deleted_at for soft delete support based on current docs.

Is there an eta for this?

@napalm272 This feature has been implemented and is under review. It should be released sometime next week

has this been released yet?

@napalm272 Sorry for the delay in this. There were a couple of issues which had been highlighted during the review. Hence some further changes needed to be made. They are done now and this is back up for review. It should be released in a day or two now ideally.

Was this page helpful?
0 / 5 - 0 ratings