Fixes #487;add a migration script for resource and protected resource