grate icon indicating copy to clipboard operation
grate copied to clipboard

Migrations hang on permissions scripts since v1.7.0

Open kimjamia opened this issue 3 months ago • 6 comments

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

kimjamia avatar Sep 17 '25 08:09 kimjamia