-- Tables

-- Alters

IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[AKUZ].[T_CDA_SECTION_WORK_CHILD]') AND name = N'UQ_T_CDA_SECTION_WORK_CHILD_CdaChildHealthState' and is_unique_constraint <> 1)
DROP INDEX [UQ_T_CDA_SECTION_WORK_CHILD_CdaChildHealthState] ON [AKUZ].[T_CDA_SECTION_WORK_CHILD]


IF NOT EXISTS (SELECT * FROM sys.columns WHERE object_id = OBJECT_ID(N'[AKUZ].[T_CDA_SECTION_WORK_CHILD]') AND name = N'CdaChildHealthState_UQ')
ALTER TABLE [AKUZ].[T_CDA_SECTION_WORK_CHILD] ADD [CdaChildHealthState_UQ] AS (CASE WHEN [CdaChildHealthState] IS NOT NULL THEN NULL ELSE [CdaSectionWorkChildID] END)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[AKUZ].[T_CDA_SECTION_WORK_CHILD]') AND name = N'UQ_T_CDA_SECTION_WORK_CHILD_CdaChildHealthState' and is_unique_constraint <> 1)
CREATE UNIQUE NONCLUSTERED INDEX [UQ_T_CDA_SECTION_WORK_CHILD_CdaChildHealthState] ON [AKUZ].[T_CDA_SECTION_WORK_CHILD] ([CdaChildHealthState] ASC, [CdaChildHealthState_UQ] ASC) ON [PRIMARY]
GO

