I'm trying to set up a smooth deployment process where we can deploy to a production or development SQL server with a single deploy script.
But I don't know how best to manage users and permissions between the two environments. For example, in development we want the developers group to have the db_owner
database role. On production we either want no access or just the datareader
role.
I think the easiest way to do this would be to set up the users once on each server and then not keep them in the database project. But then they get dropped during deployment.
Is there some way I can do this using project configuration in Visual Studio?
We're using a complete Microsoft stack
vsdbcmd
for deploymentA couple of things make this easier:
--
if ('$(Environment)' = 'DEV')
begin
create user [domain\developers]
exec sp_addrolemember @rolename='db_owner', @membername='domain\developers'
end