Skip to content

Status column on Version table is only added for one schema when bootstrapping (MS SQL) #728

@herms

Description

@herms

Describe the bug

Bootstrapping script 01_version_add_status_column.sql for SQL Server does not check schema name when deciding whether Version table has the Status column. If you have a database with multiple schemas and per-schema RoundhousE/Grate versioning, then the Status column will only be added once - for the first schema.

To Reproduce

Bootstrap an existing database that has multiple schemas and existing per-schema RoundhousE versioning. When bootstrapping Grate for all schemas, observe that the 01_version_add_status_column.sql is run for all schemas, but Status is actually only added to one schema.

Expected behavior

The Status column should be added to Version table for the "current" schema.

Screenshots
None.

Desktop (please complete the following information):

  • Database: Microsoft SQL Server
  • Version: 2.0.5

Additional context

The script should respect the schema name, e.g:

IF NOT EXISTS(
   SELECT 1 FROM sys.columns WHERE name = 'status'
   AND OBJECT_NAME(object_id) = '{{VersionTable}}'
   AND OBJECT_SCHEMA_NAME(object_id) = '{{SchemaName}}')
BEGIN
    ALTER TABLE {{SchemaName}}.{{VersionTable}}
    ADD status nvarchar(50) NULL
END

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions