Discussion:
[Liquibase-user] problem with unique constraint on postgres
Kerri Reno
2007-12-18 15:50:37 UTC
Permalink
I'm trying to set up a unique constraint as part of my createTable xml.
Following is the entire column tag:
<column name='name' type="varchar(100)">
<constraints nullable='false' unique='true' />
</column>

I get this error on pg:
Migration Failed: Error executing SQL CREATE TABLE
private.lk_ade_approved_areas
(cp_id integer NOT NULL, name varchar(100) NOT NULL, CONSTRAINT
PK_LK_ADE_APPROVED_AREAS PRIMARY KEY (cp_id), CONSTRAINT null UNIQUE (name))

It seems to want me to provide a constraint name, but I don't see a way to
do that in the documentation. I tried adding a constraintName attribute,
but it didn't like that. I know I can add the unique constraint later, but
that's a lot more typing, and this seems to be available in the createTable
xml.

TIA,
Kerri
--
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
***@yumaed.org (928) 502-4240
.·:*šš*:·. .·:*šš*:·. .·:*šš*:·.
Nathan Voxland
2007-12-18 16:31:30 UTC
Permalink
It looks like a bug since the code doesn't currently allow you to specify a constraint name but the SQL requires it. I'll add an issue to the tracker for this so it doesn't get lost. You'll have to go with the extra typing for now, or use the <sql> tag to specify the create table statement with a named unique constraint.



Nathan



From: liquibase-user-***@lists.sourceforge.net [mailto:liquibase-user-***@lists.sourceforge.net] On Behalf Of Kerri Reno
Sent: Tuesday, December 18, 2007 9:51 AM
To: liquibase-***@lists.sourceforge.net
Subject: [Liquibase-user] problem with unique constraint on postgres



I'm trying to set up a unique constraint as part of my createTable xml. Following is the entire column tag:
<column name='name' type="varchar(100)">
<constraints nullable='false' unique='true' />
</column>

I get this error on pg:
Migration Failed: Error executing SQL CREATE TABLE private.lk_ade_approved_areas
(cp_id integer NOT NULL, name varchar(100) NOT NULL, CONSTRAINT PK_LK_ADE_APPROVED_AREAS PRIMARY KEY (cp_id), CONSTRAINT null UNIQUE (name))

It seems to want me to provide a constraint name, but I don't see a way to do that in the documentation. I tried adding a constraintName attribute, but it didn't like that. I know I can add the unique constraint later, but that's a lot more typing, and this seems to be available in the createTable xml.

TIA,
Kerri
--
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
***@yumaed.org (928) 502-4240
.·:*šš*:·. .·:*šš*:·. .·:*šš*:·.
Kerri Reno
2007-12-18 16:52:55 UTC
Permalink
Nathan,

Thanks for your quick response. It's nice to know I wasn't just going nuts!

Kerri
Post by Nathan Voxland
It looks like a bug since the code doesn't currently allow you to specify
a constraint name but the SQL requires it. I'll add an issue to the tracker
for this so it doesn't get lost. You'll have to go with the extra typing
for now, or use the <sql> tag to specify the create table statement with a
named unique constraint.
Nathan
*Sent:* Tuesday, December 18, 2007 9:51 AM
*Subject:* [Liquibase-user] problem with unique constraint on postgres
I'm trying to set up a unique constraint as part of my createTable xml.
<column name='name' type="varchar(100)">
<constraints nullable='false' unique='true' />
</column>
Migration Failed: Error executing SQL CREATE TABLE
private.lk_ade_approved_areas
(cp_id integer NOT NULL, name varchar(100) NOT NULL, CONSTRAINT
PK_LK_ADE_APPROVED_AREAS PRIMARY KEY (cp_id), CONSTRAINT null UNIQUE (name))
It seems to want me to provide a constraint name, but I don't see a way to
do that in the documentation. I tried adding a constraintName attribute,
but it didn't like that. I know I can add the unique constraint later, but
that's a lot more typing, and this seems to be available in the createTable
xml.
TIA,
Kerri
--
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
.·:*šš*:·. .·:*šš*:·. .·:*šš*:·.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Liquibase-user mailing list
https://lists.sourceforge.net/lists/listinfo/liquibase-user
--
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
***@yumaed.org (928) 502-4240
.·:*šš*:·. .·:*šš*:·. .·:*šš*:·.
Peter Murray
2007-12-18 17:26:10 UTC
Permalink
There is a problem with allowing the constraint name to be specified in this situation on some databases.



Oracle requires some constraints to have names, like unique and foreign keys (there may be others too). So if you happen to specify both of these in the <constraints> tag then you would have to specify multiple names.



- Peter



From: liquibase-user-***@lists.sourceforge.net [mailto:liquibase-user-***@lists.sourceforge.net] On Behalf Of Kerri Reno
Sent: 18 December 2007 16:53
To: liquibase-***@lists.sourceforge.net
Subject: Re: [Liquibase-user] problem with unique constraint on postgres



Nathan,

Thanks for your quick response. It's nice to know I wasn't just going nuts!

Kerri

On 12/18/07, Nathan Voxland < ***@sundog.net <mailto:***@sundog.net> > wrote:

It looks like a bug since the code doesn't currently allow you to specify a constraint name but the SQL requires it. I'll add an issue to the tracker for this so it doesn't get lost. You'll have to go with the extra typing for now, or use the <sql> tag to specify the create table statement with a named unique constraint.



Nathan



From: liquibase-user-***@lists.sourceforge.net [mailto:liquibase-user-***@lists.sourceforge.net] On Behalf Of Kerri Reno
Sent: Tuesday, December 18, 2007 9:51 AM
To: liquibase-***@lists.sourceforge.net
Subject: [Liquibase-user] problem with unique constraint on postgres



I'm trying to set up a unique constraint as part of my createTable xml. Following is the entire column tag:
<column name='name' type="varchar(100)">
<constraints nullable='false' unique='true' />
</column>

I get this error on pg:
Migration Failed: Error executing SQL CREATE TABLE private.lk_ade_approved_areas
(cp_id integer NOT NULL, name varchar(100) NOT NULL, CONSTRAINT PK_LK_ADE_APPROVED_AREAS PRIMARY KEY (cp_id), CONSTRAINT null UNIQUE (name))

It seems to want me to provide a constraint name, but I don't see a way to do that in the documentation. I tried adding a constraintName attribute, but it didn't like that. I know I can add the unique constraint later, but that's a lot more typing, and this seems to be available in the createTable xml.

TIA,
Kerri
--
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
***@yumaed.org (928) 502-4240
.·:*šš*:·. .·:*šš*:·. .·:*šš*:·.


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Liquibase-user mailing list
Liquibase-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/liquibase-user
--
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
***@yumaed.org (928) 502-4240
.·:*šš*:·. .·:*šš*:·. .·:*šš*:·.


Disclaimer:

The contents of this E-mail plus any attachment is intended for the use of the
addressee only and is confidential, proprietary and may be privileged. It will not be
binding upon Trace Group plc or any group company (Trace). Opinions, conclusions,
contractual obligations and other information in this message in so far as they relate to
the official business of Trace must be specifically confirmed in writing by Trace. If you
are not the intended recipient you must not copy this message or attachment, use or
disclose the contents to any other person, but are requested to telephone or E-mail
the sender and delete the message and any attachment from your system. Trace
takes all reasonable precautions to ensure that no virus or defect is transmitted via
this e mail, however Trace accepts no responsibility for any virus or defect that might
arise from opening this E-mail or attachments.
Kerri Reno
2007-12-18 17:35:12 UTC
Permalink
Nathan,

Actually, postgres doesn't require a constraint name, if you just add the
key word 'unique' to the column line.

Kerri
Post by Kerri Reno
Nathan,
Thanks for your quick response. It's nice to know I wasn't just going nuts!
Kerri
Post by Nathan Voxland
It looks like a bug since the code doesn't currently allow you to
specify a constraint name but the SQL requires it. I'll add an issue to the
tracker for this so it doesn't get lost. You'll have to go with the extra
typing for now, or use the <sql> tag to specify the create table statement
with a named unique constraint.
Nathan
*Sent:* Tuesday, December 18, 2007 9:51 AM
*Subject:* [Liquibase-user] problem with unique constraint on postgres
I'm trying to set up a unique constraint as part of my createTable xml.
<column name='name' type="varchar(100)">
<constraints nullable='false' unique='true' />
</column>
Migration Failed: Error executing SQL CREATE TABLE
private.lk_ade_approved_areas
(cp_id integer NOT NULL, name varchar(100) NOT NULL, CONSTRAINT
PK_LK_ADE_APPROVED_AREAS PRIMARY KEY (cp_id), CONSTRAINT null UNIQUE (name))
It seems to want me to provide a constraint name, but I don't see a way
to do that in the documentation. I tried adding a constraintName attribute,
but it didn't like that. I know I can add the unique constraint later, but
that's a lot more typing, and this seems to be available in the createTable
xml.
TIA,
Kerri
--
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
.·:*šš*:·. .·:*šš*:·. .·:*šš*:·.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Liquibase-user mailing list
https://lists.sourceforge.net/lists/listinfo/liquibase-user
--
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
.·:*šš*:·. .·:*šš*:·. .·:*šš*:·.
--
Yuma Educational Computer Consortium
Compass Development Team
Kerri Reno
***@yumaed.org (928) 502-4240
.·:*šš*:·. .·:*šš*:·. .·:*šš*:·.
Loading...