diff --git a/dmp-backend/notification-service/notification-web/src/main/resources/config/db.yml b/dmp-backend/notification-service/notification-web/src/main/resources/config/db.yml index ede758c3b..aa3caed0b 100644 --- a/dmp-backend/notification-service/notification-web/src/main/resources/config/db.yml +++ b/dmp-backend/notification-service/notification-web/src/main/resources/config/db.yml @@ -6,7 +6,7 @@ spring: dialect: org.hibernate.dialect.PostgreSQLDialect hibernate: naming: - physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + physical-strategy: gr.cite.notification.config.db.PrefixPhysicalNamingStrategy implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy datasource: url: ${DB_CONNECTION_STRING} @@ -19,3 +19,6 @@ spring: maximum-pool-size: 5 idle-timeout: 600000 max-lifetime: 1800000 + +naming-strategy: + prefix: ntf_ diff --git a/dmp-backend/notification-service/notification-web/target/classes/config/db.yml b/dmp-backend/notification-service/notification-web/target/classes/config/db.yml index ede758c3b..aa3caed0b 100644 --- a/dmp-backend/notification-service/notification-web/target/classes/config/db.yml +++ b/dmp-backend/notification-service/notification-web/target/classes/config/db.yml @@ -6,7 +6,7 @@ spring: dialect: org.hibernate.dialect.PostgreSQLDialect hibernate: naming: - physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + physical-strategy: gr.cite.notification.config.db.PrefixPhysicalNamingStrategy implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy datasource: url: ${DB_CONNECTION_STRING} @@ -19,3 +19,6 @@ spring: maximum-pool-size: 5 idle-timeout: 600000 max-lifetime: 1800000 + +naming-strategy: + prefix: ntf_ diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/config/db/NamingStrategyProperties.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/config/db/NamingStrategyProperties.java new file mode 100644 index 000000000..60d731cf9 --- /dev/null +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/config/db/NamingStrategyProperties.java @@ -0,0 +1,20 @@ +package gr.cite.notification.config.db; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.bind.ConstructorBinding; + +@ConfigurationProperties(prefix = "naming-strategy") +public class NamingStrategyProperties { + + private final String prefix; + + @ConstructorBinding + public NamingStrategyProperties(String prefix) { + this.prefix = prefix; + } + + public String getPrefix() { + return prefix; + } + +} diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/config/db/PrefixPhysicalNamingStrategy.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/config/db/PrefixPhysicalNamingStrategy.java new file mode 100644 index 000000000..d058a1fa5 --- /dev/null +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/config/db/PrefixPhysicalNamingStrategy.java @@ -0,0 +1,28 @@ +package gr.cite.notification.config.db; + +import gr.cite.notification.common.StringUtils; +import org.hibernate.boot.model.naming.Identifier; +import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl; +import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@EnableConfigurationProperties({NamingStrategyProperties.class}) +public class PrefixPhysicalNamingStrategy extends PhysicalNamingStrategyStandardImpl { + + private final NamingStrategyProperties namingStrategyProperties; + + public PrefixPhysicalNamingStrategy(NamingStrategyProperties namingStrategyProperties) { + this.namingStrategyProperties = namingStrategyProperties; + } + + @Override + public Identifier toPhysicalTableName(Identifier logicalName, JdbcEnvironment context) { + if (StringUtils.isNullOrEmpty(namingStrategyProperties.getPrefix())) + return super.toPhysicalTableName(logicalName, context); + Identifier identifier = new Identifier(namingStrategyProperties.getPrefix() + logicalName.getText(), logicalName.isQuoted()); + return super.toPhysicalTableName(identifier, context); + } + +} diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/InAppNotificationEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/InAppNotificationEntity.java index 0609772df..76431b727 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/InAppNotificationEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/InAppNotificationEntity.java @@ -13,7 +13,7 @@ import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_InAppNotification\"") +@Table(name = "\"InAppNotification\"") public class InAppNotificationEntity extends TenantScopedBaseEntity { @Id @@ -27,12 +27,6 @@ public class InAppNotificationEntity extends TenantScopedBaseEntity { public static final String _userId = "userId"; - @Column(name = "\"is_active\"", nullable = false) - @Convert(converter = IsActiveConverter.class) - private IsActive isActive; - - public static final String _isActive = "isActive"; - @Column(name = "\"type\"", columnDefinition = "uuid", nullable = false) private UUID type; @@ -81,6 +75,12 @@ public class InAppNotificationEntity extends TenantScopedBaseEntity { public static final String _updatedAt = "updatedAt"; + @Column(name = "\"is_active\"", nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; + + public static final String _isActive = "isActive"; + public UUID getId() { return id; } @@ -97,14 +97,6 @@ public class InAppNotificationEntity extends TenantScopedBaseEntity { this.userId = userId; } - public IsActive getIsActive() { - return isActive; - } - - public void setIsActive(IsActive isActive) { - this.isActive = isActive; - } - public UUID getType() { return type; } @@ -177,4 +169,11 @@ public class InAppNotificationEntity extends TenantScopedBaseEntity { this.updatedAt = updatedAt; } + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/LanguageEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/LanguageEntity.java index 57ec56f3b..d7ef04cec 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/LanguageEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/LanguageEntity.java @@ -9,7 +9,7 @@ import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_Language\"") +@Table(name = "\"Language\"") public class LanguageEntity extends TenantScopedBaseEntity { @Id diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationEntity.java index ae910e8bb..14edc062a 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationEntity.java @@ -9,7 +9,7 @@ import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_Notification\"") +@Table(name = "\"Notification\"") public class NotificationEntity extends TenantScopedBaseEntity { @Id diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationTemplateEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationTemplateEntity.java index d356ac9f4..20f1c9f71 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationTemplateEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationTemplateEntity.java @@ -13,7 +13,7 @@ import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_NotificationTemplate\"") +@Table(name = "\"NotificationTemplate\"") public class NotificationTemplateEntity extends TenantScopedBaseEntity { @Id diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueInboxEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueInboxEntity.java index 68777aa9a..c59bccb11 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueInboxEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueInboxEntity.java @@ -12,7 +12,7 @@ import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_QueueInbox\"") +@Table(name = "\"QueueInbox\"") public class QueueInboxEntity implements QueueInbox { @Id diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueOutboxEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueOutboxEntity.java index f12067e49..e62f2ec4d 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueOutboxEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueOutboxEntity.java @@ -10,7 +10,7 @@ import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_QueueOutbox\"") +@Table(name = "\"QueueOutbox\"") public class QueueOutboxEntity implements QueueOutbox { @Id diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantConfigurationEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantConfigurationEntity.java index 6e5b4dfab..44c8d6030 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantConfigurationEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantConfigurationEntity.java @@ -11,7 +11,7 @@ import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_TenantConfiguration\"") +@Table(name = "\"TenantConfiguration\"") public class TenantConfigurationEntity extends TenantScopedBaseEntity { @Id diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantEntity.java index b20d2d00a..f893aaa8c 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantEntity.java @@ -8,7 +8,7 @@ import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_Tenant\"") +@Table(name = "\"Tenant\"") public class TenantEntity { @Id diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantUserEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantUserEntity.java index 40ea61311..3ff3e610e 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantUserEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantUserEntity.java @@ -33,7 +33,7 @@ public class TenantUserEntity extends TenantScopedBaseEntity { public static final String _updatedAt = "updatedAt"; - @Column(name = "is_active", length = 100, nullable = false) + @Column(name = "is_active", nullable = false) @Convert(converter = IsActiveConverter.class) private IsActive isActive; diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserContactInfoEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserContactInfoEntity.java index d77568e29..bfd2acc6b 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserContactInfoEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserContactInfoEntity.java @@ -1,7 +1,9 @@ package gr.cite.notification.data; import gr.cite.notification.common.enums.ContactInfoType; +import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.data.conventers.ContactInfoTypeConverter; +import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import jakarta.persistence.*; @@ -9,7 +11,7 @@ import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_UserContactInfo\"") +@Table(name = "\"UserContactInfo\"") public class UserContactInfoEntity extends TenantScopedBaseEntity { @Id @@ -44,6 +46,17 @@ public class UserContactInfoEntity extends TenantScopedBaseEntity { public static final String _createdAt = "createdAt"; + @Column(name = "updated_at", nullable = false) + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + @Column(name = "\"is_active\"", nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; + + public static final String _isActive = "isActive"; + public UUID getUserId() { return userId; } @@ -91,5 +104,22 @@ public class UserContactInfoEntity extends TenantScopedBaseEntity { public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserCredentialEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserCredentialEntity.java index 726e0ed5e..51470a896 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserCredentialEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserCredentialEntity.java @@ -1,64 +1,97 @@ package gr.cite.notification.data; - +import gr.cite.notification.common.enums.IsActive; +import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_UserCredential\"") +@Table(name = "\"UserCredential\"") public class UserCredentialEntity extends TenantScopedBaseEntity { - @Id - @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) - private UUID id; - public static final String _id = "id"; + @Id + @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) + private UUID id; - @Column(name = "\"user\"", columnDefinition = "uuid", nullable = false) - private UUID userId; - public static final String _userId = "userId"; + public static final String _id = "id"; - @Column(name = "\"external_id\"", length = UserCredentialEntity._externalIdLength, nullable = false) - private String externalId; - public static final String _externalId = "externalId"; - public static final int _externalIdLength = 512; - - @Column(name = "created_at", nullable = false) - private Instant createdAt; + @Column(name = "\"user\"", columnDefinition = "uuid", nullable = false) + private UUID userId; - public static final String _createdAt = "createdAt"; + public static final String _userId = "userId"; - public UUID getId() { - return id; - } + @Column(name = "\"external_id\"", length = UserCredentialEntity._externalIdLength, nullable = false) + private String externalId; - public void setId(UUID id) { - this.id = id; - } + public static final String _externalId = "externalId"; - public UUID getUserId() { - return userId; - } + public static final int _externalIdLength = 512; - public void setUserId(UUID userId) { - this.userId = userId; - } + @Column(name = "created_at", nullable = false) + private Instant createdAt; - public String getExternalId() { - return externalId; - } + public static final String _createdAt = "createdAt"; - public void setExternalId(String externalId) { - this.externalId = externalId; - } + @Column(name = "updated_at", nullable = false) + private Instant updatedAt; - public Instant getCreatedAt() { - return createdAt; - } + public static final String _updatedAt = "updatedAt"; + + @Column(name = "\"is_active\"", nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; + + public static final String _isActive = "isActive"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public UUID getUserId() { + return userId; + } + + public void setUserId(UUID userId) { + this.userId = userId; + } + + public String getExternalId() { + return externalId; + } + + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } - public void setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; - } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserEntity.java index 1e0a29e44..477695f65 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserEntity.java @@ -8,7 +8,7 @@ import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_User\"") +@Table(name = "\"User\"") public class UserEntity { @Id diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserNotificationPreferenceEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserNotificationPreferenceEntity.java index 1841453db..1eea893cc 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserNotificationPreferenceEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserNotificationPreferenceEntity.java @@ -1,7 +1,9 @@ package gr.cite.notification.data; +import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.common.enums.NotificationContactType; import gr.cite.notification.data.composite.CompositeUserNotificationPreferenceId; +import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.conventers.NotificationContactTypeConverter; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; import jakarta.persistence.*; @@ -10,7 +12,7 @@ import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"ntf_UserNotificationPreference\"") +@Table(name = "\"UserNotificationPreference\"") @IdClass(CompositeUserNotificationPreferenceId.class) public class UserNotificationPreferenceEntity extends TenantScopedBaseEntity { @@ -43,6 +45,17 @@ public class UserNotificationPreferenceEntity extends TenantScopedBaseEntity { public static final String _createdAt = "createdAt"; + @Column(name = "updated_at", nullable = false) + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + @Column(name = "\"is_active\"", nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; + + public static final String _isActive = "isActive"; + public UUID getUserId() { return userId; } @@ -82,4 +95,21 @@ public class UserNotificationPreferenceEntity extends TenantScopedBaseEntity { public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserRoleEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserRoleEntity.java index cbc808350..ba3e9baf1 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserRoleEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserRoleEntity.java @@ -1,65 +1,97 @@ package gr.cite.notification.data; - +import gr.cite.notification.common.enums.IsActive; +import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @Entity @Table(name = "\"UserRole\"") public class UserRoleEntity extends TenantScopedBaseEntity { - @Id - @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) - private UUID id; - public static final String _id = "id"; - @Column(name = "role", length = UserRoleEntity._roleLength, nullable = false) - private String role; - public static final String _role = "role"; - public static final int _roleLength = 512; + @Id + @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) + private UUID id; - @Column(name = "\"user\"", nullable = false) - private UUID userId; - public static final String _userId = "userId"; + public static final String _id = "id"; + @Column(name = "role", length = UserRoleEntity._roleLength, nullable = false) + private String role; - @Column(name = "created_at", nullable = false) - private Instant createdAt; + public static final String _role = "role"; - public static final String _createdAt = "createdAt"; + public static final int _roleLength = 512; - public UUID getId() { - return id; - } + @Column(name = "\"user\"", nullable = false) + private UUID userId; - public void setId(UUID id) { - this.id = id; - } + public static final String _userId = "userId"; - public String getRole() { - return role; - } + @Column(name = "created_at", nullable = false) + private Instant createdAt; - public void setRole(String role) { - this.role = role; - } + public static final String _createdAt = "createdAt"; - public UUID getUserId() { - return userId; - } + @Column(name = "updated_at", nullable = false) + private Instant updatedAt; - public void setUserId(UUID userId) { - this.userId = userId; - } + public static final String _updatedAt = "updatedAt"; - public Instant getCreatedAt() { - return createdAt; - } + @Column(name = "\"is_active\"", nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; - public void setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; - } + public static final String _isActive = "isActive"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public UUID getUserId() { + return userId; + } + + public void setUserId(UUID userId) { + this.userId = userId; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/tenant/TenantScopedBaseEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/tenant/TenantScopedBaseEntity.java index 070497032..8feaf544b 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/tenant/TenantScopedBaseEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/tenant/TenantScopedBaseEntity.java @@ -8,6 +8,8 @@ import org.hibernate.annotations.ParamDef; import jakarta.persistence.Column; import jakarta.persistence.EntityListeners; import jakarta.persistence.MappedSuperclass; + +import java.io.Serial; import java.io.Serializable; import java.util.UUID; @@ -20,13 +22,14 @@ import java.util.UUID; @EntityListeners(TenantListener.class) public abstract class TenantScopedBaseEntity implements TenantScoped, Serializable { + @Serial private static final long serialVersionUID = 1L; public static final String tenantFilter = "tenantFilter"; public static final String tenantFilterTenantParam = "tenantId"; - @Column(name = "tenant", columnDefinition = "uuid", nullable = true) + @Column(name = "tenant", columnDefinition = "uuid") private UUID tenantId; public static final String _tenantId = "tenantId"; @@ -39,4 +42,5 @@ public abstract class TenantScopedBaseEntity implements TenantScoped, Serializab public void setTenantId(UUID tenantId) { this.tenantId = tenantId; } + } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserContactInfo.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserContactInfo.java index 280126100..b7aabedd4 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserContactInfo.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserContactInfo.java @@ -1,6 +1,7 @@ package gr.cite.notification.model; import gr.cite.notification.common.enums.ContactInfoType; +import gr.cite.notification.common.enums.IsActive; import java.time.Instant; import java.util.UUID; @@ -8,26 +9,40 @@ import java.util.UUID; public class UserContactInfo { private UUID id; + public static final String _id = "id"; private User user; + public static final String _user = "user"; private ContactInfoType type; + public static final String _type = "type"; private String value; + public static final String _value = "value"; private Integer ordinal; + public static final String _ordinal = "ordinal"; private Tenant tenant; + public static final String _tenant = "tenant"; private Instant createdAt; + public static final String _createdAt = "createdAt"; + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + private IsActive isActive; + + public static final String _isActive = "isActive"; public UUID getId() { return id; @@ -85,4 +100,19 @@ public class UserContactInfo { this.createdAt = createdAt; } + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserCredential.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserCredential.java index 6aeee3d2d..826a39d20 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserCredential.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserCredential.java @@ -1,51 +1,81 @@ package gr.cite.notification.model; +import gr.cite.notification.common.enums.IsActive; + import java.time.Instant; import java.util.UUID; public class UserCredential { - private UUID id; - public static final String _id = "id"; - private String externalId; - public static final String _externalId = "externalId"; + private UUID id; - private User user; - public static final String _user = "user"; + public static final String _id = "id"; - private Instant createdAt; + private String externalId; - public static final String _createdAt = "createdAt"; + public static final String _externalId = "externalId"; - public UUID getId() { - return id; - } + private User user; - public void setId(UUID id) { - this.id = id; - } + public static final String _user = "user"; - public String getExternalId() { - return externalId; - } + private Instant createdAt; - public void setExternalId(String externalId) { - this.externalId = externalId; - } + public static final String _createdAt = "createdAt"; - public User getUser() { - return user; - } + private Instant updatedAt; - public void setUser(User user) { - this.user = user; - } + public static final String _updatedAt = "updatedAt"; - public Instant getCreatedAt() { - return createdAt; - } + private IsActive isActive; - public void setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; - } + public static final String _isActive = "isActive"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getExternalId() { + return externalId; + } + + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserNotificationPreference.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserNotificationPreference.java index dc6477cee..6cec86fac 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserNotificationPreference.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserNotificationPreference.java @@ -1,5 +1,6 @@ package gr.cite.notification.model; +import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.common.enums.NotificationContactType; import java.time.Instant; @@ -31,6 +32,14 @@ public class UserNotificationPreference { public static final String _createdAt = "createdAt"; + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + private IsActive isActive; + + public static final String _isActive = "isActive"; + public UUID getUserId() { return userId; } @@ -78,4 +87,21 @@ public class UserNotificationPreference { public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserRole.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserRole.java index 37c225d5d..7dc91d068 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserRole.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/UserRole.java @@ -1,5 +1,10 @@ package gr.cite.notification.model; +import gr.cite.notification.common.enums.IsActive; +import gr.cite.notification.data.conventers.IsActiveConverter; +import jakarta.persistence.Column; +import jakarta.persistence.Convert; + import java.time.Instant; import java.util.UUID; @@ -17,6 +22,14 @@ public class UserRole { public static final String _createdAt = "createdAt"; + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + private IsActive isActive; + + public static final String _isActive = "isActive"; + public UUID getId() { return id; } @@ -48,5 +61,22 @@ public class UserRole { public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserContactInfoQuery.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserContactInfoQuery.java index ddfda844b..ada21a0ce 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserContactInfoQuery.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserContactInfoQuery.java @@ -207,6 +207,9 @@ public class UserContactInfoQuery extends QueryBase { @Override protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); + if (this.isActives != null) { + predicates.add(queryContext.Root.get(UserContactInfoEntity._isActive).in(isActives)); + } if (this.userIds != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)); for (UUID item : this.userIds) @@ -264,6 +267,10 @@ public class UserContactInfoQuery extends QueryBase { return UserContactInfoEntity._ordinal; else if (item.match(UserContactInfo._createdAt)) return UserContactInfoEntity._createdAt; + else if (item.match(UserContactInfo._updatedAt)) + return UserContactInfoEntity._updatedAt; + else if (item.match(UserContactInfo._isActive)) + return UserContactInfoEntity._isActive; else if (item.match(UserContactInfo._user, User._id)) return UserContactInfoEntity._userId; else if (item.prefix(UserContactInfo._user)) @@ -282,6 +289,8 @@ public class UserContactInfoQuery extends QueryBase { item.setUserId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._userId, UUID.class)); item.setTenantId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._tenantId, UUID.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._isActive, IsActive.class)); return item; } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserCredentialQuery.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserCredentialQuery.java index 30cb14f14..2ac910df3 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserCredentialQuery.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserCredentialQuery.java @@ -3,34 +3,43 @@ package gr.cite.notification.query; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.notification.authorization.AuthorizationFlags; import gr.cite.notification.authorization.Permission; +import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.common.scope.user.UserScope; import gr.cite.notification.data.UserCredentialEntity; import gr.cite.notification.model.UserCredential; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Predicate; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.Predicate; import java.time.Instant; import java.util.*; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class UserCredentialQuery extends QueryBase { + private Collection ids; + private Collection excludedIds; + + private Collection isActives; + private Collection userIds; + private Collection externalIds; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private final UserScope userScope; + private final AuthorizationService authService; + public UserCredentialQuery(UserScope userScope, AuthorizationService authService) { this.userScope = userScope; this.authService = authService; @@ -50,7 +59,7 @@ public class UserCredentialQuery extends QueryBase { this.ids = values; return this; } - + public UserCredentialQuery excludedIds(Collection values) { this.excludedIds = values; return this; @@ -66,6 +75,21 @@ public class UserCredentialQuery extends QueryBase { return this; } + public UserCredentialQuery isActive(IsActive value) { + this.isActives = List.of(value); + return this; + } + + public UserCredentialQuery isActive(IsActive... value) { + this.isActives = Arrays.asList(value); + return this; + } + + public UserCredentialQuery isActive(Collection values) { + this.isActives = values; + return this; + } + public UserCredentialQuery userIds(UUID value) { this.userIds = List.of(value); return this; @@ -117,11 +141,15 @@ public class UserCredentialQuery extends QueryBase { @Override protected Predicate applyAuthZ(QueryContext queryContext) { - if (this.authorize.contains(AuthorizationFlags.None)) return null; - if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null; + if (this.authorize.contains(AuthorizationFlags.None)) + return null; + if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) + return null; UUID userId; - if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe(); - else userId = null; + if (this.authorize.contains(AuthorizationFlags.Owner)) + userId = this.userScope.getUserIdSafe(); + else + userId = null; List predicates = new ArrayList<>(); if (userId != null) { @@ -134,7 +162,7 @@ public class UserCredentialQuery extends QueryBase { return queryContext.CriteriaBuilder.or(); //Creates a false query } } - + @Override protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); @@ -144,6 +172,9 @@ public class UserCredentialQuery extends QueryBase { inClause.value(item); predicates.add(inClause); } + if (this.isActives != null) { + predicates.add(queryContext.Root.get(UserCredentialEntity._isActive).in(isActives)); + } if (this.userIds != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserCredentialEntity._userId)); for (UUID item : this.userIds) @@ -172,12 +203,22 @@ public class UserCredentialQuery extends QueryBase { @Override protected String fieldNameOf(FieldResolver item) { - if (item.match(UserCredential._id)) return UserCredentialEntity._id; - else if (item.match(UserCredential._externalId)) return UserCredentialEntity._externalId; - else if (item.prefix(UserCredential._user)) return UserCredentialEntity._userId; - else if (item.match(UserCredential._user)) return UserCredentialEntity._userId; - else if (item.match(UserCredential._createdAt) ) return UserCredentialEntity._createdAt; - else return null; + if (item.match(UserCredential._id)) + return UserCredentialEntity._id; + else if (item.match(UserCredential._externalId)) + return UserCredentialEntity._externalId; + else if (item.prefix(UserCredential._user)) + return UserCredentialEntity._userId; + else if (item.match(UserCredential._user)) + return UserCredentialEntity._userId; + else if (item.match(UserCredential._createdAt)) + return UserCredentialEntity._createdAt; + else if (item.match(UserCredential._updatedAt)) + return UserCredentialEntity._updatedAt; + else if (item.match(UserCredential._isActive)) + return UserCredentialEntity._isActive; + else + return null; } @Override @@ -187,6 +228,8 @@ public class UserCredentialQuery extends QueryBase { item.setExternalId(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._externalId, String.class)); item.setUserId(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._userId, UUID.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, UserCredentialEntity._createdAt, IsActive.class)); return item; } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserNotificationPreferenceQuery.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserNotificationPreferenceQuery.java index 4d1795eaf..e51efad40 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserNotificationPreferenceQuery.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserNotificationPreferenceQuery.java @@ -1,25 +1,34 @@ package gr.cite.notification.query; +import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.common.enums.NotificationContactType; import gr.cite.notification.data.UserNotificationPreferenceEntity; import gr.cite.notification.model.UserNotificationPreference; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.Predicate; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.Predicate; import java.time.Instant; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.UUID; @Component @Scope(BeanDefinition.SCOPE_PROTOTYPE) public class UserNotificationPreferenceQuery extends QueryBase { + private List userId; + + private List isActives; + private List type; + private List channel; public UserNotificationPreferenceQuery userId(UUID... userId) { @@ -32,6 +41,16 @@ public class UserNotificationPreferenceQuery extends QueryBase isActives) { + this.isActives = isActives; + return this; + } + public UserNotificationPreferenceQuery type(UUID... type) { this.type = List.of(type); return this; @@ -69,6 +88,10 @@ public class UserNotificationPreferenceQuery extends QueryBase { + private Collection ids; + private Collection excludedIds; + + private Collection isActives; + private Collection userIds; + private Collection roles; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private final UserScope userScope; + private final AuthorizationService authService; + public UserRoleQuery(UserScope userScope, AuthorizationService authService) { this.userScope = userScope; this.authService = authService; @@ -51,7 +59,7 @@ public class UserRoleQuery extends QueryBase { this.ids = values; return this; } - + public UserRoleQuery excludedIds(Collection values) { this.excludedIds = values; return this; @@ -67,6 +75,21 @@ public class UserRoleQuery extends QueryBase { return this; } + public UserRoleQuery isActives(Collection values) { + this.isActives = values; + return this; + } + + public UserRoleQuery isActives(IsActive value) { + this.isActives = List.of(value); + return this; + } + + public UserRoleQuery isActives(IsActive... value) { + this.isActives = Arrays.asList(value); + return this; + } + public UserRoleQuery userIds(UUID value) { this.userIds = List.of(value); return this; @@ -118,11 +141,15 @@ public class UserRoleQuery extends QueryBase { @Override protected Predicate applyAuthZ(QueryContext queryContext) { - if (this.authorize.contains(AuthorizationFlags.None)) return null; - if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null; + if (this.authorize.contains(AuthorizationFlags.None)) + return null; + if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) + return null; UUID userId; - if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe(); - else userId = null; + if (this.authorize.contains(AuthorizationFlags.Owner)) + userId = this.userScope.getUserIdSafe(); + else + userId = null; List predicates = new ArrayList<>(); if (userId != null) { @@ -135,7 +162,7 @@ public class UserRoleQuery extends QueryBase { return queryContext.CriteriaBuilder.or(); //Creates a false query } } - + @Override protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); @@ -145,6 +172,9 @@ public class UserRoleQuery extends QueryBase { inClause.value(item); predicates.add(inClause); } + if (this.isActives != null) { + predicates.add(queryContext.Root.get(UserRoleEntity._isActive).in(isActives)); + } if (this.userIds != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserRoleEntity._userId)); for (UUID item : this.userIds) @@ -173,12 +203,22 @@ public class UserRoleQuery extends QueryBase { @Override protected String fieldNameOf(FieldResolver item) { - if (item.match(UserRole._id)) return UserRoleEntity._id; - else if (item.match(UserRole._role)) return UserRoleEntity._role; - else if (item.prefix(UserRole._user)) return UserRoleEntity._userId; - else if (item.match(UserRole._user)) return UserRoleEntity._userId; - else if (item.match(UserRole._createdAt) ) return UserRoleEntity._createdAt; - else return null; + if (item.match(UserRole._id)) + return UserRoleEntity._id; + else if (item.match(UserRole._role)) + return UserRoleEntity._role; + else if (item.prefix(UserRole._user)) + return UserRoleEntity._userId; + else if (item.match(UserRole._user)) + return UserRoleEntity._userId; + else if (item.match(UserRole._createdAt)) + return UserRoleEntity._createdAt; + else if (item.match(UserRole._updatedAt)) + return UserRoleEntity._updatedAt; + else if (item.match(UserRole._isActive)) + return UserRoleEntity._isActive; + else + return null; } @Override @@ -188,6 +228,8 @@ public class UserRoleQuery extends QueryBase { item.setRole(QueryBase.convertSafe(tuple, columns, UserRoleEntity._role, String.class)); item.setUserId(QueryBase.convertSafe(tuple, columns, UserRoleEntity._userId, UUID.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserRoleEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, UserRoleEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, UserRoleEntity._isActive, IsActive.class)); return item; } diff --git a/dmp-db-scema/updates/00.01.034_add_ntf_UserNotificationPreference.sql b/dmp-db-scema/updates/00.01.034_add_ntf_UserNotificationPreference.sql index 8fd1116ba..85018d5c6 100644 --- a/dmp-db-scema/updates/00.01.034_add_ntf_UserNotificationPreference.sql +++ b/dmp-db-scema/updates/00.01.034_add_ntf_UserNotificationPreference.sql @@ -10,8 +10,10 @@ BEGIN "type" uuid NOT NULL, "channel" smallint NOT NULL, "ordinal" numeric NOT NULL, - "created_at" timestamp without time zone NOT NULL, "tenant" uuid, + "created_at" timestamp without time zone NOT NULL, + "updated_at" timestamp without time zone NOT NULL, + "is_active" smallint NOT NULL DEFAULT 1, CONSTRAINT "ntf_UserNotificationPreference_pkey" PRIMARY KEY ("user", "type", "channel"), CONSTRAINT "ntf_UserNotificationPreference_tenant_fkey" FOREIGN KEY ("tenant") REFERENCES public."ntf_Tenant" (id) MATCH SIMPLE diff --git a/dmp-db-scema/updates/00.01.044_Add_ntf_User_ContactInfo.sql b/dmp-db-scema/updates/00.01.044_Add_ntf_User_ContactInfo.sql index 369df5437..74991f487 100644 --- a/dmp-db-scema/updates/00.01.044_Add_ntf_User_ContactInfo.sql +++ b/dmp-db-scema/updates/00.01.044_Add_ntf_User_ContactInfo.sql @@ -12,6 +12,8 @@ CREATE TABLE IF NOT EXISTS public."ntf_UserContactInfo" "type" smallint NOT NULL, "value" character varying(512) COLLATE pg_catalog."default" NOT NULL, "created_at" timestamp without time zone NOT NULL, + "updated_at" timestamp without time zone NOT NULL, + "is_active" smallint NOT NULL DEFAULT 1, "tenant" uuid, CONSTRAINT "ntf_UserContactInfo_pkey" PRIMARY KEY (id), CONSTRAINT "ntf_UserContactInfo_tenant_fkey" FOREIGN KEY ("tenant") diff --git a/dmp-db-scema/updates/00.01.045_Add_ntf_User_Credential.sql b/dmp-db-scema/updates/00.01.045_Add_ntf_User_Credential.sql index 130da6892..2495c3d4b 100644 --- a/dmp-db-scema/updates/00.01.045_Add_ntf_User_Credential.sql +++ b/dmp-db-scema/updates/00.01.045_Add_ntf_User_Credential.sql @@ -10,6 +10,8 @@ CREATE TABLE IF NOT EXISTS public."ntf_UserCredential" "user" uuid NOT NULL, "external_id" character varying(512) COLLATE pg_catalog."default" NOT NULL, "created_at" timestamp without time zone NOT NULL, + "updated_at" timestamp without time zone NOT NULL, + "is_active" smallint NOT NULL DEFAULT 1, "tenant" uuid, "data" character varying COLLATE pg_catalog."default", CONSTRAINT "ntf_UserCredential_pkey" PRIMARY KEY (id), diff --git a/dmp-db-scema/updates/00.01.046_Add_ntf_TenantUser.sql b/dmp-db-scema/updates/00.01.046_Add_ntf_TenantUser.sql new file mode 100644 index 000000000..733db1998 --- /dev/null +++ b/dmp-db-scema/updates/00.01.046_Add_ntf_TenantUser.sql @@ -0,0 +1,28 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.046'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + +CREATE TABLE IF NOT EXISTS public."ntf_TenantUser" +( + "id" uuid NOT NULL, + "user" uuid NOT NULL, + "tenant" uuid NOT NULL, + "is_active" smallint NOT NULL, + "created_at" timestamp without time zone NOT NULL, + "updated_at" timestamp without time zone NOT NULL, + CONSTRAINT "ntf_TenantUser_pkey" PRIMARY KEY (id), + CONSTRAINT "ntf_TenantUser_tenant_fkey" FOREIGN KEY ("tenant") + REFERENCES public."ntf_Tenant" (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION, + CONSTRAINT "ntf_TenantUser_user_fkey" FOREIGN KEY ("user") + REFERENCES public."ntf_User" (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION +) + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.046', '2024-01-25 12:00:00.000000+02', now(), 'Add table ntf_TenantUser.'); + +END$$; \ No newline at end of file