UPDATE TBDD_BASECONFIG SET DB_VERSION = '1.9.8.0';
GO
UPDATE TBDD_INDEX_AUTOM SET VKT_PREVENT_MULTIPLE_VALUES = 0 WHERE VKT_PREVENT_MULTIPLE_VALUES IS NULL;
UPDATE TBDD_INDEX_AUTOM SET VKT_OVERWRITE = 0 WHERE VKT_OVERWRITE IS NULL;
GO
ALTER VIEW [dbo].[VWDDINDEX_AUTOM]
AS
SELECT TOP 100 PERCENT
     T.GUID,
     T.INDEXNAME,
     T.COMMENT,
     T.DOCTYPE_ID,
     T1.BEZEICHNUNG	    DOKUMENTART,
     T1.KURZNAME,
     T.CONNECTION_ID,
     T2.BEZEICHNUNG		CONNECTION,
     T2.SQL_PROVIDER,
     T2.SERVER,
     T2.DATENBANK,
     T2.USERNAME,
     T2.PASSWORD,
     T.SQL_RESULT,
	 T.SQL_ACTIVE,
	 T.VALUE,
     T.[SEQUENCE],
	 T.VKT_OVERWRITE,
	 T.VKT_PREVENT_MULTIPLE_VALUES
FROM
	TBDD_INDEX_AUTOM			T
	INNER JOIN TBDD_DOKUMENTART	T1 ON T.DOCTYPE_ID = T1.GUID AND T1.AKTIV = 1
	LEFT  JOIN TBDD_CONNECTION	T2 ON T.CONNECTION_ID = T2.GUID	AND T2.AKTIV = 1
WHERE 
	T.ACTIVE = 1
ORDER BY
	 T.DOCTYPE_ID,
	 T.GUID
GO
IF NOT EXISTS(SELECT 1 FROM sys.columns 
          WHERE Name = N'LANGUAGE_OVERRIDE'
          AND Object_ID = Object_ID(N'TBDD_USER_MODULE_LOG_IN'))
BEGIN
    ALTER TABLE TBDD_USER_MODULE_LOG_IN
	ADD LANGUAGE_OVERRIDE VARCHAR(5)
END
IF NOT EXISTS(SELECT * FROM information_schema.table_constraints WHERE constraint_type = 'PRIMARY KEY' AND table_name = 'TBDD_3RD_PARTY_MODULES')
	ALTER TABLE [dbo].[TBDD_3RD_PARTY_MODULES] ADD  CONSTRAINT [PK_TBDD_3RD_PARTY_MODULES] PRIMARY KEY CLUSTERED 
	(
		[GUID] ASC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY];
GO
IF NOT EXISTS(SELECT 1 FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE' AND VERSION = '11.2024')
	  INSERT INTO TBDD_3RD_PARTY_MODULES (NAME,LICENSE,[VERSION],ACTIVE) VALUES (
		'GDPICTURE',
		'kG1Qf9PwmqgR8aDmIW2zI_ebj48RzqAJegRxcystEmkbTGQqfkNBdFOXIb6C_A00Ra8zZkrHdfjqzOPXK7kgkF2YDhvrqKfqh4WDug2vOt0qO31IommzkANSuLjZ4zmraoubyEVd25rE3veQ2h_j7tGIoH_LyIHmy24GaXsxdG0yCzIBMdiLbMMMDwcPY-809KeZ83Grv76OVhFvcbBWyYc251vou1N-kGg5_ZlHDgfWoY85gTLRxafjD3KS_i9ARW4BMiy36y8n7UP2jN8kGRnW_04ubpFtfjJqvtsrP_J9D0x7bqV8xtVtT5JI6dpKsVTiMgDCrIcoFSo5gCC1fw9oUopX4TDCkBQttO4-WHBlOeq9dG5Yb0otonVmJKaQA2tP6sMR-lZDs3ql_WI9t91yPWgpssrJUxSHDd27_LMTH_owJIqkF3NOJd9mYQuAv22oNKFYbH8e41pVKb8cT33Y9CgcQ_sy6YDA5PTuIRi67mjKge_nD9rd0IN213Ir9M_EFWqg9e4haWzIdHXQUo0md70kVhPX4UIH_BKJnxEEnFfoFRNMh77bB0N4jkcBEHPl-ghOERv8dOztf4vCnNpzzWvcLD2cqWIm6THy8XGGq9h4hp8aEreRleSMwv9QQAC7mjLwhQ1rBYkpUHlpTjhTLnMwHknl6HH0Z6zzmsgkRKVyfquv94Pd7QbQfZrRka0ss_48pf9p8hAywEn81Q==',
		'11.2024',
		1)
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE  object_id = OBJECT_ID(N'[dbo].[FNDD_LOGIN_USER_MODULE]') AND type = N'TF')
	BEGIN
		PRINT 'Function FNDD_LOGIN_USER_MODULE noch nicht vorhanden!'
		DECLARE @SQL_FUNC NVARCHAR(MAX)
		SELECT @SQL_FUNC = OBJECT_DEFINITION(OBJECT_ID('FNDD_CHECK_USER_MODULE'));
		SET @SQL_FUNC =  REPLACE(@SQL_FUNC,'FNDD_CHECK_USER_MODULE','FNDD_LOGIN_USER_MODULE')
		EXEC (@SQL_FUNC);
	END
GO 
