task/3382: Harmonisera tabellnamn #6

Merged
ansv7779 merged 104 commits from task/3382 into develop 2024-11-12 13:33:44 +01:00
2 changed files with 7 additions and 4 deletions
Showing only changes of commit 251708adbb - Show all commits

View File

@ -16,12 +16,14 @@ public class Comment extends DomainObject {
private Long id;
@ManyToOne(optional = false)
@JoinColumn(name = "user_id")
tozh4728 marked this conversation as resolved Outdated

The renaming of some user foreign key columns seem a bit weird. In some places it was a loss of information by going to just user_id while others they got _user_id appended to them and some were left as-is. Out of the three options just user_id is the worst one when there is additional context to be had. In this case "creator", so I think the column should be creator_id or creator_user_id to convey as much information as possible. It is also consistent with other foreign keys that use the <context>_user_id naming scheme. See for example core/src/main/java/se/su/dsv/scipro/peer/PeerRequest.java and its requester_user_id.

The renaming of some user foreign key columns seem a bit weird. In some places it was a loss of information by going to just `user_id` while others they got `_user_id` appended to them and some were left as-is. Out of the three options just `user_id` is the worst one when there is additional context to be had. In this case "creator", so I think the column should be `creator_id` or `creator_user_id` to convey as much information as possible. It is also consistent with other foreign keys that use the `<context>_user_id` naming scheme. See for example `core/src/main/java/se/su/dsv/scipro/peer/PeerRequest.java` and its `requester_user_id`.
private User creator;
@Lob
private String comment;
@ManyToOne(optional = false)
@JoinColumn(name = "comment_thread_id")
private CommentThread commentThread;
protected Comment() {

View File

@ -8,7 +8,9 @@ import java.util.Set;
import java.util.TreeSet;
@Entity
@Table(name = "comment_thread", uniqueConstraints = {@UniqueConstraint(columnNames = {"commentableKey", "commentableId"})})
@Table(name = "comment_thread",
uniqueConstraints = {@UniqueConstraint(name = "uk_comment_thread_id_key",
columnNames = {"commentable_key", "commentable_id"})})
@Cacheable(true)
public class CommentThread extends DomainObject {
@ -16,11 +18,10 @@ public class CommentThread extends DomainObject {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Basic(optional = false)
@Column(length = 191)
@Column(name = "commentable_key", length = 191, nullable = false)
private String commentableKey;
@Basic(optional = false)
@Column(name = "commentable_id", nullable = false)
private Long commentableId;
@OneToMany(mappedBy = "commentThread", orphanRemoval = true, cascade = CascadeType.ALL, targetEntity = Comment.class)