IF NOT EXISTS(SELECT * FROM sys.sysobjects WHERE name ='UserShiftWorkDetail' and xtype='U')
Begin
CREATE TABLE [dbo].[UserShiftWorkDetail](
	[Id] [UNIQUEIDENTIFIER] NOT NULL,
	[UserShiftWorkId] [UNIQUEIDENTIFIER] NOT NULL,
	[AccountId] [INT] NOT NULL,
	[CashierPrice] [MONEY] NULL,
	[TreasuryPrice] [MONEY] NULL,
	[InitialExpectationPrice] [MONEY] NOT NULL,
	[Description] [NVARCHAR](25) NULL,
	[IsReadOnly] [BIT] NOT NULL,
	[EditType] [BIT] NOT NULL,
 CONSTRAINT [PK_UserShiftWorkDetail] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)
) ON [PRIMARY]

ALTER TABLE [dbo].[UserShiftWorkDetail] ADD  CONSTRAINT [DF_UserShiftWorkDetail_Id]  DEFAULT (NEWID()) FOR [Id]
ALTER TABLE [dbo].[UserShiftWorkDetail] ADD  CONSTRAINT [DF_UserShiftWorkDetail_InitialExpectationPrice]  DEFAULT ((0)) FOR [InitialExpectationPrice]
ALTER TABLE [dbo].[UserShiftWorkDetail] ADD  CONSTRAINT [DF_UserShiftWorkDetail_IsChangeRecord]  DEFAULT ((0)) FOR [IsReadOnly]
ALTER TABLE [dbo].[UserShiftWorkDetail] ADD  CONSTRAINT [DF_UserShiftWorkDetail_EditType]  DEFAULT ((0)) FOR [EditType]
ALTER TABLE [dbo].[UserShiftWorkDetail]  WITH CHECK ADD  CONSTRAINT [FK_UserShiftWorkDetail_UserShiftWork] FOREIGN KEY([UserShiftWorkId])
REFERENCES [dbo].[UserShiftWork] ([Id])
ON DELETE CASCADE
ALTER TABLE [dbo].[UserShiftWorkDetail] CHECK CONSTRAINT [FK_UserShiftWorkDetail_UserShiftWork]

END