UPDATE {databaseOwner}{objectQualifier}DMX_LogTypes
SET [NotifySelf]='CORE_MAILME'
WHERE
 [LogTypeKey]='MailMe'
GO

ALTER TABLE {databaseOwner}{objectQualifier}DMX_Entries
ALTER COLUMN
 [FileSize] BIGINT
GO

IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_AddEntry') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_AddEntry
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_AddEntry
	@Author NVarChar(500),
	@CollectionId Int,
	@Created DateTime,
	@Deleted Bit,
	@Entry NVarChar (255),
	@EntryType NVarChar (150),
	@FileSize BIGINT,
	@IsApproved Bit,
	@Keywords NVarChar (255),
	@LastModified DateTime,
	@LastVersionId Int,
	@LockedBy Int,
	@LockedUntil DateTime,
	@LockKey UNIQUEIDENTIFIER,
	@MD5Hash NVarChar(50),
	@OriginalFileName NVarChar (255),
	@Owner Int,
	@Path NVarChar (255),
	@PermissionsOnlyByAdmin Bit,
	@PortalId Int,
	@State NVarChar (50),
	@Version Int,
	@VersionsToKeep Int,
	@WorkflowId NVarChar (50)
AS

INSERT INTO {databaseOwner}{objectQualifier}DMX_Entries (
	[Author],
	[CollectionId],
	[Created],
	[Deleted],
	[Entry],
	[EntryType],
	[FileSize],
	[IsApproved],
	[Keywords],
	[LastModified],
	[LastVersionId],
	[LockedBy],
	[LockedUntil],
	[LockKey],
	[MD5Hash],
	[OriginalFileName],
	[Owner],
	[Path],
	[PermissionsOnlyByAdmin],
	[PortalId],
	[State],
	[Version],
	[VersionsToKeep],
	[WorkflowId]
) VALUES (
	@Author,
	@CollectionId,
	@Created,
	@Deleted,
	@Entry,
	@EntryType,
	@FileSize,
	@IsApproved,
	@Keywords,
	@LastModified,
	@LastVersionId,
	@LockedBy,
	@LockedUntil,
	@LockKey,
	@MD5Hash,
	@OriginalFileName,
	@Owner,
	@Path,
	@PermissionsOnlyByAdmin,
	@PortalId,
	@State,
	@Version,
	@VersionsToKeep,
	@WorkflowId
)

select SCOPE_IDENTITY()
GO


IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_UpdateEntry') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_UpdateEntry
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_UpdateEntry
	@EntryId Int,
	@Author NVarChar(500),
	@CollectionId Int,
	@Created DateTime,
	@Deleted Bit,
	@Entry NVarChar (255),
	@EntryType NVarChar (150),
	@FileSize BIGINT,
	@IsApproved Bit,
	@Keywords NVarChar (255),
	@LastModified DateTime,
	@LastVersionId Int,
	@LockedBy Int,
	@LockedUntil DateTime,
	@LockKey UNIQUEIDENTIFIER,
	@MD5Hash NVarChar(50),
	@OriginalFileName NVarChar (255),
	@Owner Int,
	@Path NVarChar (255),
	@PermissionsOnlyByAdmin Bit,
	@PortalId Int,
	@State NVarChar (50),
	@Version Int,
	@VersionsToKeep Int,
	@WorkflowId NVarChar (50)
AS

UPDATE {databaseOwner}{objectQualifier}DMX_Entries SET
	[Author] = @Author,
	[CollectionId] = @CollectionId,
	[Created] = @Created,
	[Deleted] = @Deleted,
	[Entry] = @Entry,
	[EntryType] = @EntryType,
	[FileSize] = @FileSize,
	[IsApproved] = @IsApproved,
	[Keywords] = @Keywords,
	[LastModified] = @LastModified,
	[LastVersionId] = @LastVersionId,
	[LockedBy] = @LockedBy,
	[LockedUntil] = @LockedUntil,
	[LockKey] = @LockKey,
	[MD5Hash] = @MD5Hash,
	[OriginalFileName] = @OriginalFileName,
	[Owner] = @Owner,
	[Path] = @Path,
	[PermissionsOnlyByAdmin] = @PermissionsOnlyByAdmin,
	[PortalId] = @PortalId,
	[State] = @State,
	[Version] = @Version,
	[VersionsToKeep] = @VersionsToKeep,
	[WorkflowId] = @WorkflowId
WHERE
	[EntryId] = @EntryId
GO

