Skip to content

Commit

Permalink
feat(core): handle previous deleted attributes when creating a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
bobeal committed Dec 7, 2024
1 parent 033a887 commit d88aaed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ class EntityAttributeService(
VALUES
(:id, :entity_id, :attribute_name, :attribute_type, :attribute_value_type, :created_at, :dataset_id,
:payload)
ON CONFLICT (entity_id, attribute_name, dataset_id)
DO UPDATE SET deleted_at = null,
attribute_type = :attribute_type,
attribute_value_type = :attribute_value_type,
created_at = :created_at,
payload = :payload
""".trimIndent()
)
.bind("id", attribute.id)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
ALTER TABLE temporal_entity_attribute
ADD COLUMN deleted_at timestamp with time zone;
ADD COLUMN deleted_at timestamp with time zone;

ALTER TABLE entity_payload
ADD COLUMN deleted_at timestamp with time zone;
ADD COLUMN deleted_at timestamp with time zone;

DROP INDEX IF EXISTS temporal_entity_attribute_null_datasetid_uniqueness;

ALTER TABLE temporal_entity_attribute
DROP CONSTRAINT temporal_entity_attribute_uniqueness;

ALTER TABLE temporal_entity_attribute
ADD CONSTRAINT temporal_entity_attribute_uniqueness UNIQUE NULLS NOT DISTINCT (entity_id, attribute_name, dataset_id);

0 comments on commit d88aaed

Please sign in to comment.