Skip to content

Schema Compare issues when there are multiple objects with same name under a bucket #25337

@zijchen

Description

@zijchen

Version: 1.48.0-insider (user setup)
Commit: 8a715ed
Date: 2024-02-15T12:58:00.069Z
VS Code: 1.82.0
Electron: 25.9.8
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.22631

Scenario 1

  1. Create a database with this:
CREATE SCHEMA [Apps]
GO

CREATE TABLE [Apps].[Apps] ([Col1] INT NULL)
GO
  1. Create a new blank database project
  2. Update project from database
  3. Select "Flat" for folder structure"
    image
  4. In the Schema Compare window that opens, both the schema and table show up correctly. But if you click "Apply", on the schema is added to the sqlproj as Apps.sql
    image
  5. If we run schema compare again, the table now shows as a difference because it wasn't added the first time
  6. If you hit "Apply" again, the Apps.sql with the schema is overwritten with the table script and build fails because now it can't find the schema. SQL71501: SqlTable: [Apps].[Apps] has an unresolved reference to SqlSchema [Apps].

image

Scenario 2

  1. Create a database with this:
CREATE LOGIN [Apps] WITH PASSWORD = '***'
GO

CREATE USER [Apps] FOR LOGIN [Apps] WITH DEFAULT_SCHEMA = [Apps]
GO

CREATE SCHEMA [Apps] AUTHORIZATION [Apps]
GO
  1. Create a new database project, add only the login to it:
CREATE LOGIN [Apps] WITH PASSWORD = '***'
  1. Update project from database. This time it doesn't matter which folder structure you choose, both the user and the schema ends up in the same folder. If you apply changes, only the schema is created, and you get a build error SQL71501: SqlSchema: [Apps] has an unresolved reference to object [Apps].
    image
  2. If you schema compare again, the User shows up as a change because it wasn't added the first time. Applying this change results in the schema Apps being overwritten by the user, and we get a new build error SQL71502: SqlUser: [Apps] has an unresolved reference to SqlSchema [Apps].
    image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions