IF((SELECT COUNT(*) FROM dbo.pal_Surface WHERE name = 'FileExplorerDownloads') = 1)
BEGIN

UPDATE pal_Surface SET isPublished = 1 WHERE name = 'FileExplorerDownloads';

IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE
	TABLE_NAME = 'publ_FileExplorerDownloads') AND EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE
	TABLE_NAME = 'qt_FileExplorerDownloads')
BEGIN
CREATE TABLE [dbo].[publ_FileExplorerDownloads](
	[itemID] [int] NOT NULL,
	[isActive] [bit] NULL,
	[surfaceId] [int] NOT NULL,
	[FileExplorerDownloadTracking_Tracking_fileExplorerMetaDataId] [varchar](max) NULL,
	[FileExplorerDownloadTracking_Tracking_date] [datetime] NULL,
	[FileExplorerDownloadTracking_Tracking_parentFolder] [varchar](max) NULL,
	[FileExplorerDownloadTracking_Tracking_subFolderPath] [varchar](max) NULL,
	[FileExplorerDownloadTracking_Tracking_fileName] [varchar](max) NULL,
	[FileExplorerDownloadTracking_Tracking_userName] [varchar](max) NULL,
	[FileExplorerDownloadTracking_Tracking_email] [varchar](max) NULL,
	[FileExplorerDownloadTracking_Tracking_schoolName] [varchar](max) NULL,
	[recId] [int] IDENTITY(1,1) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[recId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END

IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE
	TABLE_NAME = 'pal_FileExplorerDownloadTracking')
BEGIN
DROP TABLE pal_FileExplorerDownloadTracking;
END

END