/******  2011-12-20 更新 4.2-4.3 ******/
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[e_ping]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[e_ping] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[qiid] [int] NULL ,
	[editionid] [int] NULL ,
	[newsid] [int] NULL ,
	[userid] [int] NULL ,
	[plsign] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[pltitle] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[pldetail] [nvarchar] (3999) COLLATE Chinese_PRC_CI_AS NULL ,
	[plip] [varchar] (32) COLLATE Chinese_PRC_CI_AS NULL ,
	[plfrom] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[plgood] [int] NULL ,
	[istj] [bit] NULL ,
	[isshen] [bit] NULL ,
	[parentid] [int] NULL ,
	[hits] [int] NULL ,
	[addtime] [datetime] NULL 
) ON [PRIMARY]  
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[e_pingreply]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[e_pingreply] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[pingid] [int] NULL ,
	[userid] [int] NULL ,
	[resign] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[reply] [nvarchar] (3999) COLLATE Chinese_PRC_CI_AS NULL ,
	[reip] [varchar] (32) COLLATE Chinese_PRC_CI_AS NULL ,
	[refrom] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[parentid] [int] NULL ,
	[addtime] [datetime] NULL 
) ON [PRIMARY]  

/* ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]*/
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[e_pinfoqi]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[e_pinfoqi] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[qiid] [int] NULL ,
	[scoreall] [decimal](3, 1) NULL ,
	[totalren] [int] NULL 
) ON [PRIMARY]
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[e_pinfonews]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[e_pinfonews] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[newsid] [int] NULL ,
	[scoreall] [decimal](3, 1) NULL ,
	[totalren] [int] NULL 
) ON [PRIMARY]
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[e_sconews]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[e_sconews] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[newsid] [int] NULL ,
	[userid] [int] NULL ,
	[scoreall] [tinyint] NULL 
) ON [PRIMARY]
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[e_scoedition]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[e_scoedition] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[editionid] [int] NULL ,
	[userid] [int] NULL ,
	[scoreall] [tinyint] NULL 
) ON [PRIMARY]
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[e_scoqi]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[e_scoqi] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[qiid] [int] NULL ,
	[userid] [int] NULL ,
	[scoreall] [tinyint] NULL 
) ON [PRIMARY]
GO
/******  2011-12-20 更新 4.2-4.3 建表完 ******/


/******2011-12-20 Update 4.2-4.3 主键******/

if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_pinfoqi]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_pinfoqi] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_pinfoqi] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_pinfonews]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_pinfonews] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_pinfonews] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO

if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_ping]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_ping] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_ping] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO

if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_pingreply]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_pingreply] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_pingreply] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_sconews]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_sconews] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_sconews] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_scoedition]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_scoedition] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_scoedition] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_scoqi]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_scoqi] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_scoqi] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO

/**主键完 2011-12-20**/

/**约束**/
if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[FK_e_pingreply_e_ping]')  AND name = 'FK_e_pingreply_e_ping')
ALTER TABLE [dbo].[e_pingreply] ADD 
	CONSTRAINT [FK_e_pingreply_e_ping] FOREIGN KEY 
	(
		[pingid]
	) REFERENCES [dbo].[e_ping] (
		[id]
	)
GO

/***e_setting加字段 [isping] =0,[isshen] =0***/
alter table [dbo].[e_setting] ADD [isping] [bit] NULL ,[isshen] [bit] NULL 
GO
/****** 对象: UPDATE表 [dbo].[mvc_adminmenu]   2011-12-20 ******/
UPDATE [dbo].[mvc_adminmenu] SET [referurl] =convert(text, N'Commentmanage.aspx' collate Chinese_PRC_CI_AS) where id=58
GO
/******update 表 e_setting isping ishen字段为0******/
UPDATE [dbo].[e_setting] SET [isping] =0,[isshen] =0 where id=1
GO
/******011-12-20 Update Finish 4.2-4.3 ******/
