2 mentions Mentions
Id serial MentionedUserId int PostId integer Date timestamp with time zone
Mentions
Mentions_MentionedUserId_PostId_key MentionedUserId PostId
Mentions
Mentions_MentionedUserId_fkey MentionedUserId Users restrict restrict
Mentions
Mentions_PostId_fkey PostId Posts restrict restrict
INSERT INTO "Mentions"("MentionedUserId", "PostId", "Date") ( SELECT parent."PosterId" "MentionedUserId", post."Id" "PostId", post."LastChangeDate" "Date" FROM "Posts" post JOIN "Posts" parent ON post."ParentPostId" = parent."Id" WHERE post."PosterId" != parent."PosterId" ORDER BY post."Id" asc )