USE [DD_ECM]
GO
/****** Object:  Table [dbo].[TBCUST_JOBRUNNER_MAPPING]    Script Date: 23.01.2024 13:56:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBCUST_JOBRUNNER_MAPPING](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[SourcePath] [varchar](200) NOT NULL,
	[DestinationColumn] [varchar](200) NOT NULL,
	[ADDED_WHO] [varchar](100) NOT NULL,
	[ADDED_WHEN] [datetime] NULL,
 CONSTRAINT [PK_TBCUST_JOBRUNNER_MAPPING_GUID] PRIMARY KEY CLUSTERED 
(
	[GUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UQ_TBCUST_JOBRUNNER_MAPPING] UNIQUE NONCLUSTERED 
(
	[SourcePath] ASC,
	[DestinationColumn] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TBCUST_JOBRUNNER_QUERY]    Script Date: 23.01.2024 13:56:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBCUST_JOBRUNNER_QUERY](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[TITLE] [varchar](200) NOT NULL,
	[CON_ID] [smallint] NOT NULL,
	[QUERY_STRING] [varchar](4000) NOT NULL,
	[OPERATION_NAME] [varchar](200) NOT NULL,
	[DESTINATION_TABLE] [varchar](200) NOT NULL,
	[CLEAR_BEFORE_FILL] [bit] NOT NULL,
	[MAPPING_BASE_PATH] [varchar](200) NOT NULL,
	[COMMENT] [varchar](250) NULL,
	[ADDED_WHO] [varchar](100) NOT NULL,
	[ADDED_WHEN] [datetime] NULL,
	[SEQUENCE] [int] NOT NULL,
 CONSTRAINT [PK_TBCUST_JOBRUNNER_QUERY_GUID] PRIMARY KEY CLUSTERED 
(
	[GUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UQ_TBCUST_JOBRUNNER_NAME] UNIQUE NONCLUSTERED 
(
	[TITLE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UQ_TBCUST_JOBRUNNER_QUERY_STRING] UNIQUE NONCLUSTERED 
(
	[QUERY_STRING] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TBCUST_JOBRUNNER_QUERY_MAPPING]    Script Date: 23.01.2024 13:56:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBCUST_JOBRUNNER_QUERY_MAPPING](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[QUERY_ID] [int] NOT NULL,
	[MAPPING_ID] [int] NOT NULL,
	[ADDED_WHO] [varchar](100) NOT NULL,
	[ADDED_WHEN] [datetime] NULL,
 CONSTRAINT [PK_TBCUST_JOBRUNNER_QUERY_MAPPING_GUID] PRIMARY KEY CLUSTERED 
(
	[GUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [FK_TBCUST_JOBRUNNER_QUERY_MAPPING] UNIQUE NONCLUSTERED 
(
	[QUERY_ID] ASC,
	[MAPPING_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]
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_MAPPING] ADD  DEFAULT ('Digital Data') FOR [ADDED_WHO]
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_MAPPING] ADD  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_QUERY] ADD  CONSTRAINT [DF__TBCUST_JO__CLEAR__6EEB59C5]  DEFAULT ((0)) FOR [CLEAR_BEFORE_FILL]
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_QUERY] ADD  CONSTRAINT [DF__TBCUST_JO__MAPPI__6FDF7DFE]  DEFAULT ('') FOR [MAPPING_BASE_PATH]
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_QUERY] ADD  CONSTRAINT [DF__TBCUST_JO__ADDED__70D3A237]  DEFAULT ('Digital Data') FOR [ADDED_WHO]
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_QUERY] ADD  CONSTRAINT [DF__TBCUST_JO__ADDED__71C7C670]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_QUERY] ADD  CONSTRAINT [DF_TBCUST_JOBRUNNER_QUERY_SEQUENCE]  DEFAULT ((0)) FOR [SEQUENCE]
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_QUERY_MAPPING] ADD  DEFAULT ('Digital Data') FOR [ADDED_WHO]
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_QUERY_MAPPING] ADD  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_QUERY_MAPPING]  WITH CHECK ADD  CONSTRAINT [FK_TBCUST_JOBRUNNER_QUERY_MAPPING_MAPPING_ID] FOREIGN KEY([MAPPING_ID])
REFERENCES [dbo].[TBCUST_JOBRUNNER_MAPPING] ([GUID])
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_QUERY_MAPPING] CHECK CONSTRAINT [FK_TBCUST_JOBRUNNER_QUERY_MAPPING_MAPPING_ID]
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_QUERY_MAPPING]  WITH CHECK ADD  CONSTRAINT [FK_TBCUST_JOBRUNNER_QUERY_MAPPING_QUERY_ID] FOREIGN KEY([QUERY_ID])
REFERENCES [dbo].[TBCUST_JOBRUNNER_QUERY] ([GUID])
GO
ALTER TABLE [dbo].[TBCUST_JOBRUNNER_QUERY_MAPPING] CHECK CONSTRAINT [FK_TBCUST_JOBRUNNER_QUERY_MAPPING_QUERY_ID]
GO
