sozsoft-platform/configs/seeds/sql/object/Hr_T_PerformancePeriod.sql

43 lines
2 KiB
MySQL
Raw Normal View History

2026-10-04 15:04:16 +00:00
IF OBJECT_ID(N'[dbo].[Hr_T_PerformancePeriod]', 'U') IS NULL
BEGIN
CREATE TABLE [dbo].[Hr_T_PerformancePeriod]
(
[Id] uniqueidentifier NOT NULL DEFAULT NEWID(),
[TenantId] uniqueidentifier NULL,
[Name] nvarchar(128) NOT NULL,
[StartDate] date NOT NULL,
[EndDate] date NOT NULL,
[SelfReviewDueDate] date NULL,
[ManagerReviewDueDate] date NULL,
[GoalWeight] decimal(5, 2) NOT NULL DEFAULT 60,
[CompetencyWeight] decimal(5, 2) NOT NULL DEFAULT 40,
[Is360Enabled] bit NOT NULL DEFAULT 0,
[Status] nvarchar(16) NOT NULL DEFAULT 'Planned',
[Description] 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_PerformancePeriod] 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_PerformancePeriod_Dates]', 'C') IS NULL
ALTER TABLE [dbo].[Hr_T_PerformancePeriod] ADD CONSTRAINT [CK_Hr_T_PerformancePeriod_Dates] CHECK ([EndDate] >= [StartDate])
GO
IF OBJECT_ID(N'[dbo].[CK_Hr_T_PerformancePeriod_Weights]', 'C') IS NULL
ALTER TABLE [dbo].[Hr_T_PerformancePeriod] ADD CONSTRAINT [CK_Hr_T_PerformancePeriod_Weights] CHECK ([GoalWeight] >= 0 AND [CompetencyWeight] >= 0 AND [GoalWeight] + [CompetencyWeight] = 100)
GO
IF OBJECT_ID(N'[dbo].[CK_Hr_T_PerformancePeriod_Status]', 'C') IS NULL
ALTER TABLE [dbo].[Hr_T_PerformancePeriod] ADD CONSTRAINT [CK_Hr_T_PerformancePeriod_Status] CHECK ([Status] IN ('Planned', 'Active', 'Calibration', 'Closed'))
GO