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

44 lines
2.3 KiB
MySQL
Raw Normal View History

2026-10-04 15:04:16 +00:00
IF OBJECT_ID(N'[dbo].[Hr_T_PerformanceFeedback]', 'U') IS NULL
BEGIN
CREATE TABLE [dbo].[Hr_T_PerformanceFeedback]
(
[Id] uniqueidentifier NOT NULL DEFAULT NEWID(),
[TenantId] uniqueidentifier NULL,
[ReviewId] uniqueidentifier NOT NULL,
[ReviewerId] uniqueidentifier NOT NULL,
[Relation] nvarchar(16) NOT NULL DEFAULT 'Peer',
[Status] nvarchar(16) NOT NULL DEFAULT 'Pending',
[Score] decimal(6, 2) NULL,
[Comment] nvarchar(2048) NULL,
[SubmittedDate] datetime2 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_PerformanceFeedback] 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_PerformanceFeedback_Relation]', 'C') IS NULL
ALTER TABLE [dbo].[Hr_T_PerformanceFeedback] ADD CONSTRAINT [CK_Hr_T_PerformanceFeedback_Relation] CHECK ([Relation] IN ('Peer', 'Subordinate', 'Superior', 'InternalCustomer'))
GO
IF OBJECT_ID(N'[dbo].[CK_Hr_T_PerformanceFeedback_Status]', 'C') IS NULL
ALTER TABLE [dbo].[Hr_T_PerformanceFeedback] ADD CONSTRAINT [CK_Hr_T_PerformanceFeedback_Status] CHECK ([Status] IN ('Pending', 'Submitted'))
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'UX_Hr_T_PerformanceFeedback_Reviewer' AND object_id = OBJECT_ID(N'[dbo].[Hr_T_PerformanceFeedback]'))
CREATE UNIQUE NONCLUSTERED INDEX [UX_Hr_T_PerformanceFeedback_Reviewer] ON [dbo].[Hr_T_PerformanceFeedback] ([ReviewId], [ReviewerId]) WHERE [IsDeleted] = 0
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Hr_T_PerformanceFeedback_ReviewerId' AND object_id = OBJECT_ID(N'[dbo].[Hr_T_PerformanceFeedback]'))
CREATE NONCLUSTERED INDEX [IX_Hr_T_PerformanceFeedback_ReviewerId] ON [dbo].[Hr_T_PerformanceFeedback] ([ReviewerId])
GO