mini_record icon indicating copy to clipboard operation
mini_record copied to clipboard

Issue about primary keys

Open kuraga opened this issue 12 years ago • 2 comments

@DAddYE There is some issue about primary keys.

According to readme:

Option :as or :type if not provided is :string by default, you can use all ActiveRecord types:

But col :name, as: :primary_key doesn't work because of ActiveRecord::ConnectionAdapters::TableDefinition#primary_key has one argument only, but we send two.

Then if I fix this issue (by removing options argument) I get next error:

ActiveRecord::StatementInvalid: SQLite3::SQLException: table "caras" has more than one primary key: CREATE TABLE "caras" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL) 

What do you think?

kuraga avatar Jan 03 '13 18:01 kuraga

I'll investigate soon, thanks for reporting this!

DAddYE avatar Jan 13 '13 21:01 DAddYE

There is a solution to this with the release of version 0.4.3, where you would do this:

create_table :primary_key => :name
col :name, :type => :string  # or :integer

cosine avatar Nov 12 '14 21:11 cosine