grate-devs / grate-devs/grate

Migrations hang on permissions scripts since v1.7.0

Open
#657 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
297
Forks
55
Avg merge
18m
Merged PRs (30d)
1

Description

**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`:
```sql
CREATE VIEW [myview] AS
SELECT 1 as [Number]
```

`permissions\Create.sql`:
```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`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.