Flyway

Integrate with Redgate SQL Monitor

EDITION: ENTERPRISE

SQL Monitor is a database monitoring and alerting solution for your entire SQL Server estate whether that's on-premise, in the cloud, or both.  For more information or to download SQL Monitor, go to Redgate SQL Monitor.

SQL Monitor's activity graph displays CPU, Memory, I/O use, and SQL Server Waits over time.  You can setup Flyway (using the instructions below) to annotate the graph with when database deployments happen.  This can help teams understand the impact of database releases on the server and quickly get to the root of a problem.  


Instructions

  1. Create a new file called afterMigrateApplied.sql in your migrations folder.
  2. Copy and paste the following code into this file.
  3. Save and commit/push to your repo.

|

The next time Flyway migrates a database, this event will be written to the SQL Server log and displayed on the SQL Monitor activity graph.

afterMigrateApplied.sql

-- ---------------------------------------------------------------------
-- Annotate this release on Redgate SQL Monitor 
-- ---------------------------------------------------------------------
IF HAS_PERMS_BY_NAME(N'sys.xp_logevent', N'OBJECT', N'EXECUTE') = 1
BEGIN
    DECLARE @databaseName AS nvarchar(2048), @eventMessage AS nvarchar(2048)
    SET @databaseName = REPLACE(REPLACE(DB_NAME(), N'\', N'\\'), N'"', N'\"')
    SET @eventMessage = N'Redgate Flyway: { "deployment": { "description": "Flyway deployed to ' + @databaseName + N'", "database": "' + @databaseName + N'" }}'
    EXECUTE sys.xp_logevent 55000, @eventMessage
END
GO

You can also use the Monitor API, which does not write to the error log.  You can read more about this on this blog.


Didn't find what you were looking for?