Bzzt
Bzzt

Reputation: 1054

Any way to make a table key that doesn't use the Persistent ID mechanism?

I'm trying to set up my postgres schema in yesod. The plan is to let yesod generate the tables, but I'll be inserting new records into the tables from a lua script in a C++ program. I'd like one of the tables to have a primary key based on a unique Int64 that comes from the C++ environment. Can I get Persistent to treat this column as the table key, but without the automatic id generation?

I guess I could have a regular persistent-style record ID column and an Int64 column too but that seems wasteful and overly complicated. The Int64 will always be unique and that's what I'll use to do lookups on the table records to see if they exist already.

Upvotes: 3

Views: 416

Answers (1)

Greg Weber
Greg Weber

Reputation: 3428

I think this question was asked on the mail list. The short answer is no, the primary key in Persistent is auto-increment, but you can have secondary indexes

Upvotes: 1

Related Questions