Failing database build

BenNeuwirthBenNeuwirth Posts: 3 New member
edited February 13, 2020 11:19PM in SQL Change Automation
Our Azure Devops pipeline uses Invoke-DatabaseBuild to create build our database before we release.

We're getting an error on one of databases:

WARNING: The error 'There is already an object named 'GL' in the database.
WARNING: CREATE SCHEMA failed due to previous errors.' occurred when executing the following SQL:
WARNING: CREATE SCHEMA [GL]
WARNING: AUTHORIZATION [dbo]

This schema was create yrs ago and only exists once in the database.
No recent commits touch that schema at all
I don’t understand how a guid build database can already have an existing schema if it’s being created on the fly.

Any help would be appreciated




Best Answer

  • Kendra_LittleKendra_Little Posts: 139 Gold 3
    Hi Ben,

    Some first places I would look...

    Is it possible some code was accidentally deployed to the model database and created that schema there? If you're using a dynamically named database to build (you're not specifying the name and it automatically creates one with a guid-like name), when SQL Server creates the db it will automatically have what's in model before any code is deployed and it could cause this issue.

    If that's not it, could some code have been added to a pre-deployment script that is doing this?

    Hope this helps,
    Kendra

Answers

  • I don't think we touch the model database at all and nothing should have been deployed there prior to this build.

    We did have some pre deployment scripts in this commit that (although it didn't affect this schema) I can review.
    That might be a good lead.

    Thanks
  • Kendra,

    It worked. I removed the pre-deployment script and my build succeeded.

    Still not sure why it would be the source of the issue because the script didn't touch that schema. We must be doing something else wrong...

    Good for now.

    Thanks!
Sign In or Register to comment.