0

I'm trying to setup a migration file for a habtm relationship, however when I run the migration I'm getting the following error:

Primary key is not allowed in a has_and_belongs_to_many join table (parts_vehicles).

Here is my migration file (20110111035950_create_parts_vehicles.rb):

class CreatePartsVehiclesJoinTable < ActiveRecord::Migration
  def self.up
    create_table :parts_vehicles, :id => false do |t|
      t.integer :part_id
      t.integer :vehicle_id
    end
  end

  def self.down
    drop_table :parts_vehicles
  end
end

The documentation example states to use :id => false to disable a primary key from being generated, but I'm still getting the error.

Brian Wigginton
  • 2,632
  • 3
  • 21
  • 28

1 Answers1

1

1.) You're class name should be the same as your migration name:

class CreatePartsVehicles < ActiveRecord::Migration

2.) Did you migrate? Try dropping your db (rake db:drop) and remigrating (rake db:migrate)

sethvargo
  • 26,739
  • 10
  • 86
  • 156