Upgrade to new permissions format

Also added migrations.

Almost identical to https://github.com/alphagov/publisher/pull/69