if not exists (select * from dbo.sysobjects where id= object_id(N'[dbo].[PK_department]') and OBJECTPROPERTY(id, N'IsPrimaryKey')=1)
ALTER TABLE [dbo].[department] ADD 
	CONSTRAINT [PK_department] PRIMARY KEY  CLUSTERED 
	(
		[pkId]
	)  ON [PRIMARY] 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Department_Users_FK1]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) ALTER TABLE [dbo].[Users] DROP CONSTRAINT Department_Users_FK1
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_Users_Department]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) ALTER TABLE [dbo].[Users] DROP CONSTRAINT FK_Users_Department
GO
ALTER TABLE [dbo].[Users] ADD CONSTRAINT [Department_Users_FK1] FOREIGN KEY ([departmentId]) REFERENCES [dbo].[Department] ([pkId])
GO



