pgddl icon indicating copy to clipboard operation
pgddl copied to clipboard

Separate functions for pre- and post-data

Open davidfetter opened this issue 6 years ago • 2 comments

As in pg_dump, there should be a way to dump just the bare bones of the DDL first, then the constraints.

davidfetter avatar May 18 '19 20:05 davidfetter

Thanks! I will give this some thought and attention.

Current idea on how to do this is to add a second argument to functions, specifying options on how to dump stuff. Probably of type JSONB or text.

lacanoid avatar May 20 '19 13:05 lacanoid

There is a function ddlx_create_class(regclass) already, which returns bare bones DDL (plus comments).

Other parts can be got by various other functions. See function ddlx_create(regclass) for example.

No need for options, but perhaps more of this should be made public API?

lacanoid avatar Jun 07 '19 19:06 lacanoid

Not understanding how to call ddlx_create(regclass) to only get the constraints for a particular table. Please show an example.

MichaelDBA avatar Apr 30 '23 15:04 MichaelDBA

You can't. Use the new ddlx_definitions function instead.

SELECT constraints 
  FROM ddlx_definitions('my_table'::regclass)

lacanoid avatar Apr 30 '23 19:04 lacanoid

There are now several ways to do this (pre and post data):

  1. Use ddlx_createonly(oid) and ddlx_alter(oid) to get pre and post data parts respectively.
  2. Use ddlx_definitions(oid) and pick the columns you need
  3. Use ddlx_create(oid,'{noalter}') or ddlx_script('{noalter}') to get pre-data only

lacanoid avatar Oct 06 '23 22:10 lacanoid