Fix some bugs of the PetPlugin and integrate flywaydb.