Skip to content

Migrations hang on permissions scripts since v1.7.0 #657

@kimjamia

Description

@kimjamia

Describe the bug
Ever since v1.7.0 permissions scripts will just hang if a view script exists and when running with --trx on SQL Server. It doesn't even have to run it in the same migration. It's enough that the view script exists and has previously been run.

I originally reported this as #508 but then I couldn't correctly pinpoint the issue and we ended up on the wrong track.

To Reproduce

  1. Install 1.7.0 or 1.8.0 with dotnet tool: dotnet tool update -g grate --allow-downgrade --version 1.8.0.
  2. Create views\01.sql
  3. Create permissions\Create.sql
  4. Run grate --connectionstring "Server=localhost,1433;Database=***;TrustServerCertificate=True;User Id=sa;Password=***" --files . --trx
  5. Observe that grate hangs on Running 'Create.sql'.

Example scripts:
views\01.sql:

CREATE VIEW [myview] AS
SELECT 1 as [Number]

permissions\Create.sql:

DROP USER IF EXISTS [myuser];
CREATE USER [myuser] WITHOUT LOGIN

You can also leave out the Create.sql, run migrations, then add the Create.sql and try to run migrations. The view has been created but Create.sql will hang.

Expected behavior
Create.sql completes and the user is created in the db.

Desktop (please complete the following information):

  • OS: Windows
  • Version: 1.7.0 or 1.8.0
  • Installed with dotnet tool

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