From: Philip Hallstrom <phi...@pjkh.com>
Date: Wed, 3 Mar 2010 09:55:29 -0800
Local: Wed, Mar 3 2010 12:55 pm
Subject: Re: [Rails] How to create a UNIQUE table constraint with migrations.
>>>>> Hi. That does indeed look like a bug. I just tried it and it doesn't >>>>> This must be the most obvious thing to do, but I just can't seem >>>>> In deed some migration code that would generate the following SQL >>>>> CREATE TABLE properties ( >>>> create_table :properties..... >>>> add_index :properties, [:namespace, :name], :unique => true >>> After trying this and opening my interactive SQL prompt (psql), I >> Hrm. I can't... Rails 2.3.5, Postgresql 8.4.1 (on mac, but doubt > I am so sorry. I did't do exactly as you said, explanation: > create_table :properties do |t| > That does NOT create an index!!! and therefore neither a constraint!!! > I gues that is a bug in the PostgreSQL adapter. > But when I do as you describe using add_index syntax instead it will > But the fact that 't.index [:namespace, :name], :unique => true' does > Thanks for all help. I appreciate the time you've spent on this. work. What's strange is the source code seems to say that "t.index" simply calls "add_index" just like if I'd done it normally. I just tried it using MySQL as the backend and it does NOT work either. +------------+--------------+------+-----+---------+----------------+ So, at least it's not a postgresql specific bug. You should submit a ticket to the Rails folks... -philip You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||