IF OBJECT_ID(N'[dbo].[Hr_T_PerformanceRating]', 'U') IS NULL BEGIN CREATE TABLE [dbo].[Hr_T_PerformanceRating] ( [Id] uniqueidentifier NOT NULL DEFAULT NEWID(), [TenantId] uniqueidentifier NULL, [Name] nvarchar(128) NOT NULL, [Level] int NOT NULL, [MinScore] decimal(6, 2) NOT NULL, [MaxScore] decimal(6, 2) NOT NULL, [Color] nvarchar(16) NULL, [TargetDistribution] decimal(5, 2) NULL, [Description] nvarchar(512) 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_PerformanceRating] 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 OBJECT_ID(N'[dbo].[CK_Hr_T_PerformanceRating_Range]', 'C') IS NULL ALTER TABLE [dbo].[Hr_T_PerformanceRating] ADD CONSTRAINT [CK_Hr_T_PerformanceRating_Range] CHECK ([MinScore] < [MaxScore]) GO IF OBJECT_ID(N'[dbo].[CK_Hr_T_PerformanceRating_TargetDistribution]', 'C') IS NULL ALTER TABLE [dbo].[Hr_T_PerformanceRating] ADD CONSTRAINT [CK_Hr_T_PerformanceRating_TargetDistribution] CHECK ([TargetDistribution] IS NULL OR [TargetDistribution] BETWEEN 0 AND 100) GO IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'UX_Hr_T_PerformanceRating_Level' AND object_id = OBJECT_ID(N'[dbo].[Hr_T_PerformanceRating]')) CREATE UNIQUE NONCLUSTERED INDEX [UX_Hr_T_PerformanceRating_Level] ON [dbo].[Hr_T_PerformanceRating] ([TenantId], [Level]) WHERE [IsDeleted] = 0 GO