diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/common/types/notification/Attachment.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/common/types/notification/Attachment.java deleted file mode 100644 index 1fbcbb6c5..000000000 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/common/types/notification/Attachment.java +++ /dev/null @@ -1,36 +0,0 @@ -package gr.cite.annotation.common.types.notification; - -public class Attachment { - - private String fileRef, fileName, mimeType; - - public Attachment(String fileRef, String fileName, String mimeType) { - this.fileRef = fileRef; - this.fileName = fileName; - this.mimeType = mimeType; - } - - public String getFileRef() { - return fileRef; - } - - public void setFileRef(String fileRef) { - this.fileRef = fileRef; - } - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public String getMimeType() { - return mimeType; - } - - public void setMimeType(String mimeType) { - this.mimeType = mimeType; - } -} diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/common/types/notification/ContactPair.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/common/types/notification/ContactPair.java deleted file mode 100644 index 4d3a973a5..000000000 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/common/types/notification/ContactPair.java +++ /dev/null @@ -1,32 +0,0 @@ -package gr.cite.annotation.common.types.notification; - -import gr.cite.annotation.common.enums.ContactInfoType; - -public class ContactPair { - private ContactInfoType type; - private String contact; - - public ContactPair(ContactInfoType type, String contact) { - this.type = type; - this.contact = contact; - } - - public ContactPair() { - } - - public ContactInfoType getType() { - return type; - } - - public void setType(ContactInfoType type) { - this.type = type; - } - - public String getContact() { - return contact; - } - - public void setContact(String contact) { - this.contact = contact; - } -} diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/data/AnnotationEntity.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/data/AnnotationEntity.java index cfa45e409..8ea01ca22 100644 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/data/AnnotationEntity.java +++ b/annotation-service/annotation/src/main/java/gr/cite/annotation/data/AnnotationEntity.java @@ -23,6 +23,16 @@ public class AnnotationEntity { public static final String _entityId = "entityId"; + @Column(name = "entity_type", nullable = false) + private String entityType; + + public static final String _entityType = "entityType"; + + @Column(name = "anchor") + private String anchor; + + public static final String _anchor = "anchor"; + @Id @Column(name = "payload", nullable = false) private String payload; @@ -61,6 +71,22 @@ public class AnnotationEntity { this.entityId = entityId; } + public String getEntityType() { + return entityType; + } + + public void setEntityType(String entityType) { + this.entityType = entityType; + } + + public String getAnchor() { + return anchor; + } + + public void setAnchor(String anchor) { + this.anchor = anchor; + } + public String getPayload() { return payload; } diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/data/LanguageEntity.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/data/EntityUserEntity.java similarity index 69% rename from annotation-service/annotation/src/main/java/gr/cite/annotation/data/LanguageEntity.java rename to annotation-service/annotation/src/main/java/gr/cite/annotation/data/EntityUserEntity.java index 460ee1a22..49deda357 100644 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/data/LanguageEntity.java +++ b/annotation-service/annotation/src/main/java/gr/cite/annotation/data/EntityUserEntity.java @@ -2,15 +2,14 @@ package gr.cite.annotation.data; import gr.cite.annotation.common.enums.IsActive; import gr.cite.annotation.data.conventers.IsActiveConverter; -import gr.cite.annotation.data.tenant.TenantScopedBaseEntity; import jakarta.persistence.*; import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"Language\"") -public class LanguageEntity extends TenantScopedBaseEntity { +@Table(name = "\"EntityUser\"") +public class EntityUserEntity { @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) @@ -18,15 +17,17 @@ public class LanguageEntity extends TenantScopedBaseEntity { public static final String _id = "id"; - @Column(name = "code", length = 20, nullable = false) - private String code; + @Id + @Column(name = "id", columnDefinition = "uuid", nullable = false) + private UUID entityId; - public static final String _code = "code"; + public static final String _entityId = "entityId"; - @Column(name = "ordinal") - private Integer ordinal; + @Id + @Column(name = "id", columnDefinition = "uuid", nullable = false) + private UUID userId; - public static final String _ordinal = "ordinal"; + public static final String _userId = "userId"; @Column(name = "\"created_at\"", nullable = false) private Instant createdAt; @@ -52,20 +53,20 @@ public class LanguageEntity extends TenantScopedBaseEntity { this.id = id; } - public String getCode() { - return code; + public UUID getEntityId() { + return entityId; } - public void setCode(String code) { - this.code = code; + public void setEntityId(UUID entityId) { + this.entityId = entityId; } - public Integer getOrdinal() { - return ordinal; + public UUID getUserId() { + return userId; } - public void setOrdinal(Integer ordinal) { - this.ordinal = ordinal; + public void setUserId(UUID userId) { + this.userId = userId; } public Instant getCreatedAt() { diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/data/UserRoleEntity.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/data/UserRoleEntity.java deleted file mode 100644 index 52c7e2d3b..000000000 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/data/UserRoleEntity.java +++ /dev/null @@ -1,97 +0,0 @@ -package gr.cite.annotation.data; - -import gr.cite.annotation.common.enums.IsActive; -import gr.cite.annotation.data.conventers.IsActiveConverter; -import gr.cite.annotation.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; - - @Column(name = "\"user\"", nullable = false) - private UUID userId; - - public static final String _userId = "userId"; - - @Column(name = "created_at", nullable = false) - private Instant createdAt; - - 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 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/annotation-service/annotation/src/main/java/gr/cite/annotation/model/Annotation.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/model/Annotation.java index a440322b3..96cca0e73 100644 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/model/Annotation.java +++ b/annotation-service/annotation/src/main/java/gr/cite/annotation/model/Annotation.java @@ -15,6 +15,14 @@ public class Annotation { public static final String _entityId = "entityId"; + private String entityType; + + public static final String _entityType = "entityType"; + + private String anchor; + + public static final String _anchor = "anchor"; + private String payload; public static final String _payload = "payload"; @@ -47,6 +55,22 @@ public class Annotation { this.entityId = entityId; } + public String getEntityType() { + return entityType; + } + + public void setEntityType(String entityType) { + this.entityType = entityType; + } + + public String getAnchor() { + return anchor; + } + + public void setAnchor(String anchor) { + this.anchor = anchor; + } + public String getPayload() { return payload; } diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/model/builder/AnnotationBuilder.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/model/builder/AnnotationBuilder.java index e9de7df16..0354b3cae 100644 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/model/builder/AnnotationBuilder.java +++ b/annotation-service/annotation/src/main/java/gr/cite/annotation/model/builder/AnnotationBuilder.java @@ -3,9 +3,7 @@ package gr.cite.annotation.model.builder; import gr.cite.annotation.authorization.AuthorizationFlags; import gr.cite.annotation.convention.ConventionService; import gr.cite.annotation.data.AnnotationEntity; -import gr.cite.annotation.data.UserEntity; import gr.cite.annotation.model.Annotation; -import gr.cite.annotation.model.User; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; @@ -19,7 +17,7 @@ import java.util.*; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class AnnotationBuilder extends BaseBuilder{ +public class AnnotationBuilder extends BaseBuilder { private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -36,7 +34,8 @@ public class AnnotationBuilder extends BaseBuilder public List build(FieldSet fields, List data) throws MyApplicationException { this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); this.logger.trace(new DataLogEntry("requested fields", fields)); - if (fields == null || fields.isEmpty()) return new ArrayList<>(); + if (fields == null || fields.isEmpty()) + return new ArrayList<>(); List models = new ArrayList<>(); @@ -44,12 +43,22 @@ public class AnnotationBuilder extends BaseBuilder return models; for (AnnotationEntity d : data) { Annotation m = new Annotation(); - if (fields.hasField(this.asIndexer(Annotation._id))) m.setId(d.getId()); - if (fields.hasField(this.asIndexer(Annotation._entityId))) m.setEntityId(d.getEntityId()); - if (fields.hasField(this.asIndexer(Annotation._payload))) m.setPayload(d.getPayload()); - if (fields.hasField(this.asIndexer(Annotation._createdAt))) m.setCreatedAt(d.getCreatedAt()); - if (fields.hasField(this.asIndexer(Annotation._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); - if (fields.hasField(this.asIndexer(Annotation._isActive))) m.setIsActive(d.getIsActive()); + if (fields.hasField(this.asIndexer(Annotation._id))) + m.setId(d.getId()); + if (fields.hasField(this.asIndexer(Annotation._entityId))) + m.setEntityId(d.getEntityId()); + if (fields.hasField(this.asIndexer(Annotation._entityType))) + m.setEntityType(d.getEntityType()); + if (fields.hasField(this.asIndexer(Annotation._anchor))) + m.setAnchor(d.getAnchor()); + if (fields.hasField(this.asIndexer(Annotation._payload))) + m.setPayload(d.getPayload()); + if (fields.hasField(this.asIndexer(Annotation._createdAt))) + m.setCreatedAt(d.getCreatedAt()); + if (fields.hasField(this.asIndexer(Annotation._updatedAt))) + m.setUpdatedAt(d.getUpdatedAt()); + if (fields.hasField(this.asIndexer(Annotation._isActive))) + m.setIsActive(d.getIsActive()); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/model/persist/AnnotationPersist.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/model/persist/AnnotationPersist.java index 38aec7930..e2f802a2e 100644 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/model/persist/AnnotationPersist.java +++ b/annotation-service/annotation/src/main/java/gr/cite/annotation/model/persist/AnnotationPersist.java @@ -24,6 +24,14 @@ public class AnnotationPersist { public static final String _entityId = "entityId"; + private String entityType; + + public static final String _entityType = "entityType"; + + private String anchor; + + public static final String _anchor = "anchor"; + private String payload; public static final String _payload = "payload"; @@ -44,6 +52,22 @@ public class AnnotationPersist { this.entityId = entityId; } + public String getEntityType() { + return entityType; + } + + public void setEntityType(String entityType) { + this.entityType = entityType; + } + + public String getAnchor() { + return anchor; + } + + public void setAnchor(String anchor) { + this.anchor = anchor; + } + public String getPayload() { return payload; } @@ -82,7 +106,10 @@ public class AnnotationPersist { .must(() -> this.isValidGuid(item.getEntityId())) .failOn(AnnotationPersist._entityId).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationPersist._entityId}, LocaleContextHolder.getLocale())), this.spec() - .must(() -> this.isEmpty(item.getPayload())) + .must(() -> !this.isEmpty(item.getEntityType())) + .failOn(AnnotationPersist._entityType).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationPersist._entityType}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isEmpty(item.getPayload())) .failOn(AnnotationPersist._payload).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationPersist._payload}, LocaleContextHolder.getLocale())) ); } diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/query/AnnotationQuery.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/query/AnnotationQuery.java index 7439e6d89..ae149857f 100644 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/query/AnnotationQuery.java +++ b/annotation-service/annotation/src/main/java/gr/cite/annotation/query/AnnotationQuery.java @@ -33,6 +33,8 @@ public class AnnotationQuery extends QueryBase { private Collection entityIds; + private Collection entityTypes; + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); private final UserScope userScope; @@ -109,6 +111,21 @@ public class AnnotationQuery extends QueryBase { return this; } + public AnnotationQuery entityTypes(String value) { + this.entityTypes = List.of(value); + return this; + } + + public AnnotationQuery entityTypes(String... value) { + this.entityTypes = Arrays.asList(value); + return this; + } + + public AnnotationQuery entityTypes(Collection values) { + this.entityTypes = values; + return this; + } + @Override protected Boolean isFalseQuery() { return this.isEmpty(this.ids) || this.isEmpty(this.excludedIds) || this.isEmpty(this.isActives) || this.isEmpty(this.entityIds); @@ -153,6 +170,12 @@ public class AnnotationQuery extends QueryBase { inClause.value(item); predicates.add(inClause); } + if (this.entityTypes != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(AnnotationEntity._entityType)); + for (String item : this.entityTypes) + inClause.value(item); + predicates.add(inClause); + } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); @@ -168,6 +191,10 @@ public class AnnotationQuery extends QueryBase { return AnnotationEntity._id; else if (item.match(Annotation._entityId)) return AnnotationEntity._entityId; + else if (item.match(Annotation._entityType)) + return AnnotationEntity._entityType; + else if (item.match(Annotation._anchor)) + return AnnotationEntity._anchor; else if (item.match(Annotation._payload)) return AnnotationEntity._payload; else if (item.match(Annotation._createdAt)) @@ -186,6 +213,8 @@ public class AnnotationQuery extends QueryBase { AnnotationEntity item = new AnnotationEntity(); item.setId(QueryBase.convertSafe(tuple, columns, AnnotationEntity._id, UUID.class)); item.setEntityId(QueryBase.convertSafe(tuple, columns, AnnotationEntity._entityId, UUID.class)); + item.setEntityType(QueryBase.convertSafe(tuple, columns, AnnotationEntity._entityType, String.class)); + item.setAnchor(QueryBase.convertSafe(tuple, columns, AnnotationEntity._anchor, String.class)); item.setPayload(QueryBase.convertSafe(tuple, columns, AnnotationEntity._payload, String.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, AnnotationEntity._createdAt, Instant.class)); item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, AnnotationEntity._updatedAt, Instant.class)); diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/query/lookup/AnnotationLookup.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/query/lookup/AnnotationLookup.java index 192ef3788..46d493b94 100644 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/query/lookup/AnnotationLookup.java +++ b/annotation-service/annotation/src/main/java/gr/cite/annotation/query/lookup/AnnotationLookup.java @@ -20,6 +20,8 @@ public class AnnotationLookup extends Lookup { private List entityIds; + private List entityTypes; + public String getLike() { return like; } @@ -52,6 +54,22 @@ public class AnnotationLookup extends Lookup { this.isActive = isActive; } + public List getEntityIds() { + return entityIds; + } + + public void setEntityIds(List entityIds) { + this.entityIds = entityIds; + } + + public List getEntityTypes() { + return entityTypes; + } + + public void setEntityTypes(List entityTypes) { + this.entityTypes = entityTypes; + } + public AnnotationQuery enrich(QueryFactory queryFactory) { AnnotationQuery query = queryFactory.query(AnnotationQuery.class); if (this.like != null) @@ -64,6 +82,8 @@ public class AnnotationLookup extends Lookup { query.isActive(this.isActive); if (this.entityIds != null) query.entityIds(this.entityIds); + if (this.entityTypes != null) + query.entityTypes(this.entityTypes); this.enrichCommon(query); diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/service/annotation/AnnotationServiceImpl.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/service/annotation/AnnotationServiceImpl.java index bb84e4f95..e67af4c85 100644 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/service/annotation/AnnotationServiceImpl.java +++ b/annotation-service/annotation/src/main/java/gr/cite/annotation/service/annotation/AnnotationServiceImpl.java @@ -64,6 +64,8 @@ public class AnnotationServiceImpl implements AnnotationService { AnnotationEntity data = new AnnotationEntity(); data.setId(UUID.randomUUID()); data.setEntityId(model.getEntityId()); + data.setEntityType(model.getEntityType()); + data.setAnchor(model.getAnchor()); data.setPayload(model.getPayload()); data.setCreatedAt(Instant.now()); data.setUpdatedAt(Instant.now()); diff --git a/dmp-db-scema/updates/00.01.035_add_ntf_TenantConfiguration.sql b/dmp-db-scema/updates/00.01.035_add_ntf_Tenant_and_ntf_TenantConfiguration.sql similarity index 59% rename from dmp-db-scema/updates/00.01.035_add_ntf_TenantConfiguration.sql rename to dmp-db-scema/updates/00.01.035_add_ntf_Tenant_and_ntf_TenantConfiguration.sql index 16304c8ba..9b7b9f92f 100644 --- a/dmp-db-scema/updates/00.01.035_add_ntf_TenantConfiguration.sql +++ b/dmp-db-scema/updates/00.01.035_add_ntf_Tenant_and_ntf_TenantConfiguration.sql @@ -4,6 +4,16 @@ BEGIN PERFORM * FROM "DBVersion" WHERE version = this_version; IF FOUND THEN RETURN; END IF; + CREATE TABLE public."ntf_Tenant" + ( + id uuid NOT NULL, + code character varying(200) COLLATE pg_catalog."default" NOT NULL, + created_at timestamp without time zone NOT NULL DEFAULT now(), + updated_at timestamp without time zone NOT NULL DEFAULT now(), + is_active smallint NOT NULL DEFAULT 1, + CONSTRAINT "ntf_Tenant_pkey" PRIMARY KEY (id) + ); + CREATE TABLE public."ntf_TenantConfiguration" ( id uuid NOT NULL, @@ -15,11 +25,11 @@ BEGIN updated_at timestamp without time zone NOT NULL, CONSTRAINT "ntf_TenantConfguration_pkey" PRIMARY KEY (id), CONSTRAINT "ntf_TenantConfiguration_tenant_fkey" FOREIGN KEY (tenant) - REFERENCES public."Tenant" (id) MATCH SIMPLE + REFERENCES public."ntf_Tenant" (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ); - INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.035', '2023-12-05 12:00:00.000000+02', now(), 'Add table ntf_TenantConfiguration.'); + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.035', '2023-12-05 12:00:00.000000+02', now(), 'Add tables ntf_Tenant and ntf_TenantConfiguration.'); END$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.048_Add_ant_QueueInbox.sql b/dmp-db-scema/updates/00.01.048_Add_ant_QueueInbox.sql new file mode 100644 index 000000000..98cfd7bfb --- /dev/null +++ b/dmp-db-scema/updates/00.01.048_Add_ant_QueueInbox.sql @@ -0,0 +1,32 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.048'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + + CREATE TABLE public."ant_QueueInbox" + ( + id uuid NOT NULL, + queue character varying(50) COLLATE pg_catalog."default" NOT NULL, + exchange character varying(50) COLLATE pg_catalog."default" NOT NULL, + route character varying(50) COLLATE pg_catalog."default" NOT NULL, + application_id character varying(100) COLLATE pg_catalog."default" NOT NULL, + message_id uuid NOT NULL, + message json NOT NULL, + retry_count integer, + status character varying(50) COLLATE pg_catalog."default" NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + tenant uuid, + is_active smallint NOT NULL, + CONSTRAINT "ant_QueryInbox_pkey" PRIMARY KEY (id), + CONSTRAINT "ant_QueryInbox_tenant_fkey" FOREIGN KEY (tenant) + REFERENCES public."Tenant" (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION + NOT VALID + ); + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.048', '2024-02-13 12:00:00.000000+02', now(), 'Add table ant_QueueInbox.'); + +END$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.049_Add_ant_QueueOutbox.sql b/dmp-db-scema/updates/00.01.049_Add_ant_QueueOutbox.sql new file mode 100644 index 000000000..6ed6b4d7f --- /dev/null +++ b/dmp-db-scema/updates/00.01.049_Add_ant_QueueOutbox.sql @@ -0,0 +1,31 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.049'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + + CREATE TABLE public."ant_QueueOutbox" + ( + id uuid NOT NULL, + exchange character varying(200) COLLATE pg_catalog."default" NOT NULL, + route character varying(200) COLLATE pg_catalog."default" NOT NULL, + message_id uuid NOT NULL, + notify_status character varying(100) COLLATE pg_catalog."default" NOT NULL, + retry_count integer NOT NULL, + published_at timestamp without time zone, + confirmed_at timestamp without time zone, + tenant uuid, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + message text COLLATE pg_catalog."default" NOT NULL, + is_active smallint NOT NULL, + CONSTRAINT "ant_QueueOutbox_pkey" PRIMARY KEY (id), + CONSTRAINT "ant_QueueOutbox_tenant_fkey" FOREIGN KEY (tenant) + REFERENCES public."Tenant" (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION + ); + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.049', '2024-02-13 12:00:00.000000+02', now(), 'Add table ant_QueueOutbox.'); + +END$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.050_Add_ant_Tenant_and_ant_TenantConfiguration.sql b/dmp-db-scema/updates/00.01.050_Add_ant_Tenant_and_ant_TenantConfiguration.sql new file mode 100644 index 000000000..8cb9d829a --- /dev/null +++ b/dmp-db-scema/updates/00.01.050_Add_ant_Tenant_and_ant_TenantConfiguration.sql @@ -0,0 +1,35 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.050'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + + CREATE TABLE public."ant_Tenant" + ( + id uuid NOT NULL, + code character varying(200) COLLATE pg_catalog."default" NOT NULL, + created_at timestamp without time zone NOT NULL DEFAULT now(), + updated_at timestamp without time zone NOT NULL DEFAULT now(), + is_active smallint NOT NULL DEFAULT 1, + CONSTRAINT "ant_Tenant_pkey" PRIMARY KEY (id) + ); + + CREATE TABLE public."ant_TenantConfiguration" + ( + id uuid NOT NULL, + tenant uuid NOT NULL, + type smallint NOT NULL, + value character varying COLLATE pg_catalog."default" NOT NULL, + is_active smallint NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL, + CONSTRAINT "ant_TenantConfguration_pkey" PRIMARY KEY (id), + CONSTRAINT "ant_TenantConfiguration_tenant_fkey" FOREIGN KEY (tenant) + REFERENCES public."ant_Tenant" (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION + ); + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.050', '2024-02-13 12:00:00.000000+02', now(), 'Add tables ant_Tenant and ant_TenantConfiguration.'); + +END$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.051_Add_ant_User.sql b/dmp-db-scema/updates/00.01.051_Add_ant_User.sql new file mode 100644 index 000000000..ed0723ff9 --- /dev/null +++ b/dmp-db-scema/updates/00.01.051_Add_ant_User.sql @@ -0,0 +1,20 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.051'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + + CREATE TABLE IF NOT EXISTS public."ant_User" +( + "id" uuid NOT NULL, + "name" character varying(250) COLLATE pg_catalog."default", + "additional_info" character varying COLLATE pg_catalog."default", + "created_at" timestamp without time zone NOT NULL DEFAULT now(), + "updated_at" timestamp without time zone NOT NULL DEFAULT now(), + "is_active" smallint NOT NULL DEFAULT 1, + CONSTRAINT "ant_User_pkey" PRIMARY KEY (id) +) + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.051', '2024-02-13 12:00:00.000000+02', now(), 'Add table ant_User.'); + +END$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.052_Add_ant_User_Credential.sql b/dmp-db-scema/updates/00.01.052_Add_ant_User_Credential.sql new file mode 100644 index 000000000..1fe7df9ee --- /dev/null +++ b/dmp-db-scema/updates/00.01.052_Add_ant_User_Credential.sql @@ -0,0 +1,31 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.052'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + +CREATE TABLE IF NOT EXISTS public."ant_UserCredential" +( + "id" uuid NOT NULL, + "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 "ant_UserCredential_pkey" PRIMARY KEY (id), + CONSTRAINT "ant_UserCredential_tenant_fkey" FOREIGN KEY ("tenant") + REFERENCES public."ant_Tenant" (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION + NOT VALID, + CONSTRAINT "ant_UserCredential_user_fkey" FOREIGN KEY ("user") + REFERENCES public."ant_User" (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION +) + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.052', '2024-02-13 12:00:00.000000+02', now(), 'Add table ant_UserCredential.'); + +END$$; \ No newline at end of file diff --git a/dmp-db-scema/updates/00.01.053_Add_ant_TenantUser.sql b/dmp-db-scema/updates/00.01.053_Add_ant_TenantUser.sql new file mode 100644 index 000000000..b32b6b4c6 --- /dev/null +++ b/dmp-db-scema/updates/00.01.053_Add_ant_TenantUser.sql @@ -0,0 +1,28 @@ +DO $$DECLARE + this_version CONSTANT varchar := '00.01.053'; +BEGIN + PERFORM * FROM "DBVersion" WHERE version = this_version; + IF FOUND THEN RETURN; END IF; + +CREATE TABLE IF NOT EXISTS public."ant_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 "ant_TenantUser_pkey" PRIMARY KEY (id), + CONSTRAINT "ant_TenantUser_tenant_fkey" FOREIGN KEY ("tenant") + REFERENCES public."ant_Tenant" (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION, + CONSTRAINT "ant_TenantUser_user_fkey" FOREIGN KEY ("user") + REFERENCES public."ant_User" (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION +) + + INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.053', '2024-02-13 12:00:00.000000+02', now(), 'Add table ant_TenantUser.'); + +END$$; \ No newline at end of file