forked from Onlineberatung/onlineBeratung-messageService
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adapt new database for messageservice
BREAKING CHANGE: creating a new database for messageservice is required
- Loading branch information
Showing
13 changed files
with
137 additions
and
8 deletions.
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
42 changes: 42 additions & 0 deletions
42
src/main/java/de/caritas/cob/messageservice/api/model/entity/DraftMessage.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,42 @@ | ||
package de.caritas.cob.messageservice.api.model.entity; | ||
|
||
import java.time.LocalDateTime; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.SequenceGenerator; | ||
import javax.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Table(name = "draftmessage") | ||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class DraftMessage { | ||
|
||
@Id | ||
@SequenceGenerator(name = "id_seq", allocationSize = 1, sequenceName = "sequence_draftmessage") | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_seq") | ||
@Column(name = "id", updatable = false, nullable = false) | ||
private Long id; | ||
|
||
@Column(name = "user_id", nullable = false) | ||
private String userId; | ||
|
||
@Column(name = "rc_group_id", nullable = false) | ||
private String rcGroupId; | ||
|
||
@Column(name = "draft_message", nullable = false) | ||
private String message; | ||
|
||
@Column(name = "create_date", nullable = false) | ||
private LocalDateTime createDate; | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/de/caritas/cob/messageservice/api/repository/DraftMessageRepository.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,8 @@ | ||
package de.caritas.cob.messageservice.api.repository; | ||
|
||
import de.caritas.cob.messageservice.api.model.entity.DraftMessage; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface DraftMessageRepository extends CrudRepository<DraftMessage, Long> { | ||
|
||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/resources/db/changelog/changeset/0001_initsql/initSql.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,11 @@ | ||
<?xml version="1.1" encoding="UTF-8" standalone="no"?> | ||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"> | ||
<changeSet author="initialSetup" id="initSql-tables"> | ||
<sqlFile path="db/changelog/changeset/0001_initsql/initTables.sql" stripComments="true" /> | ||
<rollback><sql/></rollback> | ||
</changeSet> | ||
<changeSet author="initialSetup" id="initSql-trigger"> | ||
<sqlFile endDelimiter="//" path="db/changelog/changeset/0001_initsql/initTrigger.sql" stripComments="true" /> | ||
<rollback><sql/></rollback> | ||
</changeSet> | ||
</databaseChangeLog> |
15 changes: 15 additions & 0 deletions
15
src/main/resources/db/changelog/changeset/0001_initsql/initTables.sql
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,15 @@ | ||
CREATE TABLE messageservice.`draftmessage` ( | ||
`id` bigint(21) NOT NULL, | ||
`user_id` varchar(36) COLLATE utf8_unicode_ci NOT NULL, | ||
`rc_group_id` varchar(255) NOT NULL, | ||
`draft_message` longtext COLLATE utf8_unicode_ci NOT NULL, | ||
`create_date` datetime NOT NULL DEFAULT UTC_TIMESTAMP(), | ||
`update_date` datetime NOT NULL DEFAULT UTC_TIMESTAMP(), | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | ||
CREATE SEQUENCE messageservice.sequence_draftmessage | ||
INCREMENT BY 1 | ||
MINVALUE = 0 | ||
NOMAXVALUE | ||
START WITH 0 | ||
CACHE 0; |
4 changes: 4 additions & 0 deletions
4
src/main/resources/db/changelog/changeset/0001_initsql/initTrigger.sql
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,4 @@ | ||
CREATE TRIGGER messageservice.`message_update` BEFORE UPDATE ON messageservice.`draftmessage` FOR EACH | ||
ROW BEGIN | ||
set new.update_date=utc_timestamp(); | ||
END // |
10 changes: 10 additions & 0 deletions
10
src/main/resources/db/changelog/messageservice-dev-master.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,10 @@ | ||
<?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-3.2.xsd"> | ||
|
||
<!-- The base changeset contains the database state when liquibase was added to the project --> | ||
<include file="db/changelog/changeset/0001_initsql/initSql.xml"/> | ||
</databaseChangeLog> |
10 changes: 10 additions & 0 deletions
10
src/main/resources/db/changelog/messageservice-local-master.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,10 @@ | ||
<?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-3.2.xsd"> | ||
|
||
<!-- The base changeset contains the database state when liquibase was added to the project --> | ||
<include file="db/changelog/changeset/0001_initsql/initSql.xml"/> | ||
</databaseChangeLog> |
7 changes: 7 additions & 0 deletions
7
src/main/resources/db/changelog/messageservice-prod-master.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,7 @@ | ||
<?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-3.2.xsd"> | ||
</databaseChangeLog> |
7 changes: 7 additions & 0 deletions
7
src/main/resources/db/changelog/messageservice-staging-master.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,7 @@ | ||
<?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-3.2.xsd"> | ||
</databaseChangeLog> |
9 changes: 9 additions & 0 deletions
9
src/main/resources/db/changelog/messageservice-testing-master.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,9 @@ | ||
<?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-3.2.xsd"> | ||
|
||
<!-- PLEASE LEAVE THIS FILE EMPTY --> | ||
</databaseChangeLog> |