if not exists (select * FROM sys.syscolumns where name = 'Category' AND id = object_id(N'dbo.Connections')) BEGIN
   alter table dbo.Connections ADD Category NVARCHAR(250) NULL
END;

if not exists (select * FROM sys.syscolumns where name = 'AttachmentCount' AND id = object_id(N'dbo.Connections')) BEGIN
   alter table dbo.Connections ADD AttachmentCount int NOT NULL DEFAULT(0)
END;

if not exists (select * FROM sys.syscolumns where name = 'AttachmentPrivateCount' AND id = object_id(N'dbo.Connections')) BEGIN
   alter table dbo.Connections ADD AttachmentPrivateCount int NOT NULL DEFAULT(0)
END;

if not exists (select * FROM sys.syscolumns where name = 'IsOpenned' AND id = object_id(N'dbo.Connections')) BEGIN
   alter table dbo.Connections ADD IsOpenned bit NOT NULL DEFAULT(0)
END;

if not exists (select * FROM sys.syscolumns where name = 'IsPrivate' AND id = object_id(N'dbo.Attachment')) BEGIN
   alter table dbo.Attachment ADD IsPrivate bit NOT NULL DEFAULT(0)
END;

if not exists (select * FROM sys.syscolumns where name = 'SecurityGroup' AND id = object_id(N'dbo.Attachment')) BEGIN
   alter table dbo.Attachment ADD SecurityGroup uniqueidentifier NULL 
END;

if not exists (select * FROM sys.syscolumns where name = 'HistoryID' AND id = object_id(N'dbo.Attachment')) BEGIN
   alter table dbo.Attachment ADD HistoryID uniqueidentifier NULL 
END;

if not exists (select * FROM sys.syscolumns where name = 'GroupName' AND id = object_id(N'dbo.Attachment')) BEGIN
   alter table dbo.Attachment ADD [GroupName] NVARCHAR(400) NULL 
END;

if not exists (select * FROM sys.syscolumns where name = 'PrivateSubType' AND id = object_id(N'dbo.Attachment')) BEGIN
   alter table dbo.Attachment ADD PrivateSubType NVARCHAR(100) NULL 
END;