-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DB - Step 1 - EXPAND - DB schema and access queries become forwards a…
…nd backwards compatible.
- Loading branch information
1 parent
41f1760
commit 63e1f5a
Showing
4 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
server/src/main/java/au/chrissimon/safecontractchangesdemo/FullName.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,40 @@ | ||
package au.chrissimon.safecontractchangesdemo; | ||
|
||
import jakarta.persistence.Embeddable; | ||
|
||
@Embeddable | ||
public class FullName { | ||
private String firstName; | ||
public String getFirstName() { | ||
return firstName; | ||
} | ||
private String lastName; | ||
public String getLastName() { | ||
return lastName; | ||
} | ||
public FullName() { | ||
super(); | ||
} | ||
|
||
public static FullName fromDto(FullNameDto fullNameDto) { | ||
return new FullName(fullNameDto.getFirstName(), fullNameDto.getLastName()); | ||
} | ||
|
||
public FullNameDto asDto() { | ||
return new FullNameDto(firstName, lastName); | ||
} | ||
|
||
public FullName(String firstName, String lastName) { | ||
super(); | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
} | ||
|
||
public FullNameDto toResponse() { | ||
return new FullNameDto(getFirstName(), getLastName()); | ||
} | ||
|
||
public String toString() { | ||
return (getFirstName() + " " + getLastName()).trim(); | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
server/src/main/resources/db/changelog/02_add_fullname.yml
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,20 @@ | ||
databaseChangeLog: | ||
- changeSet: | ||
id: 2 | ||
author: Chris Simon | ||
changes: | ||
- addColumn: | ||
tableName: name | ||
columns: | ||
- column: | ||
name: first_name | ||
type: varchar(255) | ||
constraints: | ||
nullable: true | ||
unique: false | ||
- column: | ||
name: last_name | ||
type: varchar(255) | ||
constraints: | ||
nullable: true | ||
unique: false |
4 changes: 3 additions & 1 deletion
4
server/src/main/resources/db/changelog/db.changelog-master.yaml
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
databaseChangeLog: | ||
- include: | ||
file: db/changelog/01_initial_schema.yml | ||
file: db/changelog/01_initial_schema.yml | ||
- include: | ||
file: db/changelog/02_add_fullname.yml |