1

ActsAsParanoidを使用してユーザーをソフト削除しています。ユーザーを削除(ソフト)した後、クライアントが同じメールIDのユーザーを作成したいのですが、メール列が一意であるため、一意のフィールドエラーが発生します。emaildelete_at列がnullの場合のみ列。

あなたが私の質問を理解していない場合、plsは返信します。

4

2 に答える 2

2

I suppose you could change the uniqueness constraint of your users table to be:

UNIQUE (email, deletion_date)

This would effectively:

  • For standard (non-deleted) users, guarantee they have unique email addresses, since their deletion dates would presumably all be NULL.
  • For deleted users, not make any guarantee about email addresses, since they all have unique deletion dates.
  • For new users, allow them to use an email address that a deleted user has, since the new user will have a NULL deletion date, while the deleted user has a value there.
于 2011-07-19T19:50:39.543 に答える