UPDATE TBDD_MODULES SET PRODUCT_VERSION = '2.4.5.6' where NAME = 'Record-Organizer' 
GO

CREATE TABLE TBPMO_DOC_USER_VIEW
(
	GUID			INTEGER			NOT NULL	IDENTITY(1,1),
	[USER_ID]		INTEGER			NOT NULL,
	[FILE_EXTENSION]	VARCHAR(10)	NOT NULL,
	[VIEWER]		VARCHAR(100)	NOT NULL DEFAULT 'DOC_VIEW',
	ADDED_WHO		VARCHAR(50)		DEFAULT 'DEFAULT',
	ADDED_WHEN		DATETIME 		DEFAULT GETDATE(),
	CHANGED_WHO     VARCHAR(50),
	CHANGED_WHEN	DATETIME,
	CONSTRAINT		PK_TBPMO_DOC_USER_VIEW		PRIMARY KEY ([GUID]),
	CONSTRAINT			FK_PK_TBPMO_DOC_USER_VIEW_USER_ID	FOREIGN KEY(USER_ID)	REFERENCES TBDD_USER(GUID)
)
GO

CREATE TRIGGER TBPMO_DOC_USER_VIEW_UPD ON TBPMO_DOC_USER_VIEW
FOR UPDATE
AS
	UPDATE TBPMO_DOC_USER_VIEW SET CHANGED_WHEN = GETDATE() FROM INSERTED WHERE TBPMO_DOC_USER_VIEW.GUID = INSERTED.GUID
GO

ALTER TABLE TBPMO_WD_FORMVIEW_DOKTYPES
ADD MANUAL_SUBFOLDER BIT NOT NULL DEFAULT 0
GO
ALTER TABLE [dbo].[TBPMO_INDEX_MAN] DROP CONSTRAINT [FK_TBPMO_INDEX_MAN_DOCTYPE_ID]
GO
ALTER TABLE [dbo].[TBPMO_INDEX_MAN]  WITH CHECK ADD  CONSTRAINT [FK_TBPMO_INDEX_MAN_DOCTYPE_ID] FOREIGN KEY([DOCTYPE_ID])
REFERENCES [dbo].[TBDD_DOKUMENTART] ([GUID])
GO
ALTER TABLE [dbo].[TBPMO_INDEX_MAN] CHECK CONSTRAINT [FK_TBPMO_INDEX_MAN_DOCTYPE_ID]
GO

ALTER TABLE [dbo].[TBPMO_DOC_INDICES] DROP CONSTRAINT [PK_TBPMO_DOC_INDICES]
GO
ALTER TABLE [dbo].[TBPMO_DOC_INDICES] 
ADD GUID INTEGER NOT NULL IDENTITY(1,1)
GO
ALTER TABLE [dbo].[TBPMO_DOC_INDICES] ADD  CONSTRAINT [PK_TBPMO_DOC_INDICES] 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



