write database migration scripts for follow requirement changes (keep one migration script for per change log)
change logs
create table employee with fields: id,name,age,vocation, the id should be auto increased
create table user with fields: id,username,password,password_expired,role,createTime the createTime should be generated automatically. role can be a string here.
add field employee_id in user
change field name vocation to position in table employee to be more meaningful
remove field password_expired
create table role with fields: id,name
change role to role_id in user table
insert preset records for role with admin,company admin,user
Practice Output & Submit
submit your git repo url to field answer
Hint
add flyway dependency in build.gradle
add migration script under src/main/resource/db/migration
the filename of migration script should match the PATTERN like this V1__xxxxxx.sql, V2__yyyyyy.sql
run gradle bootRun to get script executed
find word migration in log of spring boot
check database structure in localhost:8080/h2-console to verify migration result
How to use H2
schema.sql will be loaded and init database when application is starting
navigate to web consolehttp://localhost:8080/h2-console
put jdbc:h2:file:./h2-db/h2;MODE=Oracle in JDBC URL field
we choose file as the h2 storage for migration practice
java_persistence_practice_flyway-2019-8-30-1-2-29-399's People