I have this for my migration:
class CreateCategories < ActiveRecord::Migration
def up
create_table :categories do |t|
t.integer :parent_id
t.string :title, :null => false
end
execute('CREATE UNIQUE INDEX ix_categories_root_title ON categories (title) WHERE parent_id IS NULL')
end
def down
drop_table :categories
end
end
But when I peeked into db/schema.rb I saw this instead:
ActiveRecord::Schema.define(:version => 20110808161830) do
create_table "categories", :force => true do |t|
t.integer "parent_id"
t.string "title", :null => false
end
add_index "categories", ["title"], :name => "ix_categories_root_title", :unique => true
end
Which obviously isn't the same thing and incorrect. Is there anyway to force schema.rb to create the same index? I'm using postresql with Rails 3.1 pre.