18
I am writing a migration script to create a table with a primary key column that is named guid and is a VARCHAR(25). The issue is I feel like I am having to double my effort to achieve what should be possible in one step.
If I run:
create_table(:global_feeds, :primary_key => 'guid') do |t|
t.string :guid, :limit => 25
t.text :title
t.text :subtitle
...
t.timestamps
end
I get a table with a primary key called guid no column called id (which is what I want). However, the issue is the guid column is an INT(11) with auto increment turned on. So I have to run one additional command:
change_column :global_feeds, :guid, :string, :limit => 25
Seems a bit convoluted to have to basically run two SQL commands to get what I believe should be possible in one.
Any suggestions on how to optimize this?