USE [ProjectOffice_WSR]
GO
/****** Object: Table [dbo].[Task] Script Date: 01.07.2023 23:43:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Task](
[Id] [int] NOT NULL,
[ProjectId] [int] NOT NULL,
[FullTitle] [nvarchar](200) NOT NULL,
[ShortTitle] [nvarchar](50) NOT NULL,
[Description] [nvarchar](max) NOT NULL,
[ExecutiveEmployeeId] [int] NOT NULL,
[StatusId] [int] NOT NULL,
[CreatedTime] [datetime] NOT NULL,
[UpdatedTime] [datetime] NULL,
[DeletedTime] [datetime] NULL,
[Deadline] [datetime] NOT NULL,
[StartActualTime] [datetime] NULL,
[FinishActualTime] [datetime] NULL,
[PreviousTaskId] [int] NULL,
CONSTRAINT [PK_Task] PRIMARY KEY CLUSTERED
(
[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] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[Task] ADD CONSTRAINT [DF_Task_CreatedTime] DEFAULT (getdate()) FOR [CreatedTime]
GO
ALTER TABLE [dbo].[Task] WITH CHECK ADD CONSTRAINT [FK_Task_Employee] FOREIGN KEY([ExecutiveEmployeeId])
REFERENCES [dbo].[Employee] ([Id])
GO
ALTER TABLE [dbo].[Task] CHECK CONSTRAINT [FK_Task_Employee]
GO
ALTER TABLE [dbo].[Task] WITH CHECK ADD CONSTRAINT [FK_Task_Project] FOREIGN KEY([ProjectId])
REFERENCES [dbo].[Project] ([Id])
GO
ALTER TABLE [dbo].[Task] CHECK CONSTRAINT [FK_Task_Project]
GO
ALTER TABLE [dbo].[Task] WITH CHECK ADD CONSTRAINT [FK_Task_Task] FOREIGN KEY([PreviousTaskId])
REFERENCES [dbo].[Task] ([Id])
GO
ALTER TABLE [dbo].[Task] CHECK CONSTRAINT [FK_Task_Task]
GO
ALTER TABLE [dbo].[Task] WITH CHECK ADD CONSTRAINT [FK_Task_TaskStatus] FOREIGN KEY([StatusId])
REFERENCES [dbo].[TaskStatus] ([Id])
GO
ALTER TABLE [dbo].[Task] CHECK CONSTRAINT [FK_Task_TaskStatus]
GO