wwwsqldesigner icon indicating copy to clipboard operation
wwwsqldesigner copied to clipboard

postgresql constraints all get the same name

Open torbjorn opened this issue 3 years ago • 2 comments

It seems postgresql schemas get the same name for all constraints for a table (which obviously won't work)

I tried setting up a simple table with a id auto_increment primary key and a code text column that's unique:

This is what it generated:

    CREATE TABLE test (
     id BIGSERIAL,
     code TEXT NOT NULL
    );


    ALTER TABLE test ADD CONSTRAINT test_pkey PRIMARY KEY (id);
    ALTER TABLE test ADD CONSTRAINT test_pkey UNIQUE (code);

Notice how they are both named test_pkey. This does not work.

If I give the constraints specific names, it still doesn't change this behavior.

torbjorn avatar Sep 13 '21 15:09 torbjorn

my solution, maybe you can think of something similar ....;) postgresql_keys-tunning.zip

p43k avatar Oct 27 '21 06:10 p43k

deal with default value:

<xsl:if test="default and not ( default = 'NULL' or default = &quot;'NULL'&quot; )"> <xsl:text> DEFAULT </xsl:text> <xsl:value-of select="default" /> <xsl:text></xsl:text> </xsl:if>

p43k avatar Nov 03 '21 12:11 p43k