--权限表记录
IF NOT EXISTS (SELECT * FROM Accounts_Permissions WHERE PermissionID=1301)
BEGIN
DECLARE @NewCategoryID int
INSERT INTO Accounts_PermissionCategories (Description) Values(N'知识库管理')
SET @NewCategoryID = @@IDENTITY
INSERT INTO Accounts_Permissions (PermissionID, Description, CategoryID) Values(1301, N'管理知识库', @NewCategoryID)
INSERT INTO Accounts_Permissions (PermissionID, Description, CategoryID) Values(1302, N'文章审核', @NewCategoryID)

INSERT INTO Accounts_Roles (Description) Values ( N'知识库管理员')
DECLARE @NewRoleID int
SET @NewRoleID = @@IDENTITY
INSERT INTO Accounts_RolePermissions (RoleID, PermissionID) Values(@NewRoleID, 1301)
INSERT INTO Accounts_RolePermissions (RoleID, PermissionID) Values(@NewRoleID, 1302)
END
GO


--新支持的字段
if not exists (select * from Pts_ProblemFields where FieldName=N'Int6' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int6', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int7' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int7', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int8' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int8', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int9' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int9', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int10' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int10', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int11' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int11', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int12' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int12', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int13' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int13', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int14' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int14', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int15' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int15', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int16' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int16', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int17' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int17', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int18' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int18', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int19' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int19', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Int20' AND FieldType= N'Integer')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Int20', N'Integer')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float6' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float6', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float7' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float7', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float8' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float8', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float9' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float9', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float10' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float10', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float11' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float11', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float12' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float12', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float13' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float13', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float14' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float14', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float15' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float15', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float16' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float16', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float17' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float17', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float18' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float18', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float19' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float19', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Float20' AND FieldType= N'Float')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Float20', N'Float')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Date11' AND FieldType= N'DateTime')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Date11', N'DateTime')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Date12' AND FieldType= N'DateTime')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Date12', N'DateTime')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Date13' AND FieldType= N'DateTime')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Date13', N'DateTime')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Date14' AND FieldType= N'DateTime')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Date14', N'DateTime')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Date15' AND FieldType= N'DateTime')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Date15', N'DateTime')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Date16' AND FieldType= N'DateTime')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Date16', N'DateTime')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Date17' AND FieldType= N'DateTime')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Date17', N'DateTime')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Date18' AND FieldType= N'DateTime')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Date18', N'DateTime')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Date19' AND FieldType= N'DateTime')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Date19', N'DateTime')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Date20' AND FieldType= N'DateTime')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Date20', N'DateTime')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'BigText11' AND FieldType= N'BigText')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'BigText11', N'BigText')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'BigText12' AND FieldType= N'BigText')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'BigText12', N'BigText')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'BigText13' AND FieldType= N'BigText')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'BigText13', N'BigText')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'BigText14' AND FieldType= N'BigText')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'BigText14', N'BigText')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'BigText15' AND FieldType= N'BigText')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'BigText15', N'BigText')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'BigText16' AND FieldType= N'BigText')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'BigText16', N'BigText')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'BigText17' AND FieldType= N'BigText')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'BigText17', N'BigText')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'BigText18' AND FieldType= N'BigText')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'BigText18', N'BigText')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'BigText19' AND FieldType= N'BigText')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'BigText19', N'BigText')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'BigText20' AND FieldType= N'BigText')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'BigText20', N'BigText')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Select16' AND FieldType= N'Select')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Select16', N'Select')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Select17' AND FieldType= N'Select')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Select17', N'Select')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Select18' AND FieldType= N'Select')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Select18', N'Select')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Select19' AND FieldType= N'Select')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Select19', N'Select')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Select20' AND FieldType= N'Select')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Select20', N'Select')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Email6' AND FieldType= N'Email')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Email6', N'Email')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Email7' AND FieldType= N'Email')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Email7', N'Email')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Email8' AND FieldType= N'Email')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Email8', N'Email')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Email9' AND FieldType= N'Email')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Email9', N'Email')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Email10' AND FieldType= N'Email')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Email10', N'Email')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect6' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect6', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect7' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect7', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect8' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect8', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect9' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect9', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect10' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect10', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect11' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect11', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect12' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect12', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect13' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect13', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect14' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect14', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect15' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect15', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect16' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect16', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect17' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect17', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect18' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect18', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect19' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect19', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'MultiSelect20' AND FieldType= N'MultiSelect')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'MultiSelect20', N'MultiSelect')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo6' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo6', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo7' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo7', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo8' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo8', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo9' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo9', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo10' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo10', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo11' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo11', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo12' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo12', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo13' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo13', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo14' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo14', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo15' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo15', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo16' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo16', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo17' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo17', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo18' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo18', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo19' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo19', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'YesNo20' AND FieldType= N'YesNo')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'YesNo20', N'YesNo')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Url6' AND FieldType= N'Url')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Url6', N'Url')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Url7' AND FieldType= N'Url')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Url7', N'Url')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Url8' AND FieldType= N'Url')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Url8', N'Url')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Url9' AND FieldType= N'Url')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Url9', N'Url')	
END
GO


if not exists (select * from Pts_ProblemFields where FieldName=N'Url10' AND FieldType= N'Url')	
BEGIN
	Insert into Pts_ProblemFields (FieldName, FieldType) Values(N'Url10', N'Url')	
END
GO


			
			
			
			
			
			
			
			
			
			
			

