Help with primary_key_prefix_type

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?

James B. wrote:

So, what am I doing wrong?

Nothing apparently, see Ticket #10314 (closed defect: fixed).

My next question is how do I get this fix into my (gem) copy of Rails:

Changeset 9057
View differences
Show lines around each change
Ignore:
Blank lines
Case changes
White space changes

Timestamp:
03/18/08 18:36:11 (3 weeks ago)
Author:
bitsweat
Message:

Merge [9056] from trunk: Migrations: create_table supports 

primary_key_prefix_type. References #10314.
Files:

    *
      branches/2-0-stable/activerecord/CHANGELOG (modified) (1 diff)
    *
      branches/2-0-stable/activerecord/lib/active_record/base.rb 

(modified) (1 diff)
*
branches/2-0-stable/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
(modified) (1 diff)

Do I have to checkout and freeze 2-0-stable in vendor plugins?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs