lykahb / groundhog

This library maps datatypes to a relational model, in a way similar to what ORM libraries do in OOP. See the tutorial https://www.schoolofhaskell.com/user/lykahb/groundhog for introduction
http://hackage.haskell.org/package/groundhog
176 stars 39 forks source link

Specifying primary key #3

Closed iquiw closed 11 years ago

iquiw commented 11 years ago

I like groundhog feature to be able to omit automatic primary key.

In addition to that, is it possible (or planned) to specify primary key on arbitrary column?

lykahb commented 11 years ago

It is possible to specify unique key which on many databases is just the same as primary key without autoincrement. See http://github.com/lykahb/groundhog/blob/master/examples/keys.hs

iquiw commented 11 years ago

I see.

I'd like to use primary key since it conceptually indicates preferred identifier.

Anyway, thanks for the information. Please feel free to close the issue.

lykahb commented 11 years ago

After the latest refactoring of migration required by MySQL, implementing this feature became easier. I committed it in 8837a5d187e0fa4efc706efc492975ac7cc99e25. There is example of its usage in tests.hs (UniqueKeySample). Thank you for suggestion.

iquiw commented 11 years ago

It's very attractive feature to me. I will try it. Thanks!