USE [Elyse_DB]
GO
/****** Object:  Table [user_restr].[authorisers]    Script Date: Sat 05-09-2026 7:01:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [user_restr].[authorisers](
	[authoriser_sid_id] [bigint] NOT NULL,
	[created] [datetime2](7) NOT NULL,
	[created_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_authorisers] PRIMARY KEY CLUSTERED 
(
	[authoriser_sid_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].[authorisers] ADD  CONSTRAINT [DF_authorisers_created]  DEFAULT (sysdatetime()) FOR [created]
GO
ALTER TABLE [user_restr].[authorisers] ADD  CONSTRAINT [DF_authorisers_created_by]  DEFAULT (original_login()) FOR [created_by]
GO
ALTER TABLE [user_restr].[authorisers]  WITH CHECK ADD  CONSTRAINT [FK_sid_is_authoriser] FOREIGN KEY([authoriser_sid_id])
REFERENCES [user_restr].[sid_list] ([sid_id])
GO
ALTER TABLE [user_restr].[authorisers] CHECK CONSTRAINT [FK_sid_is_authoriser]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This field allows for a reference link to be created between an external application and the Elyse database.' , @level0type=N'SCHEMA',@level0name=N'user_restr', @level1type=N'TABLE',@level1name=N'authorisers', @level2type=N'COLUMN',@level2name=N'app_reference'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is the table of users granted permission as an authoriser.  It is separate from the user_role_link table because of the policy that only a database administrator can grant authoriser permission by directly editing this table.  An authoriser cannot grant authorising permission to other users and does not have access to this table. 

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'authorisers'
GO
