if not exists (select * FROM sys.sysobjects where id = object_id(N'dbo.ConnectionState'))
	create table dbo.ConnectionState
	(
		ID uniqueidentifier not null,
		ConnectionID uniqueidentifier not null constraint FK_ConnectionState_ConnectionID foreign key references dbo.Connections(ID) on delete cascade,
		RepositoryID uniqueidentifier not null constraint FK_ConnectionState_RepositoryID foreign key references dbo.Repository(ID),
		UserID uniqueidentifier not null constraint FK_ConnectionState_UserID foreign key references dbo.UserAccount(ID) on delete cascade,
		State int not null,
		Comment nvarchar(max) null,
		ExpirationDate datetime null,
        MachineName nvarchar(256) null,
		CreationDate datetime null,
		CreationUsername nvarchar(256) null,
		CreationLoggedUserName nvarchar(256) null,
		constraint PK_ConnectionState primary key nonclustered (ID asc)
	);