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

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

END;

IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'publ_RetailerDataItems')
BEGIN
/****** Object:  Table [dbo].[publ_RetailerDataItems]    Script Date: 2020/05/19 11:13:17 ******/

CREATE TABLE [dbo].[publ_RetailerDataItems](
	[itemID] [int] NOT NULL,
	[isActive] [bit] NULL,
	[surfaceId] [int] NOT NULL,
	[ParentSurfaceItemId] [int] NULL,
	[RetailerDataItems_RetailerDataItems_Barcode] [varchar](max) NULL,
	[RetailerDataItems_RetailerDataItems_RetailerName] [varchar](max) NULL,
	[RetailerDataItems_RetailerDataItems_RetailerCode] [varchar](max) NULL,
	[RetailerDataItems_RetailerDataItems_CostPrice] [decimal](18, 2) NULL,
	[RetailerDataItems_RetailerDataItems_LastUpdated] [varchar](max) NULL,
	[RetailerDataItems_RetailerDataItems_UpdatedBy] [varchar](max) NULL,
	[RetailerDataItems_RetailerDataItems_ImportFileName] [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((SELECT COUNT(*) FROM dbo.pal_Surface WHERE name = 'RetailerData') = 1)
BEGIN

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

END;

IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'publ_RetailerData')
BEGIN
/****** Object:  Table [dbo].[publ_RetailerData]    Script Date: 2020/05/19 11:14:11 ******/

CREATE TABLE [dbo].[publ_RetailerData](
	[itemID] [int] NOT NULL,
	[isActive] [bit] NULL,
	[surfaceId] [int] NOT NULL,
	[ParentSurfaceItemId] [int] NULL,
	[RetailerData_RetailerData_RetailerCode] [varchar](max) NULL,
	[RetailerData_RetailerData_RetailerName] [varchar](max) NULL,
	[RetailerData_RetailerData_FileName] [varchar](max) NULL,
	[RetailerData_RetailerData_ImportedBy] [varchar](max) NULL,
	[RetailerData_RetailerData_DateImported] [datetime] NULL,
	[RetailerData_RetailerData_Status] [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;