USE [DD_ECM]
GO
/****** Object:  Table [dbo].[TBSIG_RECEIVER]    Script Date: 07.08.2023 10:09:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBSIG_RECEIVER](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[EMAIL_ADDRESS] [nvarchar](128) NOT NULL,
	[SIGNATURE] [nvarchar](64) NOT NULL,
	[ADDED_WHEN] [datetime] NOT NULL,
 CONSTRAINT [PK_TBSIG_RECEIVER] 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]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TBSIG_ENVELOPE_RECEIVER]    Script Date: 07.08.2023 10:09:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBSIG_ENVELOPE_RECEIVER](
	[ENVELOPE_ID] [int] NOT NULL,
	[RECEIVER_ID] [int] NOT NULL,
	[SEQUENCE] [int] NOT NULL,
	[NAME] [nvarchar](128) NULL,
	[JOB_TITLE] [nvarchar](128) NULL,
	[COMPANY_NAME] [nvarchar](128) NULL,
	[PRIVATE_MESSAGE] [nvarchar](max) NULL,
	[ACCESS_CODE] [nvarchar](64) NULL,
	[ADDED_WHEN] [datetime] NOT NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK_TBSIG_ENVELOPE_RECEIVER] PRIMARY KEY CLUSTERED 
(
	[ENVELOPE_ID] ASC,
	[RECEIVER_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
/****** Object:  View [dbo].[VWSIG_ENVELOPE_RECEIVERS]    Script Date: 07.08.2023 10:09:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE   VIEW [dbo].[VWSIG_ENVELOPE_RECEIVERS] as 
SELECT T2.GUID, T.ENVELOPE_ID, T.PRIVATE_MESSAGE, T.ACCESS_CODE, T.[SEQUENCE], T.NAME, T2.EMAIL_ADDRESS 
FROM TBSIG_ENVELOPE_RECEIVER T
JOIN TBSIG_RECEIVER T2 ON T.RECEIVER_ID = T2.GUID
GO
/****** Object:  Table [dbo].[TBSIG_CONFIG]    Script Date: 07.08.2023 10:09:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBSIG_CONFIG](
	[DOCUMENT_PATH] [nvarchar](256) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT]    Script Date: 07.08.2023 10:09:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[DOCUMENT_ID] [int] NOT NULL,
	[RECEIVER_ID] [int] NOT NULL,
	[STATUS] [nvarchar](64) NOT NULL,
	[ELEMENT_TYPE] [nvarchar](32) NOT NULL,
	[POSITION_X] [float] NOT NULL,
	[POSITION_Y] [float] NOT NULL,
	[WIDTH] [float] NOT NULL,
	[HEIGHT] [float] NOT NULL,
	[PAGE] [int] NOT NULL,
	[REQUIRED] [bit] NOT NULL,
	[TOOLTIP] [nvarchar](512) NULL,
	[READ_ONLY] [bit] NOT NULL,
	[ELEMENT_VALUE] [nvarchar](1024) NULL,
	[ANNOTATION_INDEX] [int] NOT NULL,
	[STATUS_CHANGED_WHEN] [datetime] NULL,
	[ADDED_WHEN] [datetime] NOT NULL,
	[CHANGED_WHEN] [datetime] NULL,
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TBSIG_ENVELOPE]    Script Date: 07.08.2023 10:09:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBSIG_ENVELOPE](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[USER_ID] [int] NOT NULL,
	[STATUS] [nvarchar](64) NOT NULL,
	[ENVELOPE_UUID] [nvarchar](36) NOT NULL,
	[SUBJECT] [nvarchar](512) NOT NULL,
	[MESSAGE] [nvarchar](max) NOT NULL,
	[SENT_WHEN] [datetime] NULL,
	[EXPIRES_WHEN] [datetime] NULL,
	[EXPIRES_WARNING_WHEN] [datetime] NULL,
	[ADDED_WHEN] [datetime] NOT NULL,
	[CHANGED_WHEN] [datetime] NULL,
 CONSTRAINT [PK_TBSIG_ENVELOPE] 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]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TBSIG_ENVELOPE_DOCUMENT]    Script Date: 07.08.2023 10:09:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBSIG_ENVELOPE_DOCUMENT](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[ENVELOPE_ID] [int] NOT NULL,
	[FILENAME] [nvarchar](256) NOT NULL,
	[FILEPATH] [nvarchar](256) NOT NULL,
	[ADDED_WHEN] [datetime] NOT NULL,
 CONSTRAINT [PK_TBSIG_DOCUMENT] 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]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TBSIG_ENVELOPE_HISTORY]    Script Date: 07.08.2023 10:09:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBSIG_ENVELOPE_HISTORY](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[ENVELOPE_ID] [int] NOT NULL,
	[STATUS] [nvarchar](64) NOT NULL,
	[USER_EMAIL_ADDRESS] [nvarchar](128) NOT NULL,
	[ACTION_TITLE] [nvarchar](64) NOT NULL,
	[ACTION_DESCRIPTION] [nvarchar](512) NOT NULL,
	[ADDED_WHEN] [datetime] NOT NULL,
 CONSTRAINT [PK_TBSIG_HISTORY] 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]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TBSIG_USER_RECEIVER]    Script Date: 07.08.2023 10:09:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TBSIG_USER_RECEIVER](
	[GUID] [int] IDENTITY(1,1) NOT NULL,
	[USER_ID] [int] NOT NULL,
	[RECEIVER_ID] [int] NOT NULL,
	[NAME] [nvarchar](128) NOT NULL,
	[COMPANY_NAME] [nvarchar](128) NULL,
	[JOB_TITLE] [nvarchar](128) NULL,
	[ADDED_WHEN] [datetime] NOT NULL,
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] ADD  CONSTRAINT [DF_TBSIG_DOCUMENT_RECEIVER_ELEMENT_POSITION_X]  DEFAULT ((0)) FOR [POSITION_X]
GO
ALTER TABLE [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] ADD  CONSTRAINT [DF_TBSIG_DOCUMENT_RECEIVER_ELEMENT_POSITION_Y]  DEFAULT ((0)) FOR [POSITION_Y]
GO
ALTER TABLE [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] ADD  CONSTRAINT [DF_TBSIG_DOCUMENT_RECEIVER_ELEMENT_WIDTH]  DEFAULT ((0)) FOR [WIDTH]
GO
ALTER TABLE [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] ADD  CONSTRAINT [DF_TBSIG_DOCUMENT_RECEIVER_ELEMENT_HEIGHT]  DEFAULT ((0)) FOR [HEIGHT]
GO
ALTER TABLE [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] ADD  CONSTRAINT [DF_TBSIG_DOCUMENT_RECEIVER_ELEMENT_PAGE]  DEFAULT ((1)) FOR [PAGE]
GO
ALTER TABLE [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] ADD  CONSTRAINT [DF_TBSIG_DOCUMENT_RECEIVER_ELEMENT_REQUIRED]  DEFAULT ((0)) FOR [REQUIRED]
GO
ALTER TABLE [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] ADD  CONSTRAINT [DF_TBSIG_DOCUMENT_RECEIVER_ELEMENT_READ_ONLY]  DEFAULT ((0)) FOR [READ_ONLY]
GO
ALTER TABLE [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] ADD  CONSTRAINT [DF_TBSIG_DOCUMENT_RECEIVER_ELEMENTS_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] ADD  CONSTRAINT [DEFAULT_TBSIG_DOCUMENT_RECEIVER_ELEMENT_ANNOTATION_INDEX]  DEFAULT ((0)) FOR [ANNOTATION_INDEX]
GO
ALTER TABLE [dbo].[TBSIG_ENVELOPE] ADD  CONSTRAINT [DF_TBSIG_ENVELOPE_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBSIG_ENVELOPE_DOCUMENT] ADD  CONSTRAINT [DF_TBSIG_DOCUMENT_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBSIG_ENVELOPE_HISTORY] ADD  CONSTRAINT [DF_TBSIG_HISTORY_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBSIG_ENVELOPE_RECEIVER] ADD  CONSTRAINT [DF_TBSIG_ENVELOPE_RECEIVER_SEQUENCE]  DEFAULT ((0)) FOR [SEQUENCE]
GO
ALTER TABLE [dbo].[TBSIG_ENVELOPE_RECEIVER] ADD  CONSTRAINT [DF_TBSIG_ENVELOPE_RECEIVER_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBSIG_RECEIVER] ADD  CONSTRAINT [DF_TBSIG_RECEIVER_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
ALTER TABLE [dbo].[TBSIG_USER_RECEIVER] ADD  CONSTRAINT [DF_TBSIG_USER_RECEIVER_ADDED_WHEN]  DEFAULT (getdate()) FOR [ADDED_WHEN]
GO
