UPDATE TBDD_MODULES SET DB_VERSION = '1.9.8.6' where NAME = 'Global-Indexer' 
GO
CREATE TABLE TBGI_REGEX_DOCTYPE(
	GUID				INTEGER			NOT NULL	IDENTITY(1,1),
	REGEX				VARCHAR(500)	NOT NULL,
	DOCTYPE_ID			INTEGER,
	ADDED_WHO			VARCHAR(50)		NOT NULL	DEFAULT 'DEFAULT',
	ADDED_WHEN			DATETIME 					DEFAULT GETDATE(),
	CHANGED_WHO			VARCHAR(50),
	CHANGED_WHEN		DATETIME,
	CONSTRAINT			PK_TBGI_REGEX_DOCTYPE PRIMARY KEY (GUID),
	CONSTRAINT			FK_TBGI_REGEX_DOCTYPE_DTID FOREIGN KEY (DOCTYPE_ID)  REFERENCES  TBDD_DOKUMENTART (GUID)
)
GO
CREATE TRIGGER TBGI_REGEX_DOCTYPE_AFT_UPD ON TBGI_REGEX_DOCTYPE
FOR UPDATE
AS
  UPDATE TBGI_REGEX_DOCTYPE SET CHANGED_WHEN = GETDATE()
  FROM INSERTED
  WHERE TBGI_REGEX_DOCTYPE.GUID = INSERTED.GUID
GO
ALTER TABLE TBGI_HISTORY ADD ADDED_WHERE VARCHAR(100)
GO 