I put this config in environment.rb
Use table_id instead of id for primary key.
config.active_record.primary_key_prefix_type =
:table_name_with_underscore
I have this migration:
class CreateEntities < ActiveRecord::Migration
def self.up
create_table :entities do |t|
t.string :entity_name, :null => false,
:limit => 40
t.string :entity_legal_name, :null => false,
:limit => 120
t.string :entity_legal_form, :null => false,
:limit => 4
t.timestamps
end
add_index :entities, :entity_name,
:name => :idxU_entities_entity_name,
:unique => true
end
def self.down
remove_index :entities, :name => :idxU_entities_entity_name
drop_table :entities
end
end
When I run these rake tasks:
rake db:drop
rake migrate
Then I see this:
sqlite3 db/development.sqlite3
SQLite version 3.3.6
Enter “.help” for instructions
sqlite> .schema entities
CREATE TABLE entities (“id” INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
“entity_name” varchar(40) NOT NULL, “entity_legal_name” varchar(120) NOT
NULL, “entity_legal_form” varchar(4) NOT NULL, “created_at” datetime
DEFAULT NULL, “updated_at” datetime DEFAULT NULL);
But I expected to see this:
CREATE TABLE entities (“entity_id” INTEGER PRIMARY KEY AUTOINCREMENT NOT
NULL,…
It makes no difference if I pass the value to
config.active_record.primary_key_prefix_type as a string or a symbol as
neither works.
So, what am I doing wrong?