if not exists (select * FROM sys.syscolumns where name = 'PermissionCacheID' AND id = object_id(N'dbo.ConnectionHistory'))
    alter table dbo.ConnectionHistory add PermissionCacheID uniqueidentifier null;