IF OBJECT_ID(N'[dbo].[Hr_T_PerformanceCompetency]', 'U') IS NULL BEGIN CREATE TABLE [dbo].[Hr_T_PerformanceCompetency] ( [Id] uniqueidentifier NOT NULL DEFAULT NEWID(), [TenantId] uniqueidentifier NULL, [ReviewId] uniqueidentifier NOT NULL, [SkillId] uniqueidentifier NOT NULL, [ExpectedLevelId] uniqueidentifier NULL, [SelfLevelId] uniqueidentifier NULL, [ManagerLevelId] uniqueidentifier NULL, [Score] decimal(6, 2) NULL, [SelfComment] nvarchar(1024) NULL, [ManagerComment] nvarchar(1024) NULL, [IsActive] bit NOT NULL DEFAULT 1, [CreationTime] datetime2 NOT NULL DEFAULT GETUTCDATE(), [CreatorId] uniqueidentifier NULL, [LastModificationTime] datetime2 NULL, [LastModifierId] uniqueidentifier NULL, [IsDeleted] bit NOT NULL DEFAULT 0, [DeletionTime] datetime2 NULL, [DeleterId] uniqueidentifier NULL, CONSTRAINT [PK_Hr_T_PerformanceCompetency] PRIMARY KEY NONCLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'UX_Hr_T_PerformanceCompetency_Skill' AND object_id = OBJECT_ID(N'[dbo].[Hr_T_PerformanceCompetency]')) CREATE UNIQUE NONCLUSTERED INDEX [UX_Hr_T_PerformanceCompetency_Skill] ON [dbo].[Hr_T_PerformanceCompetency] ([ReviewId], [SkillId]) WHERE [IsDeleted] = 0 GO