postgresql check constraint

I am unable to apply a check constraint with liquibase.

Via direct sql I can do this

$psql -c "CREATE TABLE a ( colors text CHECK (colors IN (‘red’, ‘yellow’, ‘blue’))); "

CREATE TABLE

$psql -c ‘\d+ a;’

                           Table “gro.a”

 Column | Type | Modifiers | Storage  | Stats target | Description

--------±-----±----------±---------±-------------±------------

 colors | text |           | extended |              |

Check constraints:

    “a_colors_check” CHECK (colors = ANY (ARRAY[‘red’::text, ‘yellow’::text, ‘blue’::text]))

Has OIDs: no


The check constraint is correctly applied via SQL.


How do I do the above in my xml?

I tried the following 

         

             

         

     

and

         

             

         

     

and

         

             

         

     


However that check constraint does not get registered. What am I missing?


$ psql -c ‘\d+ x;’

                         Table “public.x”

 Column | Type | Modifiers | Storage  | Stats target | Description

--------±-----±----------±---------±-------------±------------

 colors | text |           | extended |              |

Has OIDs: no


$ psql -c ‘\d+ y;’

                         Table “public.y”

 Column | Type | Modifiers | Storage  | Stats target | Description

--------±-----±----------±---------±-------------±------------

 colors | text |           | extended |              |

Has OIDs: no


$ psql -c ‘\d+ z;’

                         Table “public.z”

 Column | Type | Modifiers | Storage  | Stats target | Description

--------±-----±----------±---------±-------------±------------

 colors | text |           | extended |              |

Has OIDs: no

It appears to be a bug. I created https://liquibase.jira.com/browse/CORE-1800 to track the fix. For now, you will have to fall back to the tag and define it yourself (either in the table creation or in an add check constraint statement). 


Or you could use something like in your create table changeSet.


Nathan