Skip to content

MySql connection adapter forces int(11) for primary keys #2573

Closed
maletor opened this Issue Aug 17, 2011 · 9 comments

6 participants

@maletor
maletor commented Aug 17, 2011

This line freezes such that I cannot make my primary column a varchar(255).

Is there any good reason for this? If yes then why allow set_primary_key to non integers within the model?

@rosshale

Same problem here. Most notably, every time we dump the schema

:id => false 

and

t.string "id" 

get stripped out of the schema

@isaacsanders

@maletor Is this still an issue?

@maletor
maletor commented Apr 30, 2012

Yes, I add these lines to my spec_helper.rb before(:suite).

ActiveRecord::Base.connection.execute('ALTER TABLE comments MODIFY code varchar(255) NOT NULL')
ActiveRecord::Base.connection.execute('ALTER TABLE subcomments MODIFY code varchar(255) NOT NULL')
@vipulnsward
Ruby on Rails member

This also makes auto_increment to be added by default, which doesn't seem to be configurable.

@schneems
Ruby on Rails member

I would ❤️ the ability to use a UUID from postgres for my primary keys, but unless we have some docs that says otherwise, this looks like a feature request instead of a bug report. WDYT?

@vipulnsward
Ruby on Rails member

@schneems I have been working on a PR to close this. Something allowing configurable primary keys. Would like feedback on if

create_table :testings, :id => false, :primary_key => { column definition here } do |t|

end

would be considerate.

Support for previous :primary_key => :column_name would still be maintained.

Not sure, if I should be asking for feedback here or on rails-core.

@vipulnsward
Ruby on Rails member

This can be closed since @tenderlove implemented series of patches upto bc8ebef

@senny
Ruby on Rails member
senny commented Apr 30, 2013

Thanks @vipulnsward. closing this one.

@senny senny closed this Apr 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.