USE [Elyse_DB]
GO
/****** Object:  Table [user_restr].[user_privilege_log]    Script Date: Sat 05-09-2026 7:01:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [user_restr].[user_privilege_log](
	[primary_key] [bigint] IDENTITY(1,1) NOT NULL,
	[privilege_type] [nvarchar](50) NOT NULL,
	[privilege_name] [nvarchar](50) NULL,
	[linked_to] [nvarchar](50) NULL,
	[sid_id] [bigint] NULL,
	[username] [nvarchar](128) NULL,
	[action_type] [nvarchar](20) NOT NULL,
	[created] [datetime2](7) NOT NULL,
	[created_by] [nvarchar](128) NOT NULL,
	[created_by_sid_id] [bigint] NOT NULL,
	[valid_from] [datetime2](7) NULL,
	[valid_until] [datetime2](7) NULL,
	[notes] [nvarchar](1000) NULL,
	[app_reference] [nvarchar](1000) NULL,
 CONSTRAINT [PK_user_privilege_log] PRIMARY KEY CLUSTERED 
(
	[primary_key] 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].[user_privilege_log] ADD  CONSTRAINT [DF_user_privilege_log_created]  DEFAULT (sysdatetime()) FOR [created]
GO
ALTER TABLE [user_restr].[user_privilege_log] ADD  CONSTRAINT [DF_user_privilege_log_created_by]  DEFAULT (original_login()) FOR [created_by]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This table stores records of user privilege changes.  Also see user_restr.authoriser_privilege_requests.

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