EdwinVW/pitstop

Azure SQL is not supported

rouke-broersma opened this issue · 6 comments

See: https://github.com/EdwinVW/pitstop/blob/master/src/NotificationService/Repositories/SqlServerNotificationRepository.cs#L39

DB_ID always returns NULL for azure sql (single database).

We could instead use

"IF NOT EXISTS(SELECT * FROM master.sys.databases WHERE name='Notification') CREATE DATABASE Notification;"

The USE command is also not allowed on azure sql single database which is used by ChangeDatabase: https://github.com/EdwinVW/pitstop/blob/master/src/NotificationService/Repositories/SqlServerNotificationRepository.cs#L44

We can replace this with closing the sql connection to master and creating a new sql connection to the target database.

This does work on azure sql. Would this change be acceptable?

Yes that's fine - providing it also keeps working on SQL Server (which I assume is the case).

Fixed in commit 9383def
Successfully tested these changes on SQL Server.

Can you check whether this is sufficient to fix the issue?

This is the same change we made to our fork 👍

The only difference is that we did a conn.OpenAsync(); in the new connection scope but if you say the change works fine without it on SQL server then I guess it's not neccesary? 🤷

Yes, it makes sense to explicitly open the connection. I'll create a fix for that.

See commit f243358

I've also changed the SqlServerWorkshopPlanningEventSourceRepository of the WorkshopManagementAPI so its structure is identical to that of the other two repos.