USE [Elyse_DB]
GO
/****** Object:  Table [user_restr].[doc_group_edit_perm_funct_lst]    Script Date: Sat 05-09-2026 7:01:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [user_restr].[doc_group_edit_perm_funct_lst](
	[doc_group_id] [bigint] NOT NULL,
	[function_list_id] [bigint] NOT NULL,
	[created] [datetime2](7) NOT NULL,
	[granted_by] [nvarchar](128) NOT NULL,
	[valid_from] [datetime2](7) NULL,
	[valid_until] [datetime2](7) NULL,
	[notes] [nvarchar](1000) NULL,
	[app_reference] [nvarchar](1000) NULL,
 CONSTRAINT [PK_doc_group_edit_perm_function_lst] PRIMARY KEY CLUSTERED 
(
	[doc_group_id] ASC,
	[function_list_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [user_restr].[doc_group_edit_perm_funct_lst] ADD  CONSTRAINT [DF_doc_group_edit_perm_funct_lst_created]  DEFAULT (sysdatetime()) FOR [created]
GO
ALTER TABLE [user_restr].[doc_group_edit_perm_funct_lst] ADD  CONSTRAINT [DF_doc_group_edit_perm_funct_lst_granted_by]  DEFAULT (original_login()) FOR [granted_by]
GO
ALTER TABLE [user_restr].[doc_group_edit_perm_funct_lst]  WITH CHECK ADD  CONSTRAINT [FK_doc_group_is_linked_to_edit_permission_duty_function_list] FOREIGN KEY([doc_group_id])
REFERENCES [xref].[doc_group_names] ([doc_group_id])
GO
ALTER TABLE [user_restr].[doc_group_edit_perm_funct_lst] CHECK CONSTRAINT [FK_doc_group_is_linked_to_edit_permission_duty_function_list]
GO
ALTER TABLE [user_restr].[doc_group_edit_perm_funct_lst]  WITH CHECK ADD  CONSTRAINT [FK_duty_function_list_is_linked_to_document_group_edit_permission] FOREIGN KEY([function_list_id])
REFERENCES [people].[function_list_names] ([function_list_id])
GO
ALTER TABLE [user_restr].[doc_group_edit_perm_funct_lst] CHECK CONSTRAINT [FK_duty_function_list_is_linked_to_document_group_edit_permission]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This table links document groups with function lists to grant metadata edit permissions for a group of documents to a group of user duty functions.

COPYRIGHT NOTICE
This database schema and stored procedures are protected by copyright.
Copyright.  Silkwood Software Pty. Ltd. 2023' , @level0type=N'SCHEMA',@level0name=N'user_restr', @level1type=N'TABLE',@level1name=N'doc_group_edit_perm_funct_lst'
GO
