Apologies in advance if this is somewhere in the documentation. I've
scoured the FAQ and google with no luck.

I'm creating an entity as follows:
class Member(MyEntity):

    using_options(tablename='members')
    role = ManyToOne('models.Role', primary_key=True)
    user = ManyToOne('models.User', primary_key=True)
    groups = ManyToMany('models.Group', onupdate='cascade',
ondelete='cascade')

This almost does everything I want. However, I would love to enforce a
rule in the database that says a user can only have one role in a
group. This could be accomplished by putting a unique constraint on
the user and group column in the table created for the many to many
relationship. Is there some way to do this with Elixir or am I going
to have to get more familiar with sqlalchemy mappers?

To be more clear, the above creates a table called
members_groups__groups_members with a primary key across all three
columns: groups_id, members_role_rolename, members_user_username. I'd
like to put a unique constraint across groups_id and user_username.

Maybe this isn't even a good idea! :-) Thanks for any help.

- Sean
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to