IF NOT EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[pal_Report]')
 AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
	CREATE TABLE [dbo].[pal_Report](
		[recId] [int] IDENTITY(1,1) NOT NULL,
		[name] [varchar](150) NOT NULL,
		[display] [varchar](150) NOT NULL,
		[isActive] [bit] NULL,
	 CONSTRAINT [PK_pal_Report] 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]
END






IF NOT EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[pal_ReportField]')
 AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
	CREATE TABLE [dbo].[pal_ReportField](
		[recId] [int] IDENTITY(1,1) NOT NULL,
		[reportId] [int] NOT NULL,
		[reportFieldName] [varchar](150) NOT NULL,
		[reportFieldDisplay] [varchar](150) NOT NULL,
		[reportFieldTypeId] [int] NOT NULL,
		[surfaceId] [int] NULL,
		[surfaceFieldId] [int] NULL,
		[sequence] [int] NULL,
		[isFilter] [bit] NULL,
		[isActive] [bit] NULL,
	 CONSTRAINT [PK_pal_ReportField] 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]
END







IF NOT EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[pal_ReportFieldType]')
 AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
	CREATE TABLE [dbo].[pal_ReportFieldType](
		[recId] [int] IDENTITY(1,1) NOT NULL,
		[reportFieldType] [varchar](150) NOT NULL,
		[isActive] [bit] NULL,
	 CONSTRAINT [PK_pal_ReportFieldType] 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]

	SET IDENTITY_INSERT [dbo].[pal_ReportFieldType] ON 
	INSERT [dbo].[pal_ReportFieldType] ([recId], [reportFieldType], [isActive]) VALUES (1, N'surface', 1)
	INSERT [dbo].[pal_ReportFieldType] ([recId], [reportFieldType], [isActive]) VALUES (2, N'custom', 1)
	SET IDENTITY_INSERT [dbo].[pal_ReportFieldType] OFF
END