
/****** Object:  Table [dbo].[ApiTaskHistories]    Script Date: 06.09.2021 19:46:11 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[ApiTaskHistories](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[TaskId] [int] NOT NULL,
	[OperatorId] [int] NOT NULL,
	[OperatorName] [nvarchar](50) NOT NULL,
	[ObjectType] [int] NOT NULL,
	[ObjectId] [int] NOT NULL,
	[Description] [nvarchar](max) NOT NULL,
	[TimeSpend] [int] NOT NULL,
	[TS] [datetime] NOT NULL,
	[ModTS] [datetime] NOT NULL,
	[TaskSummaryLineId] [int] NOT NULL,
	ToSummary int not null,
	[Distance] [int] NOT NULL,
	[Value] [decimal](18, 2) NOT NULL,
	[DeviceId] [int] NOT NULL,
	[geolat] [float] NOT NULL,
	[geolong] [float] NOT NULL,
	[RelObjectId] [int] NOT NULL,
	[RelObjectType] [int] NOT NULL,
	[HistoryParentId] [int] NOT NULL,
	[RelObjectElem] [int] NULL,
 CONSTRAINT [PK_ApiTaskHisories] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  CONSTRAINT [DF_ApiTaskHisories_TaskId]  DEFAULT ((0)) FOR [TaskId]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  CONSTRAINT [DF_ApiTaskHisories_OperatorId]  DEFAULT ((0)) FOR [OperatorId]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  CONSTRAINT [DF_ApiTaskHisories_OperatorName]  DEFAULT ((0)) FOR [OperatorName]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  CONSTRAINT [DF_ApiTaskHisories_ObjectType]  DEFAULT ((0)) FOR [ObjectType]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  CONSTRAINT [DF_ApiTaskHisories_ObjectId]  DEFAULT ((0)) FOR [ObjectId]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  CONSTRAINT [DF_ApiTaskHisories_ModTS]  DEFAULT (getdate()) FOR [ModTS]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  DEFAULT ((0)) FOR [TaskSummaryLineId]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  DEFAULT ((0)) FOR [Distance]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  DEFAULT ((0)) FOR [Value]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  DEFAULT ((0)) FOR [DeviceId]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  DEFAULT ((0)) FOR [geolat]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  DEFAULT ((0)) FOR [geolong]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  DEFAULT ((0)) FOR [RelObjectId]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  DEFAULT ((0)) FOR [RelObjectType]
GO

ALTER TABLE [dbo].[ApiTaskHistories] ADD  DEFAULT ((0)) FOR [HistoryParentId]
GO


