Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Create Table forces table_name pluralization when inferring relationships #98

Open
krobi64 opened this issue Apr 5, 2013 · 0 comments

Comments

@krobi64
Copy link

krobi64 commented Apr 5, 2013

Second Issue: (Rails 3.2.12)

Migration Files:

class CreateSnakeCaseTableA < ActiveRecord::Migration
  def up
    create_table :snake_case_table_a, :force => true do |t|
      t.string :name
    end
  end

  def down
    drop_tabe :snake_case_table_a
  end
end

and

class CreateSnakeCaseTableB < ActiveRecord::Migration
  def up
    create_table :snake_case_table_b, :force => true do |t|
      t.integer :snake_case_table_a_id
      t.string :name
    end
  end

  def down
    drop_tabe :snake_case_table_a
  end
end

rake db:migrate yields:

==  CreateSnakeCaseTableA: migrating ==========================================
-- create_table(:snake_case_table_a, {:force=>true})
   -> 0.0879s
==  CreateSnakeCaseTableA: migrated (0.0880s) =================================

==  CreateSnakeCaseTableB: migrating ==========================================
-- create_table(:snake_case_table_b, {:force=>true})
rake aborted!
An error has occurred, all later migrations canceled:

Mysql2::Error: Can't create table 'example-app_development.snake_case_table_b' (errno: 150): CREATE TABLE `snake_case_table_b` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `snake_case_table_a_id` int(11), `name` varchar(255), CONSTRAINT fk_snake_case_table_b_snake_case_table_a_id FOREIGN KEY (`snake_case_table_a_id`) REFERENCES `snake_case_table_as` (`id`)) ENGINE=InnoDB/Users/krobison/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `query'
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant