USE [db_PalFactoryMonitoring]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[OPC_UA_Queue](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[ProdId] [nvarchar](10) NULL,
	[JsonValues] [nvarchar](max) NULL,
	[IsSentToMachine] [bit] NOT NULL,
	[IsSentToAx] [bit] NOT NULL,
	[CreatedBy] [nvarchar](100) NULL,
	[CreatedDateTime] [datetime] NULL,
	[WrkCtrId] [nvarchar](10) NULL,
	[IsInError] [bit] NOT NULL,
	[ErrorString] [nvarchar](255) NULL,
	[WrkCtrRecId] [bigint] NOT NULL,

    CONSTRAINT [PK_OPC_UA_QUEUE] 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].[OPC_UA_QUEUE] ADD  CONSTRAINT [DF_OPC_UA_QUEUE_IsSentToMachine]  DEFAULT ((0)) FOR [IsSentToMachine]
GO

ALTER TABLE [dbo].[OPC_UA_QUEUE] ADD  CONSTRAINT [DF_OPC_UA_QUEUE_IsSentToAx]  DEFAULT ((0)) FOR [IsSentToAx]
GO

ALTER TABLE [dbo].[OPC_UA_QUEUE] ADD  CONSTRAINT [DF_OPC_UA_QUEUE_CreatedDateTime]  DEFAULT (getdate()) FOR [CreatedDateTime]
GO

ALTER TABLE [dbo].[OPC_UA_QUEUE] ADD  CONSTRAINT [DF_OPC_UA_QUEUE_IsInError]  DEFAULT ((0)) FOR [IsInError]
GO

ALTER TABLE [dbo].[OPC_UA_QUEUE] ADD  CONSTRAINT [DF_OPC_UA_QUEUE_WrkCtrActivityId]  DEFAULT ((0)) FOR [WrkCtrRecId]
GO