UPDATE TBDD_MODULES SET DB_VERSION = '1.5.3.0' WHERE SHORT_NAME = 'SIG_ENV_CR'
GO

ALTER TABLE [dbo].[TBSIG_CONFIG] ADD [DEF_VERIFICATION_TYPE] TINYINT NOT NULL DEFAULT 0;
GO
ALTER TABLE [dbo].[TBSIG_ENVELOPE] ADD [VERIFICATION_TYPE] TINYINT NOT NULL DEFAULT 0;
GO
ALTER TABLE [dbo].[TBSIG_RECEIVER] ADD [TOTP_EXPIRATION] DATETIME;
GO
ALTER TABLE [dbo].[TBSIG_RECEIVER] ADD [TOTP_SECRET_KEY] NVARCHAR(MAX);
GO
USE [DD_ECM]
GO

/****** Object:  View [dbo].[VWSIG_ENVELOPE_DATA]    Script Date: 07.01.2025 09:45:40 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- Changed	07.01.2025	MS	VerifType integriert
ALTER VIEW [dbo].[VWSIG_ENVELOPE_DATA] AS
SELECT 
	ENV.[GUID] ENVELOPE_ID
    ,[USER_ID]	
	,USR.EMAIL USER_EMAIL
	,USR.PRENAME + ' ' + USR.NAME USER_PRE_NAME
    ,[STATUS] ENVELOPE_STATE
	,ENV.VERIFICATION_TYPE
    ,[ENVELOPE_UUID]
	,[LANG_CODE]			ENV_LANG_CODE
    ,[MESSAGE]
    ,[EXPIRES_WHEN]
    ,[EXPIRES_WARNING_WHEN]
    ,ENV.[ADDED_WHEN]
    ,ENV.[CHANGED_WHEN]
    ,[TITLE]
    ,[CONTRACT_TYPE]
    ,ENV.[LANGUAGE]
    ,[SEND_REMINDER_EMAILS]
    ,[FIRST_REMINDER_DAYS]
    ,[REMINDER_INTERVAL_DAYS]
    ,[ENVELOPE_TYPE]
    ,[CERTIFICATION_TYPE]
    ,[USE_ACCESS_CODE]
    ,[FINAL_EMAIL_TO_CREATOR]
    ,[FINAL_EMAIL_TO_RECEIVERS]
    ,[EXPIRES_WHEN_DAYS]
    ,[EXPIRES_WARNING_WHEN_DAYS]
  FROM 
	[TBSIG_ENVELOPE] ENV INNER JOIN TBDD_USER USR ON ENV.USER_ID = USR.GUID 
GO
IF NOT EXISTS(SELECT *
	FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TBSIG_ENVELOPE'
AND COLUMN_NAME = 'LANG_CODE')
BEGIN
	ALTER TABLE [dbo].[TBSIG_ENVELOPE] ADD [LANG_CODE] VARCHAR(5) NOT NULL DEFAULT 'de-DE';
END


