-- Final update actions, migrations etc.

USE [VIGIL-DVR]
GO

-- Migrate Advanced Reporting permission to granular reporting permissions
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 12200) > 0
BEGIN
	INSERT INTO grouppermission(groupname, permission_id)
	SELECT  groupname, 13000 FROM grouppermission WHERE permission_id = 12200

	INSERT INTO grouppermission(groupname, permission_id)
	SELECT  groupname, 13100 FROM grouppermission WHERE permission_id = 12200

	INSERT INTO grouppermission(groupname, permission_id)
	SELECT  groupname, 13200 FROM grouppermission WHERE permission_id = 12200

	INSERT INTO grouppermission(groupname, permission_id)
	SELECT  groupname, 13300 FROM grouppermission WHERE permission_id = 12200

	DELETE FROM perms WHERE permission_id = 12200
END
GO
