if not exists (select * FROM sys.sysobjects where id = object_id(N'dbo.UserGroupInfo')) BEGIN
  create table dbo.UserGroupInfo (
    ID uniqueidentifier DEFAULT newid() NOT NULL,
    UserInfoID uniqueidentifier FOREIGN KEY REFERENCES dbo.UserInfo(ID),
    GroupInfoID uniqueidentifier FOREIGN KEY REFERENCES dbo.GroupInfo(ID),
    constraint PK_UserGroupInfo primary key clustered (ID)
  );
END;

if not exists (select * FROM sys.syscolumns where name = 'SecurityGroup' AND id = object_id(N'dbo.Connections')) 
  alter table dbo.Connections ADD SecurityGroup uniqueidentifier FOREIGN KEY REFERENCES dbo.GroupInfo(ID);