-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add communication metadata (#209)
* feat: add communication metadata * test: check if survey-unit is deleted when metadata are linked * fix: use same type in FK, H2 silently casting type is dangerous⚠️
- Loading branch information
Showing
6 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...main/java/fr/insee/pearljam/infrastructure/surveyunit/entity/CommunicationMetadataDB.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package fr.insee.pearljam.infrastructure.surveyunit.entity; | ||
|
||
import fr.insee.pearljam.api.domain.SurveyUnit; | ||
import fr.insee.pearljam.infrastructure.campaign.entity.CommunicationTemplateDB; | ||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.io.Serializable; | ||
|
||
@Entity(name = "communication_metadata") | ||
@Table | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public class CommunicationMetadataDB implements Serializable { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private SurveyUnit surveyUnit; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private CommunicationTemplateDB communicationTemplate; | ||
@Column(name = "metadata_key") | ||
private String key; | ||
@Column(name = "metadata_value") | ||
private String value; | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/resources/db/changelog/580_add_communication_metadata.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
<changeSet author="simondmz" id="580-1"> | ||
<createTable tableName="communication_metadata"> | ||
<column name="id" type="BIGINT" autoIncrement="true"> | ||
<constraints primaryKey="true" primaryKeyName="communication_metadataPK"/> | ||
</column> | ||
<column name="survey_unit_id" type="VARCHAR(255)"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="communication_template_id" type="BIGINT"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="metadata_key" type="VARCHAR(255)"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="metadata_value" type="VARCHAR(255)"> | ||
<constraints nullable="false"/> | ||
</column> | ||
</createTable> | ||
<addForeignKeyConstraint | ||
baseTableName="communication_metadata" | ||
baseColumnNames="survey_unit_id" | ||
constraintName="fk_survey_unit" | ||
referencedTableName="survey_unit" | ||
referencedColumnNames="id"/> | ||
<addForeignKeyConstraint | ||
baseTableName="communication_metadata" | ||
baseColumnNames="communication_template_id" | ||
constraintName="fk_communication_template" | ||
referencedTableName="communication_template" | ||
referencedColumnNames="id"/> | ||
</changeSet> | ||
</databaseChangeLog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters