IF Not EXISTS(SELECT * FROM sysobjects WHERE name='WarehouseHistory')
BEGIN 
CREATE TABLE [dbo].[WarehouseHistory](
	[Id] [INT] IDENTITY(1,1) NOT NULL,
	[Code] [SMALLINT] NOT NULL,
	[BeforeStatus] [TINYINT] NOT NULL,
	[AfterStatus] [TINYINT] NOT NULL,
	[UserId] [SMALLINT] NOT NULL,
	[Date] [SMALLDATETIME] NOT NULL,
 CONSTRAINT [PK_WarehouseHistory] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)
) ON [PRIMARY]

ALTER TABLE [dbo].[WarehouseHistory] ADD  CONSTRAINT [DF_WarehouseHistory_Date]  DEFAULT (GETDATE()) FOR [Date]
END 

