polishing the workspace migration
This commit is contained in:
@@ -16,7 +16,7 @@ import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "group_batch", indexes = {
|
||||
@Index(name = "idx_group_batch_user_id", columnList = "user_id"),
|
||||
@Index(name = "idx_group_batch_workspace_id", columnList = "workspace_id"),
|
||||
@Index(name = "idx_group_batch_status", columnList = "status"),
|
||||
@Index(name = "idx_group_batch_recipient_group_id", columnList = "recipient_group_id"),
|
||||
@Index(name = "idx_group_batch_created_at", columnList = "created_at"),
|
||||
@@ -32,6 +32,8 @@ import java.util.UUID;
|
||||
public class GroupBatch extends BaseEntity {
|
||||
@Column(name = "recipient_group_id")
|
||||
private UUID recipientGroupId;
|
||||
@Column(name = "workspace_id")
|
||||
private UUID workspaceId;
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
private String description;
|
||||
|
||||
@@ -7,10 +7,12 @@ import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "recipient", indexes = {
|
||||
@Index(name = "idx_recipient_account_user", columnList = "account, user_id"),
|
||||
@Index(name = "idx_recipient_user_id", columnList = "user_id"),
|
||||
@Index(name = "idx_recipient_account_workspace", columnList = "account, workspace_id"),
|
||||
@Index(name = "idx_recipient_workspace_id", columnList = "workspace_id"),
|
||||
@Index(name = "idx_recipient_phone", columnList = "phone_number"),
|
||||
@Index(name = "idx_recipient_email", columnList = "email"),
|
||||
})
|
||||
@@ -31,6 +33,8 @@ public class Recipient extends BaseEntity {
|
||||
private String initials;
|
||||
@Column(name = "latest_provider_label")
|
||||
private String latestProviderLabel;
|
||||
@Column(name = "workspace_id")
|
||||
private UUID workspaceId;
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "recipient_group", indexes = {
|
||||
@Index(name = "idx_recipient_group_user_id", columnList = "user_id"),
|
||||
@Index(name = "idx_recipient_group_workspace_id", columnList = "workspace_id"),
|
||||
})
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -23,6 +25,8 @@ import org.hibernate.annotations.SQLRestriction;
|
||||
public class RecipientGroup extends BaseEntity {
|
||||
private String name;
|
||||
private String description;
|
||||
@Column(name = "workspace_id")
|
||||
private UUID workspaceId;
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ public class RecipientGroupMember extends BaseEntity {
|
||||
@Column(name = "recipient_uid")
|
||||
private UUID recipientUid;
|
||||
private String account;
|
||||
@Column(name = "workspace_id")
|
||||
private UUID workspaceId;
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.UUID;
|
||||
@Table(name = "transaction", indexes = {
|
||||
@Index(name = "idx_transaction_trace_type", columnList = "trace, type"),
|
||||
@Index(name = "idx_transaction_reference", columnList = "reference"),
|
||||
@Index(name = "idx_transaction_user_id", columnList = "user_id"),
|
||||
@Index(name = "idx_transaction_workspace_id", columnList = "workspace_id"),
|
||||
@Index(name = "idx_transaction_confirm_pay_integ", columnList = "confirmation_status, payment_status, integration_status"),
|
||||
@Index(name = "idx_transaction_pay_poll", columnList = "payment_status, polling_status"),
|
||||
@Index(name = "idx_transaction_status", columnList = "status"),
|
||||
@@ -33,6 +33,8 @@ import java.util.UUID;
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@SQLRestriction("deleted = false")
|
||||
public class Transaction extends BaseEntity {
|
||||
@Column(name = "workspace_id")
|
||||
private UUID workspaceId;
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
private String trace;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package zw.qantra.tm.domain.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -9,7 +10,9 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name = "users", indexes = {
|
||||
@@ -50,6 +53,10 @@ public class User extends BaseEntity implements UserDetails {
|
||||
|
||||
@Column(name = "is_credentials_non_expired")
|
||||
private boolean credentialsNonExpired = true;
|
||||
|
||||
@JsonIgnore
|
||||
@ManyToMany(mappedBy = "users", fetch = FetchType.LAZY)
|
||||
private Set<Workspace> workspaces = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
|
||||
39
src/main/java/zw/qantra/tm/domain/models/Workspace.java
Normal file
39
src/main/java/zw/qantra/tm/domain/models/Workspace.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package zw.qantra.tm.domain.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name = "workspace", indexes = {
|
||||
@Index(name = "idx_workspace_name", columnList = "name"),
|
||||
})
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SQLRestriction("deleted = false")
|
||||
public class Workspace extends BaseEntity {
|
||||
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
private String phone;
|
||||
private String email;
|
||||
|
||||
@JsonIgnore
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "workspace_users",
|
||||
joinColumns = @JoinColumn(name = "workspace_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "user_id")
|
||||
)
|
||||
@Builder.Default
|
||||
private Set<User> users = new HashSet<>();
|
||||
}
|
||||
Reference in New Issue
Block a user