50 lines
2.3 KiB
Transact-SQL
50 lines
2.3 KiB
Transact-SQL
IF OBJECT_ID(N'[dbo].[Hr_T_Timesheet]', 'U') IS NULL
|
|
BEGIN
|
|
CREATE TABLE [dbo].[Hr_T_Timesheet]
|
|
(
|
|
[Id] uniqueidentifier NOT NULL DEFAULT NEWID(),
|
|
[TenantId] uniqueidentifier NULL,
|
|
[EmployeeId] uniqueidentifier NOT NULL,
|
|
[WorkDate] date NOT NULL,
|
|
[PeriodYear] int NOT NULL,
|
|
[PeriodMonth] int NOT NULL,
|
|
[PeriodKey] nvarchar(48) NOT NULL,
|
|
[ShiftId] uniqueidentifier NULL,
|
|
[DayType] nvarchar(16) NOT NULL DEFAULT N'Work',
|
|
[LeaveTypeId] uniqueidentifier NULL,
|
|
[TrainingId] uniqueidentifier NULL,
|
|
[FirstIn] datetime2 NULL,
|
|
[LastOut] datetime2 NULL,
|
|
[BreakMinutes] int NOT NULL DEFAULT 0,
|
|
[NetMinutes] int NOT NULL DEFAULT 0,
|
|
[NetHours] decimal(6, 2) NOT NULL DEFAULT 0,
|
|
[LateMinutes] int NOT NULL DEFAULT 0,
|
|
[EarlyLeaveMinutes] int NOT NULL DEFAULT 0,
|
|
[OvertimeHours] decimal(6, 2) NOT NULL DEFAULT 0,
|
|
[IsManual] bit NOT NULL DEFAULT 0,
|
|
[IsIncomplete] bit NOT NULL DEFAULT 0,
|
|
[IsAssumed] bit NOT NULL DEFAULT 0,
|
|
[Note] nvarchar(512) NULL,
|
|
[CalculatedAt] datetime2 NULL,
|
|
[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_Timesheet] 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'IX_Hr_T_Timesheet_EmployeeDate' AND object_id = OBJECT_ID(N'[dbo].[Hr_T_Timesheet]'))
|
|
CREATE INDEX [IX_Hr_T_Timesheet_EmployeeDate] ON [dbo].[Hr_T_Timesheet] ([EmployeeId], [WorkDate]) INCLUDE ([IsDeleted], [IsManual])
|
|
GO
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Hr_T_Timesheet_Period' AND object_id = OBJECT_ID(N'[dbo].[Hr_T_Timesheet]'))
|
|
CREATE INDEX [IX_Hr_T_Timesheet_Period] ON [dbo].[Hr_T_Timesheet] ([TenantId], [PeriodYear], [PeriodMonth]) INCLUDE ([EmployeeId], [DayType], [IsDeleted])
|
|
GO
|