-- Create Table
CREATE TABLE IF NOT EXISTS dbo."Prj_T_Timesheet" (
    "Id"                   UUID           NOT NULL CONSTRAINT "PK_Prj_T_Timesheet" PRIMARY KEY,
    "TenantId"             UUID           NULL,
    "TaskId"               UUID           NOT NULL REFERENCES dbo."Prj_T_Task" ("Id"),
    "WorkDate"             TIMESTAMP      NOT NULL,
    "UserId"               UUID           NULL,
    "Description"          VARCHAR(500)   NULL,
    "Hours"                NUMERIC(18, 2) NOT NULL DEFAULT 0,
    "CreationTime"         TIMESTAMP      NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC'),
    "CreatorId"            UUID           NULL,
    "LastModificationTime" TIMESTAMP      NULL,
    "LastModifierId"       UUID           NULL,
    "IsDeleted"            BOOLEAN        NOT NULL DEFAULT FALSE,
    "DeletionTime"         TIMESTAMP      NULL,
    "DeleterId"            UUID           NULL
);

CREATE INDEX IF NOT EXISTS "IX_Prj_T_Timesheet_TaskId_WorkDate" ON dbo."Prj_T_Timesheet" ("TaskId" ASC, "WorkDate" DESC);
