/******  2012-2-12 更新 4.6-4.7 ******/
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[e_article]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[e_article] (
	[id] [int] IDENTITY (1, 1) NOT NULL,
	[title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[content] [ntext] COLLATE Chinese_PRC_CI_AS NULL ,
	[fordoc] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
	[contact] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[tel] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[email] [varchar] (80) COLLATE Chinese_PRC_CI_AS NULL ,
	[isread] [bit] NULL ,
	[addtime] [datetime] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[e_moban]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[e_moban] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[typeid] [int] NULL ,
	[classname] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[classen] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[classdes] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[sortid] [int] NULL 
) ON [PRIMARY]
GO
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[e_reader]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[e_reader] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[chenname] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[email] [varchar] (80) COLLATE Chinese_PRC_CI_AS NULL ,
	[issend] [bit] NULL ,
	[isvalid] [bit] NULL ,
	[isding] [bit] NULL ,
	[isdui] [bit] NULL ,
	[addtime] [datetime] NULL 
) ON [PRIMARY]
GO
/****** 对象: 表 [dbo].[e_qiclass]    脚本日期: 2012-2-18 11:35:31 ******/
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[e_qiclass]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[e_qiclass] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[qiid] [int] NULL ,
	[classname] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[classen] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
	[classdes] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[parentid] [int] NULL ,
	[depth] [int] NULL ,
	[parentpath] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[childclass] [varchar] (2000) COLLATE Chinese_PRC_CI_AS NULL ,
	[sortid] [int] NULL ,
	[isrefer] [bit] NULL ,
	[referurl] [varchar] (150) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO
/******  2012-2-18 更新 4.6-4.7完 ******/
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-12 Update 4.6-4.7 主键完 ***/
/***e_news加字段 [qiclid] =0***/
alter table [dbo].[e_news] ADD [qiclid] [int] NULL
GO
UPDATE [dbo].[e_news] SET [qiclid] =0
GO
/***e_setting加字段 [pwidth] =410,[pheight] =615***/
alter table [dbo].[e_setting] ADD [ispage] [bit] NULL,[pwidth] [int] NULL ,[pheight] [int] NULL,[defaultpage] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
GO
UPDATE [dbo].[e_setting] SET ispage=0,[pwidth] =410,[pheight]=615,defaultpage='' where id=1
GO
alter table [dbo].[e_eachqi] ADD [qipic] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
    [downpic] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
	[ispicurl] [bit] NULL ,
	[downpicurl] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
	[downpdf] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL ,
	[ispdfurl] [bit] NULL ,
	[downpdfurl] [varchar] (120) COLLATE Chinese_PRC_CI_AS NULL 
GO
UPDATE [dbo].[e_eachqi] SET [qipic] ='',[downpic]='',[ispicurl]=0,[downpicurl]='',[downpdf]='',[ispdfurl]=0,[downpdfurl]=''
GO
/*删除字段typeid*/
alter  table [dbo].[e_allyear]  drop   column  typeid 
alter  table [dbo].[e_allmonth]  drop   column  typeid 
alter  table [dbo].[e_pageclass]  drop   column  typeid 
alter  table [dbo].[e_eachqi]  drop   column  typeid 
alter  table [dbo].[e_eachedition]  drop   column  typeid 
alter  table [dbo].[e_news] drop  column  typeid 
GO
/*删除约束*/
ALTER TABLE [dbo].[e_news] drop CONSTRAINT FK_e_news_e_eachedition
GO
/*更新字段*/
alter table [dbo].[e_news] alter column  editionid [varchar](100) COLLATE Chinese_PRC_CI_AS NULL
GO
/***update data***/
INSERT [dbo].[mvc_adminmenu] ([id], [classname], [classen], [classdes], [parentid], [depth], [parentpath], [childclass], [sortid], [isrefer], [referurl]) VALUES (89, N'模板管理', convert(text, N'' collate Chinese_PRC_CI_AS), N'', 3, 1, convert(text, N'0,3' collate Chinese_PRC_CI_AS), convert(text, N'89' collate Chinese_PRC_CI_AS), 10, 1, convert(text, N'Mobanmanage.aspx' collate Chinese_PRC_CI_AS))
INSERT [dbo].[mvc_adminmenu] ([id], [classname], [classen], [classdes], [parentid], [depth], [parentpath], [childclass], [sortid], [isrefer], [referurl]) VALUES (90, N'其他信息', convert(text, N'' collate Chinese_PRC_CI_AS), N'', 0, 0, convert(text, N'0' collate Chinese_PRC_CI_AS), convert(text, N'90,91,92,93' collate Chinese_PRC_CI_AS), 12, 1, convert(text, N'Default.aspx' collate Chinese_PRC_CI_AS))
INSERT [dbo].[mvc_adminmenu] ([id], [classname], [classen], [classdes], [parentid], [depth], [parentpath], [childclass], [sortid], [isrefer], [referurl]) VALUES (91, N'在线投稿管理', convert(text, N'' collate Chinese_PRC_CI_AS), N'', 90, 1, convert(text, N'0,90' collate Chinese_PRC_CI_AS), convert(text, N'91' collate Chinese_PRC_CI_AS), 1, 1, convert(text, N'Tougaomanage.aspx' collate Chinese_PRC_CI_AS))
INSERT [dbo].[mvc_adminmenu] ([id], [classname], [classen], [classdes], [parentid], [depth], [parentpath], [childclass], [sortid], [isrefer], [referurl]) VALUES (92, N'在线订阅管理', convert(text, N'' collate Chinese_PRC_CI_AS), N'', 90, 1, convert(text, N'0,90' collate Chinese_PRC_CI_AS), convert(text, N'92' collate Chinese_PRC_CI_AS), 2, 1, convert(text, N'Dingyuemanage.aspx' collate Chinese_PRC_CI_AS))
INSERT [dbo].[mvc_adminmenu] ([id], [classname], [classen], [classdes], [parentid], [depth], [parentpath], [childclass], [sortid], [isrefer], [referurl]) VALUES (93, N'友情链接管理', convert(text, N'' collate Chinese_PRC_CI_AS), N'', 90, 1, convert(text, N'0,90' collate Chinese_PRC_CI_AS), convert(text, N'93' collate Chinese_PRC_CI_AS), 3, 1, convert(text, N'Linksmanage.aspx' collate Chinese_PRC_CI_AS))
GO
INSERT [dbo].[e_moban] ([typeid],[classname], [classen], [classdes], [sortid]) VALUES (0,N'红色', convert(text, N'default' collate Chinese_PRC_CI_AS), N'默认报纸模板', 1)
INSERT [dbo].[e_moban] ([typeid],[classname], [classen], [classdes], [sortid]) VALUES (0,N'蓝色', convert(text, N'blue' collate Chinese_PRC_CI_AS), N'蓝色报纸模板', 2)
INSERT [dbo].[e_moban] ([typeid],[classname], [classen], [classdes], [sortid]) VALUES (8,N'菲星数码', convert(text, N'basic' collate Chinese_PRC_CI_AS), N'广州菲星数码《菲粉》杂志模板', 1)