开发者

Migration a has_and_belongs_to_many join table don't create the table

I'm develop a web app with Rails 3.0.9 and Postgres 9.4

I'm trying to create a join table for a has_and_belongs_to_many association, but when execute "rake db:migrate" the only one not executed migration is the migration for join table. Rails didn't show any error, only didn't create the table. When I do the rollback, rails show a error because couldn't drop the table because don't exist.

Here is the code of migration:

class CreateCampanaLocalJoinTable < ActiveRecord::Migration
  def self.up
    d开发者_开发知识库ef change
      create_table :campanas_locals, :id => false do |t|
        t.integer :campana_id
        t.integer :local_id
      end
    end
  end

  def self.down
    drop_table :campanas_locals
  end
end

Anyone have an idea? Thanks!


Rails 3.0.X try:

class CreateCampanaLocalJoinTable < ActiveRecord::Migration
  def self.up
    create_table :campanas_locals, :id => false do |t|
      t.integer :campana_id
      t.integer :local_id
    end
  end

  def self.down
    drop_table :campanas_locals
  end
end

Rails 3.1.X try:

class CreateCampanaLocalJoinTable < ActiveRecord::Migration
  def change
    create_table :campanas_locals, :id => false do |t|
      t.integer :campana_id
      t.integer :local_id
    end
  end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜