


CREATE TABLE [dbo].[RDM_ActivityLog](
	[ActivityID] [int] IDENTITY(1,1) NOT NULL,
	[FacilityID] [int] NULL,
	[DateTime] [datetime] NOT NULL,
	[TableName] [nvarchar](255) NOT NULL,
	[NewValue] [xml] NULL,
	[OldValue] [xml] NULL,
	[Action] [varchar](150) NULL,
	[UserID] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_ADSyncExecutionStatus](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ExecutionDate] [datetime] NULL,
	[Status] [bit] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Agreements](
	[AgreementID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) NULL,
	[AgreementContent] [varchar](max) NULL,
	[Item] [int] NULL,
	[IsDefault] [bit] NULL,
	[ModifiedDate] [datetime] NULL,
	[Type] [char](1) NULL,
	[FacilityID] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_AuditAll](
	[AuditId] [int] IDENTITY(1,1) NOT NULL,
	[DateTime] [datetime] NOT NULL,
	[TableName] [nvarchar](255) NOT NULL,
	[NewValue] [xml] NULL,
	[OldValue] [xml] NULL,
	[Action] [varchar](50) NULL,
	[UserID] [varchar](50) NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Building](
	[BuildingID] [int] IDENTITY(1,1) NOT NULL,
	[BuildingName] [varchar](40) NOT NULL,
	[Description] [varchar](50) NULL,
	[FacilityZoneID] [int] NULL,
	[Notes] [varchar](MAX) NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedDate] [datetime] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Cabinet](
	[CabinetID] [int] IDENTITY(1,1) NOT NULL,
	[CabinetName] [varchar](25) NOT NULL,
	[CabinetDesription] [varchar](50) NULL,
	[FacilityID] [int] NOT NULL,
	[Notes] [varchar](MAX) NULL,
	[ModifiedDate] [datetime] NULL,
	[IsDeleted] [bit] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Core](
	[CoreID] [int] IDENTITY(1,1) NOT NULL,
	[CoreUID] [int] NULL,
	[CoreSerialNo] [varchar](22) NULL,
	[CoreMarkID] [int] NULL,
	[ProductID] [int] NULL,
	[Notes] [varchar](MAX) NULL,
	[CoreSerialize] [int] NULL,
	[CoreDispositionID] [int] NULL,
	[CoreDispositionUID] [int] NULL,
	[CoreDispositionType] [varchar](50) NULL,
	[CoreOosDate] [datetime] NULL,
	[CoreFinalDispID] [int] NULL,
	[CoreFinalDispType] [varchar](50) NULL,
	[ModifiedDate] [datetime] NULL,
	[FacilityID] [int] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_CoreMark](
	[CoreMarkID] [int] IDENTITY(1,1) NOT NULL,
	[CoreMarkName] [varchar](20) NULL,
	[KeyMarkID] [int] NULL,
	[Notes] [varchar](MAX) NULL,
	[FacilityID] [int] NULL,
	[OP_By] [nvarchar](max) NULL,
	[ModifiedDate] [datetime] NULL,
	[Stacking] [varchar](max) NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_CoreMark_Sel](
	[SelectivityID] [int] IDENTITY(1,1) NOT NULL,
	[CoreMarkID] [int] NOT NULL,
	[KeyMarkID] [int] NOT NULL,
	[IsStandardSelectivity] [bit] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_CustomerFeedback](
	[VOC_ID] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [varchar](100) NULL,
	[ScreenName] [varchar](100) NULL,
	[FeedbackType] [int] NULL,
	[Description] [varchar](2000) NULL,
	[CreatedDate] [datetime] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_CustomerValidation](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[CustomerID] [varchar](500) NULL,
	[MacID] [varchar](500) NOT NULL,
	[HDD_ID] [varchar](500) NULL,
	[DemoStartDate] [varchar](500) NULL,
	[DemoEndDate] [varchar](500) NULL,
	[FullLicenceKey] [varchar](500) NULL,
	[FullIssueDate] [varchar](500) NULL,
	[Status] [varchar](100) NULL,
	[LastModifiedDate] [date] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_DashboardSettings](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[TileName] [varchar](100) NULL,
	[Position] [int] NULL,
	[Visibility] [bit] NULL,
	[UserID] [int] NOT NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Department](
	[DeptID] [int] IDENTITY(1,1) NOT NULL,
	[DeptName] [varchar](50) NOT NULL,
	[Description] [varchar](50) NULL,
	[Notes]  [varchar](MAX) NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedDate] [datetime] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Door](
	[DoorID] [int] IDENTITY(1,1) NOT NULL,
	[DoorUID] [int] NULL,
	[DoorTypeID] [int] NULL,
	[DoorNumber] [varchar](25) NULL,
	[Area] [varchar](25) NULL,
	[Description] [varchar](50) NULL,
	[BuildingID] [int] NULL,
	[IsDeleted] [bit] NULL,
	[DeletedDate] [datetime] NULL,
	[Notes] [varchar](MAX) NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedDate] [datetime] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_DoorType](
	[DoorTypeID] [int] IDENTITY(1,1) NOT NULL,
	[Type] [varchar](25) NOT NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_EmailNotifications](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryType] [int] NOT NULL,
	[Body] [nvarchar](max) NULL,
	[AdditionalReceipients] [varchar](512) NULL,
	[OtherNxGenUsers] [nvarchar](max) NULL,
	[AdditionalDistribution] [varchar](512) NULL,
	[Myself] [bit] NULL,
	[ItemRecipient] [bit] NULL,
	[ItemType] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_EmailSettings](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Type] [int] NULL,
	[WeekSelectedDay] [int] NULL,
	[ScheduleDate] [datetime] NULL,
	[Status] [bit] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Employee](
	[EmployeeId] [int] IDENTITY(1,1) NOT NULL,
	[EmployeeUID] [int] NULL,
	[ID] [varchar](256) NULL,
	[LastName] [varchar](256) NULL,
	[FirstName] [varchar](256) NULL,
	[MiddleInitial] [varchar](256) NULL,
	[Email] [varchar](256) NULL,
	[Phone] [varchar](256) NULL,
	[Misc] [varchar](50) NULL,
	[Description] [varchar](50) NULL,
	[EmpTypeID] [int] NULL,
	[EmpTitleID] [int] NULL,
	[DeptID] [int] NULL,
	[IsDeleted] [bit] NULL,
	[DeletedDate] [datetime] NULL,
	[Notes] [varchar](MAX) NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedDate] [datetime] NULL,
	[AD_GUID] [uniqueidentifier] NULL,
	[AD_IsActive] [bit] NULL,
	[AD_SyncDate] [datetime] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_EmpTitle](
	[EmpTitleID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [varchar](50) NOT NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_EmpType](
	[EmpTypeID] [int] IDENTITY(1,1) NOT NULL,
	[Type] [varchar](50) NOT NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Facility](
	[FacilityID] [int] IDENTITY(1,1) NOT NULL,
	[FacilityName] [varchar](50) NULL,
	[Path] [varchar](100) NULL,
	[Description] [varchar](50) NULL,
	[LastBackup] [datetime] NULL,
	[Notes] [varchar](MAX) NULL,
	[IsDeleted] [bit] NOT NULL,
	[ModifiedDate] [datetime] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Facility_Configuration](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[FacilityID] [int] NULL,
	[KeySerial] [int] NULL,
	[CoreSerial] [int] NULL,
	[LockSerial] [int] NULL,
	[PartAgreementDefault] [int] NULL,
	[KeyAgreementDefault] [int] NULL,
	[KeyringAgreementDefault] [int] NULL,
	[PartRRDefault] [int] NULL,
	[KeyRRDefault] [int] NULL,
	[KeyringRRDefault] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_FacilityZone](
	[FacilityZoneID] [int] IDENTITY(1,1) NOT NULL,
	[ZoneName] [varchar](25) NOT NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_GeneralPermission](
	[GeneralPermissionId] [int] IDENTITY(1,1) NOT NULL,
	[Building] [bit] NOT NULL,
	[Cabinet] [bit] NOT NULL,
	[Core] [bit] NOT NULL,
	[CoreMark] [bit] NOT NULL,
	[Department] [bit] NOT NULL,
	[Door] [bit] NOT NULL,
	[Employee] [bit] NOT NULL,
	[Facility] [bit] NOT NULL,
	[Hook] [bit] NOT NULL,
	[Key] [bit] NOT NULL,
	[Keymark] [bit] NOT NULL,
	[Keyring] [bit] NOT NULL,
	[Part] [bit] NOT NULL,
	[Masterkey] [bit] NOT NULL,
	[OutofService] [bit] NOT NULL,
	[Product] [bit] NOT NULL,
	[Reports] [bit] NOT NULL,
	[Site] [bit] NOT NULL,
	[Unassigned] [bit] NOT NULL,
	[User] [bit] NOT NULL,
	[SuperUser] [bit] NOT NULL,
	[ViewCodes] [bit] NOT NULL,
	[ViewMasterLevelCodes] [bit] NOT NULL,
	[Updates] [bit] NOT NULL,
	[Transactions] [bit] NOT NULL,
	[PinSegmentCaluculator] [bit] NOT NULL,
	[PrintAcitvityLog] [bit] NOT NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_GlobalConfiguration](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[HDCrashNotificationMail] [varchar](250) NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Hook](
	[HookID] [int] IDENTITY(1,1) NOT NULL,
	[HookUID] [int] NULL,
	[HookName] [varchar](14) NULL,
	[HookDescription] [varchar](50) NULL,
	[CabinetID] [int] NOT NULL,
	[Notes] [varchar](MAX) NULL,
	[IsDeleted] [bit] NULL,
	[DeletedDate] [datetime] NULL,
	[ModifiedDate] [datetime] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_ItemHistory](
	[HistoryID] [int] IDENTITY(1,1) NOT NULL,
	[ItemID] [int] NULL,
	[ToID] [int] NULL,
	[UserID] [int] NULL,
	[DatetimeWhen] [datetime] NULL,
	[DateReturn] [datetime] NULL,
	[DateDue] [datetime] NULL,
	[Comment] [varchar](50) NULL,
	[ItemParentID] [int] NULL,
	[ItemParentType] [varchar](50) NULL,
	[ToParentID] [int] NULL,
	[ToParentType] [varchar](50) NULL,
	[FacilityID] [int] NOT NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Key](
	[KeyID] [int] IDENTITY(1,1) NOT NULL,
	[KeyUID] [int] NULL,
	[KeySerialNo] [varchar](22) NOT NULL,
	[KeyDescription] [varchar](50) NULL,
	[KeyMarkID] [int] NULL,
	[ProductID] [int] NULL,
	[Notes]  [varchar](MAX) NULL,
	[KeySerialize] [int] NULL,
	[KeyDispositonID] [int] NULL,
	[KeyDispositionUID] [int] NULL,
	[KeyDispositionType] [varchar](50) NULL,
	[KeyOosDate] [datetime] NULL,
	[KeyFinalDispID] [int] NULL,
	[KeyFinalDispType] [varchar](50) NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedDate] [datetime] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_keycut](
	[ID] [int] NULL,
	[Keycut] [varchar](8) NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_KeyMark](
	[KeyMarkID] [int] IDENTITY(1,1) NOT NULL,
	[KeyMarkName] [varchar](20) NOT NULL,
	[KeyMarkStatusID] [int] NULL,
	[SystemID] [int] NULL,
	[KeyCut] [varchar](7) NULL,
	[KeyMarkLevelID] [smallint] NOT NULL,
	[ParentID] [int] NULL,
	[Notes] [varchar](MAX) NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedDate] [datetime] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_KeyMark_Sel](
	[SelectivityID] [int] IDENTITY(1,1) NOT NULL,
	[SelMasterKeyID] [int] NULL,
	[SelOperKeyID] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_KeyMarkLevel](
	[KeyMarkLevelID] [smallint] IDENTITY(1,1) NOT NULL,
	[KeyMarkLevel] [varchar](10) NOT NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_KeyMarkStatus](
	[KeymarkStatusID] [int] IDENTITY(1,1) NOT NULL,
	[Status] [varchar](25) NOT NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_KeyRings](
	[KeyRingID] [int] IDENTITY(1,1) NOT NULL,
	[KeyRingUID] [int] NULL,
	[KeyRing] [varchar](30) NULL,
	[Description] [varchar](50) NULL,
	[DispositionID] [int] NULL,
	[DispositionUID] [int] NULL,
	[DispositionType] [varchar](50) NULL,
	[Notes] [varchar](MAX) NULL,
	[KeyringOosDate] [datetime] NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedDate] [datetime] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Keyway](
	[KeywayID] [int] IDENTITY(1,1) NOT NULL,
	[KeywayName] [varchar](25) NOT NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_MailExecutionStatus](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ExecutionDate] [datetime] NULL,
	[Status] [bit] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_MailSettings](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ItemType] [int] NOT NULL,
	[CategoryType] [int] NOT NULL,
	[OtherNxGenUsers] [nvarchar](max) NULL,
	[AdditionalRecipients] [bit] NULL,
	[Myself] [bit] NULL,
	[SecurityPersonnel] [varchar](512) NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Mark](
	[MarkID] [smallint] IDENTITY(1,1) NOT NULL,
	[Mark] [varchar](5) NOT NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_MasterKeySystem](
	[SystemID] [int] IDENTITY(1,1) NOT NULL,
	[SystemName] [varchar](25) NOT NULL,
	[KeywayID] [int] NULL,
	[SystemTypeID] [smallint] NULL,
	[PinsizeID] [smallint] NULL,
	[MarkID] [int] NULL,
	[Keystamp] [varchar](9) NULL,
	[Notes] [varchar](MAX) NULL,
	[GM_KeyMarkID] [int] NULL,
	[CT_KeyMarkID] [int] NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedDate] [datetime] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Part](
	[PartID] [int] IDENTITY(1,1) NOT NULL,
	[PartUID] [int] NULL,
	[SerialNo] [varchar](35) NOT NULL,
	[PartDescription] [varchar](50) NULL,
	[ProductID] [int] NULL,
	[Notes] [varchar](MAX) NULL,
	[CreatedDate] [datetime] NULL,
	[Serialize] [int] NULL,
	[DispositionID] [int] NULL,
	[DispositionUID] [int] NULL,
	[DispositionType] [varchar](50) NULL,
	[OosDate] [datetime] NULL,
	[FacilityID] [int] NOT NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_PinSize](
	[PinSizeID] [smallint] IDENTITY(1,1) NOT NULL,
	[PinSize] [char](1) NOT NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Product](
	[ProductID] [int] IDENTITY(1,1) NOT NULL,
	[ProductName] [varchar](25) NOT NULL,
	[ProductDescription] [varchar](50) NULL,
	[MfgID] [int] NULL,
	[ProductTypeID] [int] NOT NULL,
	[NumCores] [int] NULL,
	[Notes] [varchar](MAX) NULL,
	[ModifiedDate] [datetime] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_ProductMfg](
	[MfgID] [int] IDENTITY(1,1) NOT NULL,
	[MfgName] [varchar](50) NOT NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_ProductType](
	[ProductTypeID] [int] IDENTITY(1,1) NOT NULL,
	[ProductType] [varchar](25) NOT NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Reports](
	[ID] [int] NULL,
	[ReportName] [varchar](60) NOT NULL,
	[BaseReport] [varchar](60) NULL,
	[Orientation] [varchar](20) NULL,
	[Description] [varchar](60) NULL,
	[AvailableFields] [varchar](2000) NULL,
	[DefaultFields] [varchar](2000) NULL,
	[FilterCriteria] [varchar](max) NULL,
	[FacilityID] [int] NULL,
	[UserID] [int] NULL,
	[IsPrivate] [bit] NULL,
	[IsCustomReport] [bit] NULL,
	[ModifiedDate] [datetime] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Role](
	[RoleID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](20) NOT NULL,
	[PwdExpiryInDays] [int] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Scheduler](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Type] [int] NULL,
	[Days] [varchar](100) NULL,
	[Time] [varchar](100) NULL,
	[Status] [bit] NULL,
	[ServiceType] [varchar](150) NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_Site](
	[SiteID] [int] IDENTITY(1,1) NOT NULL,
	[SerialNumber] [varchar](20) NULL,
	[Customer] [varchar](50) NULL,
	[Server] [varchar](20) NULL,
	[InstallationDate] [datetime] NULL,
	[Notes] [varchar](MAX) NULL,
	[Description] [varchar](50) NULL,
	[Address1] [varchar](50) NULL,
	[Address2] [varchar](50) NULL,
	[City] [varchar](20) NULL,
	[State] [varchar](2) NULL,
	[Zip] [varchar](10) NULL,
	[Country] [varchar](30) NULL,
	[ContactName1] [varchar](50) NULL,
	[ContactPhone1] [varchar](15) NULL,
	[ContactFax1] [varchar](15) NULL,
	[ContactName2] [varchar](50) NULL,
	[ContactPhone2] [varchar](15) NULL,
	[ContactFax2] [varchar](15) NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_SystemType](
	[SystemTypeID] [smallint] IDENTITY(1,1) NOT NULL,
	[SystemType] [varchar](25) NOT NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_TransactionPermission](
	[TransactionPermissionId] [int] IDENTITY(1,1) NOT NULL,
	[Building] [bit] NOT NULL,
	[Cabinet] [bit] NOT NULL,
	[Core] [bit] NOT NULL,
	[CoreMark] [bit] NOT NULL,
	[Department] [bit] NOT NULL,
	[Door] [bit] NOT NULL,
	[Employee] [bit] NOT NULL,
	[Facility] [bit] NOT NULL,
	[Hook] [bit] NOT NULL,
	[Key] [bit] NOT NULL,
	[Keymark] [bit] NOT NULL,
	[Keyring] [bit] NOT NULL,
	[Part] [bit] NOT NULL,
	[Masterkey] [bit] NOT NULL,
	[OutofService] [bit] NOT NULL,
	[Product] [bit] NOT NULL,
	[Reports] [bit] NOT NULL,
	[Site] [bit] NOT NULL,
	[Unassigned] [bit] NOT NULL,
	[User] [bit] NOT NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_TransactionTypes](
	[TransactionTypeID] [int] IDENTITY(1,1) NOT NULL,
	[TransactionType] [varchar](100) NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_UpdatePermission](
	[UpdatePermissionId] [int] IDENTITY(1,1) NOT NULL,
	[Building] [bit] NOT NULL,
	[Cabinet] [bit] NOT NULL,
	[Core] [bit] NOT NULL,
	[CoreMark] [bit] NOT NULL,
	[Department] [bit] NOT NULL,
	[Door] [bit] NOT NULL,
	[Employee] [bit] NOT NULL,
	[Facility] [bit] NOT NULL,
	[Hook] [bit] NOT NULL,
	[Key] [bit] NOT NULL,
	[Keymark] [bit] NOT NULL,
	[Keyring] [bit] NOT NULL,
	[Part] [bit] NOT NULL,
	[Masterkey] [bit] NOT NULL,
	[OutofService] [bit] NOT NULL,
	[Product] [bit] NOT NULL,
	[Reports] [bit] NOT NULL,
	[Site] [bit] NOT NULL,
	[Unassigned] [bit] NOT NULL,
	[User] [bit] NOT NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_User](
	[UserID] [int] IDENTITY(1,1) NOT NULL,
	[UserLogin] [varchar](50) NULL,
	[Email] [varchar](100) NULL,
	[HashedPassword] [varchar](250) NULL,
	[Description] [nvarchar](max) NULL,
	[Notes] [varchar](MAX) NULL,
	[Salt] [varchar](150) NULL,
	[IsLocked] [bit] NULL,
	[RoleID] [int] NOT NULL,
	[GeneralPermissionId] [int] NULL,
	[UpdatePermissionId] [int] NULL,
	[TransactionPermissionId] [int] NULL,
	[ModifiedDate] [datetime] NULL,
	[CreatedBY] [varchar](50) NULL,
	[EmployeeID] [int] NULL,
	[PwdChangedDate] [date] NULL,
	[ModifiedBy] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1,
	[EncryptedPassword] [varchar](250) NULL
);

CREATE TABLE [dbo].[RDM_UserFacilities](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[UserID] [int] NULL,
	[FacilityID] [int] NULL,
	[IsDefault] [bit] NULL,
	[BuildingDefault] [int] NULL,
	[CabinetDefault] [int] NULL,
	[CoreDefault] [int] NULL,
	[CoremarkDefault] [int] NULL,
	[DepartmentDefault] [int] NULL,
	[OutOfServiceDefault] [int] NULL,
	[DoorDefault] [int] NULL,
	[EmployeeDefault] [int] NULL,
	[FacilityDefault] [int] NULL,
	[HookDefault] [int] NULL,
	[KeyDefault] [int] NULL,
	[KeymarkDefault] [int] NULL,
	[KeyringDefault] [int] NULL,
	[PartDefault] [int] NULL,
	[MasterkeyDefault] [int] NULL,
	[ProductDefault] [int] NULL,
	[ReportDefault] [int] NULL,
	[SiteDefault] [int] NULL,
	[UnassignedDefault] [int] NULL,
	[UserDefault] [int] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);

CREATE TABLE [dbo].[RDM_UserPermissions](
	[PERMISSIONID] [int] IDENTITY(1,1) NOT NULL,
	[USERID] [int] NULL,
	[CLONED_FROM] [varchar](50) NULL,
	[PERMIT_VIEW_DASHBOARD] [bit] NULL,
	[PERMIT_VIEW_MASTERKEY] [bit] NULL,
	[PERMIT_VIEW_DEPARTMENT] [bit] NULL,
	[PERMIT_VIEW_EMPLOYEE] [bit] NULL,
	[PERMIT_VIEW_KEY] [bit] NULL,
	[PERMIT_VIEW_BUILDING] [bit] NULL,
	[PERMIT_VIEW_DOOR] [bit] NULL,
	[PERMIT_VIEW_CORE] [bit] NULL,
	[PERMIT_VIEW_CABINET] [bit] NULL,
	[PERMIT_VIEW_HOOK] [bit] NULL,
	[PERMIT_VIEW_KEYRING] [bit] NULL,
	[PERMIT_VIEW_PRODUCT] [bit] NULL,
	[PERMIT_VIEW_PART] [bit] NULL,
	[PERMIT_VIEW_OOS] [bit] NULL,
	[PERMIT_VIEW_UNASSIGNED] [bit] NULL,
	[PERMIT_VIEW_REPORTS] [bit] NULL,
	[PERMIT_VIEW_KEYSTONECONNECT] [bit] NULL,
	[PERMIT_VIEW_FACILITY] [bit] NULL,
	[PERMIT_UPDATE_DASHBOARD] [bit] NULL,
	[PERMIT_UPDATE_MASTERKEY] [bit] NULL,
	[PERMIT_UPDATE_DEPARTMENT] [bit] NULL,
	[PERMIT_UPDATE_EMPLOYEE] [bit] NULL,
	[PERMIT_UPDATE_KEY] [bit] NULL,
	[PERMIT_UPDATE_BUILDING] [bit] NULL,
	[PERMIT_UPDATE_DOOR] [bit] NULL,
	[PERMIT_UPDATE_CORE] [bit] NULL,
	[PERMIT_UPDATE_CABINET] [bit] NULL,
	[PERMIT_UPDATE_HOOK] [bit] NULL,
	[PERMIT_UPDATE_KEYRING] [bit] NULL,
	[PERMIT_UPDATE_PRODUCT] [bit] NULL,
	[PERMIT_UPDATE_PART] [bit] NULL,
	[PERMIT_UPDATE_OOS] [bit] NULL,
	[PERMIT_UPDATE_UNASSIGNED] [bit] NULL,
	[PERMIT_UPDATE_REPORTS] [bit] NULL,
	[PERMIT_DELETE_MASTERKEY] [bit] NULL,
	[PERMIT_DELETE_DEPARTMENT] [bit] NULL,
	[PERMIT_DELETE_EMPLOYEE] [bit] NULL,
	[PERMIT_DELETE_KEY] [bit] NULL,
	[PERMIT_DELETE_BUILDING] [bit] NULL,
	[PERMIT_DELETE_DOOR] [bit] NULL,
	[PERMIT_DELETE_CORE] [bit] NULL,
	[PERMIT_DELETE_CABINET] [bit] NULL,
	[PERMIT_DELETE_HOOK] [bit] NULL,
	[PERMIT_DELETE_KEYRING] [bit] NULL,
	[PERMIT_DELETE_PRODUCT] [bit] NULL,
	[PERMIT_DELETE_PART] [bit] NULL,
	[PERMIT_DELETE_OOS] [bit] NULL,
	[PERMIT_DELETE_UNASSIGNED] [bit] NULL,
	[PERMIT_DELETE_REPORTS] [bit] NULL,
	[PERMIT_TRANS_EMP_ISSUENEWKEY] [bit] NULL,
	[PERMIT_TRANS_EMP_RETURNKEY] [bit] NULL,
	[PERMIT_TRANS_EMP_ISSUEEXISTINGKEY] [bit] NULL,
	[PERMIT_TRANS_EMP_TRANSFERKEY] [bit] NULL,
	[PERMIT_TRANS_HOOK_TRANSFERKEY] [bit] NULL,
	[PERMIT_TRANS_OOS_TRANSFERKEY] [bit] NULL,
	[PERMIT_TRANS_UNA_TRANSFERKEY] [bit] NULL,
	[PERMIT_TRANS_KEYRING_ATTACHNEWKEY] [bit] NULL,
	[PERMIT_TRANS_KEYRING_DETACHKEY] [bit] NULL,
	[PERMIT_TRANS_KEYRING_ATTACHEXISTINGKEY] [bit] NULL,
	[PERMIT_TRANS_DOOR_INSTALLNEWCORE] [bit] NULL,
	[PERMIT_TRANS_DOOR_REMOVECORE] [bit] NULL,
	[PERMIT_TRANS_DOOR_INSTALLEXISTINGCORE] [bit] NULL,
	[PERMIT_TRANS_PART_INSTALLNEWCORE] [bit] NULL,
	[PERMIT_TRANS_PART_REMOVECORE] [bit] NULL,
	[PERMIT_TRANS_PART_INSTALLEXISTINGCORE] [bit] NULL,
	[PERMIT_TRANS_EMP_TRANSFERCORE] [bit] NULL,
	[PERMIT_TRANS_DOOR_TRANSFERCORE] [bit] NULL,
	[PERMIT_TRANS_HOOK_TRANSFERCORE] [bit] NULL,
	[PERMIT_TRANS_OOS_TRANSFERCORE] [bit] NULL,
	[PERMIT_TRANS_UNA_TRANSFERCORE] [bit] NULL,
	[PERMIT_TRANS_EMP_ISSUENEWCORE] [bit] NULL,
	[PERMIT_TRANS_EMP_RETURNCORE] [bit] NULL,
	[PERMIT_TRANS_EMP_ISSUEEXISTINGCORE] [bit] NULL,
	[PERMIT_TRANS_EMP_ISSUENEWKEYRING] [bit] NULL,
	[PERMIT_TRANS_EMP_RETURNKEYRING] [bit] NULL,
	[PERMIT_TRANS_EMP_ISSUEEXISTINGKEYRING] [bit] NULL,
	[PERMIT_TRANS_EMP_TRANSFERKEYRING] [bit] NULL,
	[PERMIT_TRANS_HOOK_TRANSFERKEYRING] [bit] NULL,
	[PERMIT_TRANS_OOS_TRANSFERKEYRING] [bit] NULL,
	[PERMIT_TRANS_UNA_TRANSFERKEYRING] [bit] NULL,
	[PERMIT_TRANS_DOOR_INSTALLNEWPART] [bit] NULL,
	[PERMIT_TRANS_DOOR_REMOVEPART] [bit] NULL,
	[PERMIT_TRANS_DOOR_INSTALLEXISTINGPART] [bit] NULL,
	[PERMIT_TRANS_EMP_TRANSFERPART] [bit] NULL,
	[PERMIT_TRANS_HOOK_TRANSFERPART] [bit] NULL,
	[PERMIT_TRANS_OOS_TRANSFERPART] [bit] NULL,
	[PERMIT_TRANS_UNA_TRANSFERPART] [bit] NULL,
	[PERMIT_TRANS_EMP_ISSUENEWPART] [bit] NULL,
	[PERMIT_TRANS_EMP_RETURNPART] [bit] NULL,
	[PERMIT_TRANS_EMP_ISSUEEXISTINGPART] [bit] NULL,
	[PERMIT_TRANS_HOOK_ISSUENEWKEY] [bit] NULL,
	[PERMIT_TRANS_HOOK_ISSUENEWKEYRING] [bit] NULL,
	[PERMIT_TRANS_HOOK_ISSUENEWCORE] [bit] NULL,
	[PERMIT_TRANS_HOOK_ISSUENEWPART] [bit] NULL,
	[PERMIT_VIEW_CODES] [bit] NULL,
	[RDM_FacilityID] [int] NULL,
	[RDM_ID] [int] NULL,
	IsMigrationRequired BIT DEFAULT 1
);
