0

We are using visual studio database projects to define our databases and deploy them.

CREATE LOGIN [My_User]
CREATE USER [MY_User] FOR LOGIN [My_User] WITH DEFAULT_SCHEMA=[dbo]

And it works fine when deploying locally. But when deploying on the server, with OctopusDeploy, it causes the following error:

*** The object [My_User] already exists in database with a different definition and will not be altered."

This might not be a problem because the resulting user does work. But it's a major red flag and we'd rather not have any errors or warnings.

Neil Lunn
  • 148,042
  • 36
  • 346
  • 317
MrFox
  • 4,852
  • 7
  • 45
  • 81
  • Are you adding the user using a pre/post deployment script? – Fenton Dec 23 '15 at 19:31
  • No it's a file in the project. Just part of the database to be deployed. Don't know exactly in what part it get's deployed. – MrFox Dec 24 '15 at 08:01
  • Are you sure nobody manually added it previously? Or restored it from a backup? – Fenton Feb 04 '16 at 11:56
  • @Sohnee Yes, we're talking freshly created databases here. Also that should not matter, the sql defines what the database should end up looking like, regardless of what it looks like now. – MrFox Feb 08 '16 at 10:40
  • We discovered such problem when we use user mappings. I bet you are using same sql server instance but DB creation/configuration and deployment was doing from different sql server users. Its hard to understand but we've solved this with removing db users before creating script. For some reason sqlproj do not check existence of some entities like users – Alex Lyalka Sep 25 '17 at 22:21

0 Answers0