--IsPrimaryKey判断是否主键

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

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

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

if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_pageclass]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_pageclass] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_pageclass] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_adminjb]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_adminjb] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_adminjb] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_adminmenu]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_adminmenu] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_adminmenu] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_area]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_area] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_area] PRIMARY KEY  CLUSTERED 
	(
		[areaid]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_city]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_city] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_city] PRIMARY KEY  CLUSTERED 
	(
		[areaid]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_companyinfo]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_companyinfo] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_companyinfo] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_corp]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_corp] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_corp] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_corppic]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_corppic] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_corppic] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_info]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_info] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_info] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_infopic]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_infopic] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_infopic] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_user]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_user] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_user] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_userjb]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_userjb] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_userjb] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_userreg]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_userreg] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_userreg] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_order]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_order] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_order] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_package]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_package] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_package] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO

--判断是否存在索引 mvc_info_title
if not  exists(select * from sysindexes where name='mvc_info_title')
    CREATE  INDEX [mvc_info_title] ON [dbo].[mvc_info]([title]) ON [PRIMARY]
GO


--IsForeignKey   

if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[FK_e_eachedition_e_eachqi]')  AND name = 'FK_e_eachedition_e_eachqi')
BEGIN
ALTER TABLE [dbo].[e_eachedition] ADD 
	CONSTRAINT [FK_e_eachedition_e_eachqi] FOREIGN KEY 
	(
		[qiid]
	) REFERENCES [dbo].[e_eachqi] (
		[id]
	),
	CONSTRAINT [FK_e_eachedition_e_pageclass] FOREIGN KEY 
	(
		[pageid]
	) REFERENCES [dbo].[e_pageclass] (
		[id]
	)
END
GO
if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[FK_e_news_e_eachqi]')  AND name = 'FK_e_news_e_eachqi')
ALTER TABLE [dbo].[e_news] ADD 
/*
	CONSTRAINT [FK_e_news_e_eachedition] FOREIGN KEY 
	(
		[editionid]
	) REFERENCES [dbo].[e_eachedition] (
		[id]
	),
	*/
	CONSTRAINT [FK_e_news_e_eachqi] FOREIGN KEY 
	(
		[qiid]
	) REFERENCES [dbo].[e_eachqi] (
		[id]
	),
	CONSTRAINT [FK_e_news_mvc_info] FOREIGN KEY 
	(
		[infoid]
	) REFERENCES [dbo].[mvc_info] (
		[id]
	)
GO
if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[FK_mvc_admin_mvc_adminjb]')  AND name = 'FK_mvc_admin_mvc_adminjb')
ALTER TABLE [dbo].[mvc_admin] ADD 
	CONSTRAINT [FK_mvc_admin_mvc_adminjb] FOREIGN KEY 
	(
		[jbid]
	) REFERENCES [dbo].[mvc_adminjb] (
		[id]
	)
GO
--if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[FK_mvc_corppic_mvc_corp]')  AND name = 'FK_mvc_corppic_mvc_corp')
--ALTER TABLE [dbo].[mvc_corppic] ADD 
--	CONSTRAINT [FK_mvc_corppic_mvc_corp] FOREIGN KEY 
--	(
--		[corpid]
--	) REFERENCES [dbo].[mvc_corp] (
--		[id]
--	)
--GO

--if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[FK_mvc_infopic_mvc_info]')  AND name = 'FK_mvc_infopic_mvc_info')
---ALTER TABLE [dbo].[mvc_infopic] ADD 
---	CONSTRAINT [FK_mvc_infopic_mvc_info] FOREIGN KEY 
---	(
---		[infoid]
---	) REFERENCES [dbo].[mvc_info] (
---		[id]
---	)
---GO
if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[FK_mvc_user_mvc_userjb]')  AND name = 'FK_mvc_user_mvc_userjb')
ALTER TABLE [dbo].[mvc_user] ADD 
	CONSTRAINT [FK_mvc_user_mvc_userjb] FOREIGN KEY 
	(
		[jbid]
	) REFERENCES [dbo].[mvc_userjb] (
		[id]
	)
GO
if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[FK_mvc_userreg_mvc_user]')  AND name = 'FK_mvc_userreg_mvc_user')
ALTER TABLE [dbo].[mvc_userreg] ADD 
	CONSTRAINT [FK_mvc_userreg_mvc_user] FOREIGN KEY 
	(
		[userid]
	) REFERENCES [dbo].[mvc_user] (
		[id]
	)
GO

/*2011-11-22 Update 4.1-4.2 */
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_pdf]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_pdf] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_pdf] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO

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

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

if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[FK_e_pdfpic_e_pdf]')  AND name = 'FK_e_pdfpic_e_pdf')
ALTER TABLE [dbo].[e_pdfpic] ADD 
	CONSTRAINT [FK_e_pdfpic_e_pdf] FOREIGN KEY 
	(
		[pdfid]
	) REFERENCES [dbo].[e_pdf] (
		[id]
	)
GO
if not exists (select 1 from dbo.sysobjects where id = object_id(N'[dbo].[FK_e_pdfcon_e_pdf]')  AND name = 'FK_e_pdfcon_e_pdf')
ALTER TABLE [dbo].[e_pdfcon] ADD 
	CONSTRAINT [FK_e_pdfcon_e_pdf] FOREIGN KEY 
	(
		[pdfid]
	) REFERENCES [dbo].[e_pdf] (
		[id]
	)
GO
/*2011-11-22 Update Finish 4.1-4.2 */


/*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
/*2011-12-20 Update 4.2-4.3 主键完 */

if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_article]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
ALTER TABLE [dbo].[e_article] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_article] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_moban]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
ALTER TABLE [dbo].[e_moban] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_moban] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_reader]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
ALTER TABLE [dbo].[e_reader] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_reader] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_qiclass]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
ALTER TABLE [dbo].[e_qiclass] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_qiclass] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO
/*2012-2-18 Update 4.6-4.7 主键完 */

/******  2012-3-1 更新 4.7-4.8 开始******/
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_smtp]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
ALTER TABLE [dbo].[e_smtp] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_smtp] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_body]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
ALTER TABLE [dbo].[e_body] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_body] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO

/******  2012-8-15 更新 4.8-4.9 开始******/
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_newsban]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
ALTER TABLE [dbo].[e_newsban] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_newsban] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
GO
if not  exists(select * from sysindexes where name='e_newsban_editionid')
    CREATE  INDEX [e_newsban_editionid] ON [dbo].[e_newsban]([editionid]) ON [PRIMARY]
GO
if not  exists(select * from sysindexes where name='e_news_qiid')
 CREATE  INDEX [e_news_qiid] ON [dbo].[e_news]([qiid]) ON [PRIMARY]
GO
if not  exists(select * from sysindexes where name='e_news_issuedate')
 CREATE  INDEX [e_news_issuedate] ON [dbo].[e_news]([issuedate]) ON [PRIMARY]
GO
if not  exists(select * from sysindexes where name='e_news_classid')
 CREATE  INDEX [e_news_classid] ON [dbo].[e_news]([classid]) ON [PRIMARY]
GO
if not  exists(select * from sysindexes where name='e_news_classpath')
 CREATE  INDEX [e_news_classpath] ON [dbo].[e_news]([classpath]) ON [PRIMARY]
GO
if not  exists(select * from sysindexes where name='e_news_qiclasspath')
 CREATE  INDEX [e_news_qiclasspath] ON [dbo].[e_news]([qiclasspath]) ON [PRIMARY]
GO
if not  exists(select * from sysindexes where name='e_eachedition_pagepath')
 CREATE  INDEX [e_eachedition_pagepath] ON [dbo].[e_eachedition]([pagepath]) ON [PRIMARY]
GO

/****** 2013-12-9更新 5.3--5.4******/
if not  exists(select * from sysindexes where name='e_eachedition_qiid')
 CREATE  INDEX [e_eachedition_qiid] ON [dbo].[e_eachedition]([qiid]) ON [PRIMARY]
GO
if not  exists(select * from sysindexes where name='e_eachqi_totalqi')
 CREATE  INDEX [e_eachqi_totalqi] ON [dbo].[e_eachqi]([totalqi]) ON [PRIMARY]
GO
if not  exists(select * from sysindexes where name='e_eachqi_issuedate')
 CREATE  INDEX [e_eachqi_issuedate] ON [dbo].[e_eachqi]([issuedate]) ON [PRIMARY]
GO
if not  exists(select * from sysindexes where name='e_eachqi_nowyear')
 CREATE  INDEX [e_eachqi_nowyear] ON [dbo].[e_eachqi]([nowyear]) ON [PRIMARY]
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_e_cmsset]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[e_cmsset] WITH NOCHECK ADD 
	CONSTRAINT [PK_e_cmsset] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PK_mvc_userweixin]') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
BEGIN
ALTER TABLE [dbo].[mvc_userweixin] WITH NOCHECK ADD 
	CONSTRAINT [PK_mvc_userweixin] PRIMARY KEY  CLUSTERED 
	(
		[id]
	)  ON [PRIMARY] 
END
GO
if not  exists(select * from sysindexes where name='mvc_userweixin_userid')
 CREATE  INDEX [mvc_userweixin_userid] ON [dbo].[mvc_userweixin]([userid]) ON [PRIMARY]
GO

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