Demonstrate how to to ZDD with SQL migrations. This project expose a REST API and is written with Dropwizard.
Subdirectories contain the different versions of the project to show the steps.
v1
Initial version, store the address in theaddress
column of thePerson
tablev2
Add newAddress
table, not used by the codev3
Can store address in theaddress
column of thePerson
table or in theAddress
tablev4
Migrate all addresses to theAddress
tablev5
Provide the/v2
API, remove knowledge of theaddress
column from the codev6
Drop theaddress
column
- A local PostgreSQL database
- A
zdd_java_sql
user with azdd_java_sql
password - Run
reset_databases.sh
to create the databases
- Go to the
vX
directory - Run
mvn clean install
to build the application - Create a database in your PostgreSQL schema
- Update the database configuration in
config.yml
- Run
java -jar target/vX-1.0-SNAPSHOT.jar db migrate config.yml
to initialize the database tables - Start application with
java -jar target/vX-1.0-SNAPSHOT.jar server config.yml
- To check that your application is running enter url
http://localhost:8080
To see your applications health enter url http://localhost:8081/healthcheck
V1 :
- Get all people :
curl -v "http://localhost:8080/v1/people"
- Get one person
curl -v "http://localhost:8080/v1/people/1"
- Create one person
curl -v -X POST -H "Content-Type: application/json" -d '{"name":"John Doe", "address": "34, avenue de l Opéra 75002 Paris"}' "http://localhost:8080/v1/people"
- Delete one person
curl -v -X DELETE "http://localhost:8080/v1/people/1"
- Update one person
curl -v -X PUT POST -H "Content-Type: application/json" -d '{"name":"John Doe", "address": "34, avenue de l Opéra 75002 Paris"}' "http://localhost:8080/v1/people/1"