--
-- Script To Update Accounts_Users Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Accounts_Users Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   ALTER TABLE [Accounts_Users]
      ADD [AgentUserID] [int] NULL
GO



IF 1 = 1
   ALTER TABLE [Accounts_Users]
      ADD [ExpireDate] [datetime] NULL
GO



IF 1 = 1
   ALTER TABLE [Accounts_Users]
      ADD [ExtendedSettings] [ntext] COLLATE Chinese_PRC_CI_AS NULL
GO



IF 1 = 1
   ALTER TABLE [Accounts_Users]
      ADD [ExtIntData1] [int] NULL
GO



IF 1 = 1
   ALTER TABLE [Accounts_Users]
      ADD [ExtIntData2] [int] NULL
GO



IF 1 = 1
   ALTER TABLE [Accounts_Users]
      ADD [ExtIntData3] [int] NULL
GO



IF 1 = 1
   ALTER TABLE [Accounts_Users]
      ADD [ExtIntData4] [int] NULL
GO



IF 1 = 1
   ALTER TABLE [Accounts_Users]
      ADD [ExtStrData1] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NULL
GO



IF 1 = 1
   ALTER TABLE [Accounts_Users]
      ADD [ExtStrData2] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NULL
GO



IF 1 = 1
   ALTER TABLE [Accounts_Users]
      ADD [LoginName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL
GO









IF 1 = 1
BEGIN
   PRINT 'Accounts_Users Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Accounts_Users Table'
END
GO


--
-- Script To Update Accounts_UserRoles Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Accounts_UserRoles Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Accounts_UserRoles_Accounts_Users')
      ALTER TABLE [Accounts_UserRoles] DROP CONSTRAINT [FK_Accounts_UserRoles_Accounts_Users]
GO



IF 1 = 1
BEGIN
   PRINT 'Accounts_UserRoles Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Accounts_UserRoles Table'
END
GO


--
-- Script To Update Common_Config Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Common_Config Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Common_Config_AllowSelfRegister')
      ALTER TABLE [Common_Config] DROP CONSTRAINT [DF_Common_Config_AllowSelfRegister]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Common_Config_AutoSetNewUserNormal')
      ALTER TABLE [Common_Config] DROP CONSTRAINT [DF_Common_Config_AutoSetNewUserNormal]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Common_Config_RequireSmtpAuthentication')
      ALTER TABLE [Common_Config] DROP CONSTRAINT [DF_Common_Config_RequireSmtpAuthentication]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Common_Config_MailServer')
      ALTER TABLE [Common_Config] DROP CONSTRAINT [DF_Common_Config_MailServer]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Common_Config_MailUsername')
      ALTER TABLE [Common_Config] DROP CONSTRAINT [DF_Common_Config_MailUsername]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Common_Config_MailPassword')
      ALTER TABLE [Common_Config] DROP CONSTRAINT [DF_Common_Config_MailPassword]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Common_Config_SiteUrl')
      ALTER TABLE [Common_Config] DROP CONSTRAINT [DF_Common_Config_SiteUrl]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Common_Config_CompanyName')
      ALTER TABLE [Common_Config] DROP CONSTRAINT [DF_Common_Config_CompanyName]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Common_Config_CompanyUrl')
      ALTER TABLE [Common_Config] DROP CONSTRAINT [DF_Common_Config_CompanyUrl]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF__Common_Co__Admin__16D94F8E')
      ALTER TABLE [Common_Config] DROP CONSTRAINT [DF__Common_Co__Admin__16D94F8E]
GO



IF 1 = 1
   CREATE TABLE [tmp_Common_Config] (
   [ID] [int] IDENTITY (1, 1) NOT NULL,
   [AllowSelfRegister] [bit] NOT NULL CONSTRAINT [DF_Common_Config_AllowSelfRegister] DEFAULT (1),
   [AutoSetNewUserNormal] [bit] NOT NULL CONSTRAINT [DF_Common_Config_AutoSetNewUserNormal] DEFAULT (1),
   [RequireSmtpAuthentication] [bit] NOT NULL CONSTRAINT [DF_Common_Config_RequireSmtpAuthentication] DEFAULT (0),
   [MailServer] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_Common_Config_MailServer] DEFAULT (''),
   [MailUsername] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_Common_Config_MailUsername] DEFAULT (''),
   [MailPassword] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_Common_Config_MailPassword] DEFAULT (''),
   [SiteUrl] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_Common_Config_SiteUrl] DEFAULT (''),
   [CompanyName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_Common_Config_CompanyName] DEFAULT (''),
   [CompanyUrl] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_Common_Config_CompanyUrl] DEFAULT (''),
   [AdminMail] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF__Common_Co__Admin__16D94F8E] DEFAULT (''),
   [SenderMail] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [ExtendedSettings] [ntext] COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_Common_Config_ExtendedSettings] DEFAULT (N'')
)
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Common_Config] ON
GO



IF 1 = 1
   INSERT INTO [tmp_Common_Config] ([ID], [AllowSelfRegister], [AutoSetNewUserNormal], [RequireSmtpAuthentication], [MailServer], [MailUsername], [MailPassword], [SiteUrl], [CompanyName], [CompanyUrl], [AdminMail], [SenderMail])
   SELECT [ID], [AllowSelfRegister], [AutoSetNewUserNormal], [RequireSmtpAuthentication], [MailServer], [MailUsername], [MailPassword], [SiteUrl], [CompanyName], [CompanyUrl], [AdminMail], [SenderMail]
   FROM [Common_Config]
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Common_Config] OFF
GO



IF 1 = 1
   DROP TABLE [Common_Config]
GO

sp_rename N'[tmp_Common_Config]', N'Common_Config'



IF 1 = 1
BEGIN
   PRINT 'Common_Config Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Common_Config Table'
END
GO

--
-- Script To Create Common_Events Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Common_Events Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Common_Events] (
   [EventID] [int] IDENTITY (1, 1) NOT NULL,
   [Time] [datetime] NULL,
   [UserID] [int] NULL,
   [UserName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL,
   [EventType] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL,
   [EventInfo] [ntext] COLLATE Chinese_PRC_CI_AS NULL
)
GO



IF 1 = 1
   ALTER TABLE [Common_Events] ADD CONSTRAINT [PK_Common_Events] PRIMARY KEY CLUSTERED ([EventID])
GO



IF 1 = 1
BEGIN
   PRINT 'Common_Events Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Common_Events Table'
END
GO

--
-- Script To Create Common_PersonalConfig Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Common_PersonalConfig Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Common_PersonalConfig] (
   [ID] [int] IDENTITY (1, 1) NOT NULL,
   [UserID] [int] NOT NULL,
   [ProjectID] [int] NOT NULL CONSTRAINT [DF_Common_PersonalConfig_ProjectID] DEFAULT ((0)),
   [Type] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [CreateDate] [datetime] NOT NULL,
   [Title] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [Data] [ntext] COLLATE Chinese_PRC_CI_AS NULL
)
GO



IF 1 = 1
   ALTER TABLE [Common_PersonalConfig] ADD CONSTRAINT [PK_Common_PersonalConfig] PRIMARY KEY CLUSTERED ([ID])
GO



IF 1 = 1
BEGIN
   PRINT 'Common_PersonalConfig Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Common_PersonalConfig Table'
END
GO

--
-- Script To Create Common_SystemConfig Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Common_SystemConfig Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Common_SystemConfig] (
   [ConfigItem] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [ConfigValue] [ntext] COLLATE Chinese_PRC_CI_AS NULL
)
GO



IF 1 = 1
   ALTER TABLE [Common_SystemConfig] ADD CONSTRAINT [PK_Common_SystemConfig] PRIMARY KEY CLUSTERED ([ConfigItem])
GO



IF 1 = 1
BEGIN
   PRINT 'Common_SystemConfig Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Common_SystemConfig Table'
END
GO

--
-- Script To Create Common_Version Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Common_Version Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Common_Version] (
   [DbVersion] [int] NULL
)
GO



IF 1 = 1
BEGIN
   PRINT 'Common_Version Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Common_Version Table'
END
GO

--
-- Script To Update Kb_ArticleAttachments Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Kb_ArticleAttachments Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO



IF 1 = 1
BEGIN
   PRINT 'Kb_ArticleAttachments Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Kb_ArticleAttachments Table'
END
GO


--
-- Script To Update Kb_ArticleComment Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Kb_ArticleComment Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO



IF 1 = 1
BEGIN
   PRINT 'Kb_ArticleComment Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Kb_ArticleComment Table'
END
GO


--
-- Script To Update Kb_Articles Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Kb_Articles Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Kb_Articles_CreateDate')
      ALTER TABLE [Kb_Articles] DROP CONSTRAINT [DF_Kb_Articles_CreateDate]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Kb_Articles_UpdateDate')
      ALTER TABLE [Kb_Articles] DROP CONSTRAINT [DF_Kb_Articles_UpdateDate]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Kb_Articles_NumRead')
      ALTER TABLE [Kb_Articles] DROP CONSTRAINT [DF_Kb_Articles_NumRead]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Kb_Articles_NumRatings')
      ALTER TABLE [Kb_Articles] DROP CONSTRAINT [DF_Kb_Articles_NumRatings]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Kb_Articles_RateValue')
      ALTER TABLE [Kb_Articles] DROP CONSTRAINT [DF_Kb_Articles_RateValue]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Kb_Articles_ArticleStatus')
      ALTER TABLE [Kb_Articles] DROP CONSTRAINT [DF_Kb_Articles_ArticleStatus]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Kb_Articles_CreateUserID')
      ALTER TABLE [Kb_Articles] DROP CONSTRAINT [DF_Kb_Articles_CreateUserID]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Kb_Articles_NumComment')
      ALTER TABLE [Kb_Articles] DROP CONSTRAINT [DF_Kb_Articles_NumComment]
GO



IF 1 = 1
   CREATE TABLE [tmp_Kb_Articles] (
   [ArticleID] [int] IDENTITY (1, 1) NOT NULL,
   [CategoryID] [int] NOT NULL,
   [Title] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [KeyWords] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NULL,
   [Summary] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [CreateDate] [datetime] NULL CONSTRAINT [DF_Kb_Articles_CreateDate] DEFAULT (getdate()),
   [UpdateDate] [datetime] NULL CONSTRAINT [DF_Kb_Articles_UpdateDate] DEFAULT (getdate()),
   [CreateUser] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL,
   [UpdateUser] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL,
   [NumRead] [int] NULL CONSTRAINT [DF_Kb_Articles_NumRead] DEFAULT (0),
   [IsRepost] [bit] NULL,
   [NumRatings] [int] NOT NULL CONSTRAINT [DF_Kb_Articles_NumRatings] DEFAULT (0),
   [RateValue] [float] NOT NULL CONSTRAINT [DF_Kb_Articles_RateValue] DEFAULT (3),
   [ArticleStatus] [int] NULL CONSTRAINT [DF_Kb_Articles_ArticleStatus] DEFAULT (0),
   [Source] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [SourceUrl] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [ValueLevel] [tinyint] NULL,
   [Difficulty] [tinyint] NULL,
   [RelateProblemID] [int] NULL,
   [OriginAuthor] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL,
   [CreateUserID] [int] NOT NULL CONSTRAINT [DF_Kb_Articles_CreateUserID] DEFAULT (0),
   [NumComment] [int] NULL CONSTRAINT [DF_Kb_Articles_NumComment] DEFAULT (0),
   [IsReviewed] [bit] NOT NULL CONSTRAINT [DF_Kb_Articles_IsReviewed] DEFAULT (0),
   [ReviewedBy] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL,
   [IsPublic] [bit] NOT NULL CONSTRAINT [DF_Kb_Articles_IsPublic] DEFAULT (1),
   [Note1] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [Note2] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [Note3] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [Note4] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [Note5] [ntext] COLLATE Chinese_PRC_CI_AS NULL
)
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Kb_Articles] ON
GO



IF 1 = 1
   INSERT INTO [tmp_Kb_Articles] ([ArticleID], [CategoryID], [Title], [KeyWords], [Summary], [Content], [CreateDate], [UpdateDate], [CreateUser], [UpdateUser], [NumRead], [IsRepost], [NumRatings], [RateValue], [ArticleStatus], [Source], [SourceUrl], [ValueLevel], [Difficulty], [RelateProblemID], [OriginAuthor], [CreateUserID], [NumComment], [ReviewedBy], [Note1], [Note2], [Note3], [Note4], [Note5])
   SELECT [ArticleID], [CategoryID], [Title], [KeyWords], [Summary], [Content], [CreateDate], [UpdateDate], [CreateUser], [UpdateUser], [NumRead], [IsRepost], [NumRatings], [RateValue], [ArticleStatus], [Source], [SourceUrl], [ValueLevel], [Difficulty], [RelateProblemID], [OriginAuthor], [CreateUserID], [NumComment], NULL, NULL, NULL, NULL, NULL, NULL
   FROM [Kb_Articles]
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Kb_Articles] OFF
GO



IF 1 = 1
   DROP TABLE [Kb_Articles]
GO

sp_rename N'[tmp_Kb_Articles]', N'Kb_Articles'



IF 1 = 1
   ALTER TABLE [Kb_Articles] ADD CONSTRAINT [PK_Kb_Articles] PRIMARY KEY CLUSTERED ([ArticleID])
GO







IF 1 = 1
BEGIN
   PRINT 'Kb_Articles Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Kb_Articles Table'
END
GO

--
-- Script To Create Kb_ArticleViewer Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Kb_ArticleViewer Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Kb_ArticleViewer] (
   [ArticleID] [int] NOT NULL,
   [UserID] [int] NOT NULL
)
GO



IF 1 = 1
BEGIN
   PRINT 'Kb_ArticleViewer Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Kb_ArticleViewer Table'
END
GO

--
-- Script To Update Pts_DbDirectory Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_DbDirectory Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_DbDirectory_ProjectID')
      ALTER TABLE [Pts_DbDirectory] DROP CONSTRAINT [DF_Pts_DbDirectory_ProjectID]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_DbDirectory_Hidden')
      ALTER TABLE [Pts_DbDirectory] DROP CONSTRAINT [DF_Pts_DbDirectory_Hidden]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_DbDirectory_InUse')
      ALTER TABLE [Pts_DbDirectory] DROP CONSTRAINT [DF_Pts_DbDirectory_InUse]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_DbDirectory_ListOrder')
      ALTER TABLE [Pts_DbDirectory] DROP CONSTRAINT [DF_Pts_DbDirectory_ListOrder]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_DbDirectory_Required')
      ALTER TABLE [Pts_DbDirectory] DROP CONSTRAINT [DF_Pts_DbDirectory_Required]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_DbDirectory_HtmlEdit')
      ALTER TABLE [Pts_DbDirectory] DROP CONSTRAINT [DF_Pts_DbDirectory_HtmlEdit]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_DbDirectory_MaxLength')
      ALTER TABLE [Pts_DbDirectory] DROP CONSTRAINT [DF_Pts_DbDirectory_MaxLength]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_DbDirectory_UseSelectList')
      ALTER TABLE [Pts_DbDirectory] DROP CONSTRAINT [DF_Pts_DbDirectory_UseSelectList]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_DbDirectory_UseGlobalSelect')
      ALTER TABLE [Pts_DbDirectory] DROP CONSTRAINT [DF_Pts_DbDirectory_UseGlobalSelect]
GO



IF 1 = 1
   CREATE TABLE [tmp_Pts_DbDirectory] (
   [ID] [int] IDENTITY (1, 1) NOT NULL,
   [ProjectID] [int] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_ProjectID] DEFAULT (1),
   [FieldName] [varchar] (60) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [Label] [nvarchar] (25) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [FieldType] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [Hidden] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_Hidden] DEFAULT (0),
   [InUse] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_InUse] DEFAULT (0),
   [ListOrder] [int] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_ListOrder] DEFAULT (1000),
   [Required] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_Required] DEFAULT (1),
   [DefaultValue] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [SelectItems] [nvarchar] (2000) COLLATE Chinese_PRC_CI_AS NULL,
   [FieldHelp] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [FormatString] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [HtmlEdit] [bit] NULL CONSTRAINT [DF_Pts_DbDirectory_HtmlEdit] DEFAULT (0),
   [MaxLength] [int] NULL CONSTRAINT [DF_Pts_DbDirectory_MaxLength] DEFAULT (0),
   [Width] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL,
   [Height] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL,
   [GlobalSelectID] [int] NULL,
   [UseSelectList] [bit] NULL CONSTRAINT [DF_Pts_DbDirectory_UseSelectList] DEFAULT (0),
   [UseGlobalSelect] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_UseGlobalSelect] DEFAULT (0),
   [ReadableToAll] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_ReadableToAll] DEFAULT ((1)),
   [EditableToAll] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_EditableToAll] DEFAULT ((1)),
   [IsSystem] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_IsSystem] DEFAULT ((0)),
   [VisibleWhenNew] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_VisibleWhenNew] DEFAULT ((1)),
   [VisibleWhenEdit] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_VisibleWhenEdit] DEFAULT ((1)),
   [VisibleInList] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_VisibleInList] DEFAULT ((0)),
   [ReadableToCreateUser] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_VisibleToCreator] DEFAULT ((1)),
   [EditableToCreateUser] [bit] NOT NULL CONSTRAINT [DF_Pts_DbDirectory_EditableToCreateUser] DEFAULT ((1))
)
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Pts_DbDirectory] ON
GO



IF 1 = 1
   INSERT INTO [tmp_Pts_DbDirectory] ([ID], [ProjectID], [FieldName], [Label], [FieldType], [Hidden], [InUse], [ListOrder], [Required], [DefaultValue], [SelectItems], [FieldHelp], [FormatString], [HtmlEdit], [MaxLength], [Width], [Height], [GlobalSelectID], [UseSelectList], [UseGlobalSelect])
   SELECT [ID], [ProjectID], [FieldName], [Label], [FieldType], [Hidden], [InUse], [ListOrder], [Required], [DefaultValue], [SelectItems], [FieldHelp], [FormatString], [HtmlEdit], [MaxLength], [Width], [Height], [GlobalSelectID], [UseSelectList], [UseGlobalSelect]
   FROM [Pts_DbDirectory]
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Pts_DbDirectory] OFF
GO



IF 1 = 1
   DROP TABLE [Pts_DbDirectory]
GO

sp_rename N'[tmp_Pts_DbDirectory]', N'Pts_DbDirectory'



IF 1 = 1
   ALTER TABLE [Pts_DbDirectory] ADD CONSTRAINT [PK_Pts_DbDirectory] PRIMARY KEY CLUSTERED ([ID])
GO














IF 1 = 1
BEGIN
   PRINT 'Pts_DbDirectory Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_DbDirectory Table'
END
GO


--
-- Script To Update Pts_FilterNodes Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_FilterNodes Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_FilterNodes Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_FilterNodes Table'
END
GO


--
-- Script To Update Pts_Filters Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_Filters Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_Filters Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_Filters Table'
END
GO


--
-- Script To Create Pts_Notify Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_Notify Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_Notify] (
   [NotifyID] [int] IDENTITY (1, 1) NOT NULL,
   [TargetType] [int] NOT NULL,
   [TargetID] [int] NOT NULL,
   [NotifyUsers] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [EventType] [int] NOT NULL,
   [CCMails] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [Sender] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [EventTime] [datetime] NOT NULL CONSTRAINT [DF_Pts_Notify_EventTime] DEFAULT (getdate())
)
GO



IF 1 = 1
   ALTER TABLE [Pts_Notify] ADD CONSTRAINT [PK_Pts_Notify] PRIMARY KEY CLUSTERED ([NotifyID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_Notify Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_Notify Table'
END
GO

--
-- Script To Update Pts_Projects Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_Projects Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemCatalogs_Pts_Projects')
      ALTER TABLE [Pts_ProblemCatalogs] DROP CONSTRAINT [FK_Pts_ProblemCatalogs_Pts_Projects]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemPriority_Pts_Projects')
      ALTER TABLE [Pts_ProblemPriority] DROP CONSTRAINT [FK_Pts_ProblemPriority_Pts_Projects]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_Projects')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Pts_Projects]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_Projects1')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Pts_Projects1]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemSeverities_Pts_Projects')
      ALTER TABLE [Pts_ProblemSeverity] DROP CONSTRAINT [FK_Pts_ProblemSeverities_Pts_Projects]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemState_Pts_Projects')
      ALTER TABLE [Pts_ProblemState] DROP CONSTRAINT [FK_Pts_ProblemState_Pts_Projects]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemType_Pts_Projects')
      ALTER TABLE [Pts_ProblemType] DROP CONSTRAINT [FK_Pts_ProblemType_Pts_Projects]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_RecordType_Pts_Projects')
      ALTER TABLE [Pts_RecordType] DROP CONSTRAINT [FK_Pts_RecordType_Pts_Projects]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Workgroups_Pts_Projects')
      ALTER TABLE [Pts_Workgroups] DROP CONSTRAINT [FK_Pts_Workgroups_Pts_Projects]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Projects_Pts_ProjectCatalogs')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [FK_Pts_Projects_Pts_ProjectCatalogs]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Projects_Pts_ProjectStates')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [FK_Pts_Projects_Pts_ProjectStates]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_ProjectCode')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_ProjectCode]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_ShortName')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_ShortName]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_Description')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_Description]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_TotalProblems')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_TotalProblems]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_TotalThreads')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_TotalThreads]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_TotalRecords')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_TotalRecords]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_DateCreated')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_DateCreated]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_ProblemTitle')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_ProblemTitle]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_ThreadTitle')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_ThreadTitle]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_RecordTitle')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_RecordTitle]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_ChangeOwnProblem')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_ChangeOwnProblem]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_EnableProblemState')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_EnableProblemState]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_MultipleThread')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_MultipleThread]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_EnableEMailNotify')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_EnableEMailNotify]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_EnableProblemPriority')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_EnableProblemPriority]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_EnableProblemSeverity')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_EnableProblemSeverity]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_EnableProblemType')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_EnableProblemType]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_EnableProblemCatalog')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_EnableProblemCatalog]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_EnableProblemDeadline')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_EnableProblemDeadline]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_VisibleToAll')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_VisibleToAll]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_EnableStateTimer')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_EnableStateTimer]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_AutoAssignedTo')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_AutoAssignedTo]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF__Pts_Proje__OpenP__3DE82FB7')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF__Pts_Proje__OpenP__3DE82FB7]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Projects_NewProblemIndex')
      ALTER TABLE [Pts_Projects] DROP CONSTRAINT [DF_Pts_Projects_NewProblemIndex]
GO



IF 1 = 1
   CREATE TABLE [tmp_Pts_Projects] (
   [ProjectID] [int] IDENTITY (1, 1) NOT NULL,
   [ProjectCatalogID] [int] NOT NULL,
   [ProjectCode] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_Pts_Projects_ProjectCode] DEFAULT (''),
   [Name] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [ShortName] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_Pts_Projects_ShortName] DEFAULT (''),
   [Description] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_Pts_Projects_Description] DEFAULT (''),
   [ProjectStateID] [int] NOT NULL,
   [TotalProblems] [int] NOT NULL CONSTRAINT [DF_Pts_Projects_TotalProblems] DEFAULT (0),
   [TotalThreads] [int] NOT NULL CONSTRAINT [DF_Pts_Projects_TotalThreads] DEFAULT (0),
   [TotalRecords] [int] NOT NULL CONSTRAINT [DF_Pts_Projects_TotalRecords] DEFAULT (0),
   [DateCreated] [smalldatetime] NOT NULL CONSTRAINT [DF_Pts_Projects_DateCreated] DEFAULT (getdate()),
   [ProblemTitle] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_Pts_Projects_ProblemTitle] DEFAULT (N'问题'),
   [ThreadTitle] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_Pts_Projects_ThreadTitle] DEFAULT (N'任务'),
   [RecordTitle] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF_Pts_Projects_RecordTitle] DEFAULT (N'记录'),
   [OnlyViewOwnProblem] [bit] NOT NULL CONSTRAINT [DF_Pts_Projects_ChangeOwnProblem] DEFAULT (1),
   [EnableProblemState] [bit] NOT NULL CONSTRAINT [DF_Pts_Projects_EnableProblemState] DEFAULT (1),
   [EnableMultipleThread] [bit] NOT NULL CONSTRAINT [DF_Pts_Projects_MultipleThread] DEFAULT (0),
   [EnableEmailNotify] [bit] NOT NULL CONSTRAINT [DF_Pts_Projects_EnableEMailNotify] DEFAULT (1),
   [EnableProblemPriority] [bit] NOT NULL CONSTRAINT [DF_Pts_Projects_EnableProblemPriority] DEFAULT (1),
   [EnableProblemSeverity] [bit] NOT NULL CONSTRAINT [DF_Pts_Projects_EnableProblemSeverity] DEFAULT (1),
   [EnableProblemType] [bit] NOT NULL CONSTRAINT [DF_Pts_Projects_EnableProblemType] DEFAULT (1),
   [EnableProblemCatalog] [bit] NOT NULL CONSTRAINT [DF_Pts_Projects_EnableProblemCatalog] DEFAULT (1),
   [EnableProblemDeadline] [bit] NOT NULL CONSTRAINT [DF_Pts_Projects_EnableProblemDeadline] DEFAULT (1),
   [VisibleToAll] [bit] NOT NULL CONSTRAINT [DF_Pts_Projects_VisibleToAll] DEFAULT (1),
   [EnableStateTimer] [bit] NOT NULL CONSTRAINT [DF_Pts_Projects_EnableStateTimer] DEFAULT (1),
   [AutoAssignedTo] [int] NULL CONSTRAINT [DF_Pts_Projects_AutoAssignedTo] DEFAULT (1),
   [OpenProblems] [int] NOT NULL CONSTRAINT [DF__Pts_Proje__OpenP__3DE82FB7] DEFAULT (0),
   [NewProblemIndex] [int] NOT NULL CONSTRAINT [DF_Pts_Projects_NewProblemIndex] DEFAULT (1),
   [ExtendedSettings] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [SecurityLevel] [int] NOT NULL CONSTRAINT [DF_Pts_Projects_SecurityLevel] DEFAULT ((2)),
   [KeyWords] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL
)
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Pts_Projects] ON
GO



IF 1 = 1
   INSERT INTO [tmp_Pts_Projects] ([ProjectID], [ProjectCatalogID], [ProjectCode], [Name], [ShortName], [Description], [ProjectStateID], [TotalProblems], [TotalThreads], [TotalRecords], [DateCreated], [ProblemTitle], [ThreadTitle], [RecordTitle], [OnlyViewOwnProblem], [EnableProblemState], [EnableMultipleThread], [EnableEmailNotify], [EnableProblemPriority], [EnableProblemSeverity], [EnableProblemType], [EnableProblemCatalog], [EnableProblemDeadline], [VisibleToAll], [EnableStateTimer], [AutoAssignedTo], [OpenProblems], [NewProblemIndex], [ExtendedSettings], [KeyWords])
   SELECT [ProjectID], [ProjectCatalogID], [ProjectCode], [Name], [ShortName], [Description], [ProjectStateID], [TotalProblems], [TotalThreads], [TotalRecords], [DateCreated], [ProblemTitle], [ThreadTitle], [RecordTitle], [OnlyViewOwnProblem], [EnableProblemState], [EnableMultipleThread], [EnableEmailNotify], [EnableProblemPriority], [EnableProblemSeverity], [EnableProblemType], [EnableProblemCatalog], [EnableProblemDeadline], [VisibleToAll], [EnableStateTimer], [AutoAssignedTo], [OpenProblems], [NewProblemIndex], NULL, NULL
   FROM [Pts_Projects]
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Pts_Projects] OFF
GO



IF 1 = 1
   DROP TABLE [Pts_Projects]
GO

sp_rename N'[tmp_Pts_Projects]', N'Pts_Projects'



IF 1 = 1
   ALTER TABLE [Pts_Projects] ADD CONSTRAINT [PK_Pts_Projects] PRIMARY KEY CLUSTERED ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_Projects Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_Projects Table'
END
GO


--
-- Script To Update Pts_ProblemCatalogs Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemCatalogs Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemCatalogs_Pts_Projects')
      ALTER TABLE [Pts_ProblemCatalogs] DROP CONSTRAINT [FK_Pts_ProblemCatalogs_Pts_Projects]
GO



IF 1 = 1
   ALTER TABLE [Pts_ProblemCatalogs]
      ADD [ResponseUser] [int] NULL
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemCatalogs Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemCatalogs Table'
END
GO


--
-- Script To Update Pts_ProblemPriority Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemPriority Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemPriority_Pts_Projects')
      ALTER TABLE [Pts_ProblemPriority] DROP CONSTRAINT [FK_Pts_ProblemPriority_Pts_Projects]
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemPriority Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemPriority Table'
END
GO


--
-- Script To Update Pts_ProblemSeverity Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemSeverity Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemSeverities_Pts_Projects')
      ALTER TABLE [Pts_ProblemSeverity] DROP CONSTRAINT [FK_Pts_ProblemSeverities_Pts_Projects]
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemSeverity Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemSeverity Table'
END
GO


--
-- Script To Update Pts_ProblemState Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemState Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemState')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Pts_ProblemState]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemStateHistory_Pts_ProblemState')
      ALTER TABLE [Pts_ProblemStateRecord] DROP CONSTRAINT [FK_Pts_ProblemStateHistory_Pts_ProblemState]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_StateTimeLimit_Pts_ProblemState')
      ALTER TABLE [Pts_ProblemStateTimeLimit] DROP CONSTRAINT [FK_Pts_StateTimeLimit_Pts_ProblemState]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemStateTransfer_Pts_ProblemState')
      ALTER TABLE [Pts_ProblemStateTransfer] DROP CONSTRAINT [FK_Pts_ProblemStateTransfer_Pts_ProblemState]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemStateTransfer_Pts_ProblemState1')
      ALTER TABLE [Pts_ProblemStateTransfer] DROP CONSTRAINT [FK_Pts_ProblemStateTransfer_Pts_ProblemState1]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemState_Pts_Projects')
      ALTER TABLE [Pts_ProblemState] DROP CONSTRAINT [FK_Pts_ProblemState_Pts_Projects]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_ProblemState_ListOrder')
      ALTER TABLE [Pts_ProblemState] DROP CONSTRAINT [DF_Pts_ProblemState_ListOrder]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_ProblemState_IsFinalState')
      ALTER TABLE [Pts_ProblemState] DROP CONSTRAINT [DF_Pts_ProblemState_IsFinalState]
GO



IF 1 = 1
   CREATE TABLE [tmp_Pts_ProblemState] (
   [ProblemStateID] [int] IDENTITY (1, 1) NOT NULL,
   [ProjectID] [int] NOT NULL,
   [StateName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [Description] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [ListOrder] [int] NOT NULL CONSTRAINT [DF_Pts_ProblemState_ListOrder] DEFAULT ((100000)),
   [IsFinalState] [bit] NOT NULL CONSTRAINT [DF_Pts_ProblemState_IsFinalState] DEFAULT ((0)),
   [AssignType] [int] NOT NULL CONSTRAINT [DF_Pts_ProblemState_AssignType] DEFAULT ((0)),
   [Assignee] [int] NULL,
   [SelectableAssigneeWorkgroupIDs] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NULL,
   [SelectableAssigneeUserIDs] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NULL,
   [OldID] [int] NULL,
   [ExtendedSettings] [ntext] COLLATE Chinese_PRC_CI_AS NULL
)
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Pts_ProblemState] ON
GO



IF 1 = 1
   INSERT INTO [tmp_Pts_ProblemState] ([ProblemStateID], [ProjectID], [StateName], [Description], [ListOrder], [IsFinalState], [Assignee], [SelectableAssigneeWorkgroupIDs], [SelectableAssigneeUserIDs], [OldID], [ExtendedSettings])
   SELECT [ProblemStateID], [ProjectID], [StateName], [Description], [ListOrder], [IsFinalState], NULL, NULL, NULL, [OldID], NULL
   FROM [Pts_ProblemState]
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Pts_ProblemState] OFF
GO



IF 1 = 1
   DROP TABLE [Pts_ProblemState]
GO

sp_rename N'[tmp_Pts_ProblemState]', N'Pts_ProblemState'



IF 1 = 1
   ALTER TABLE [Pts_ProblemState] ADD CONSTRAINT [PK_Pts_ProblemState] PRIMARY KEY CLUSTERED ([ProblemStateID])
GO







IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemState Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemState Table'
END
GO


--
-- Script To Update Pts_ProblemType Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemType Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemType_Pts_Projects')
      ALTER TABLE [Pts_ProblemType] DROP CONSTRAINT [FK_Pts_ProblemType_Pts_Projects]
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemType Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemType Table'
END
GO


--
-- Script To Update Pts_Problems Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_Problems Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemAttachments_Pts_Problems')
      ALTER TABLE [Pts_ProblemAttachments] DROP CONSTRAINT [FK_Pts_ProblemAttachments_Pts_Problems]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemRelations_Pts_Problems')
      ALTER TABLE [Pts_ProblemRelations] DROP CONSTRAINT [FK_Pts_ProblemRelations_Pts_Problems]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemRelations_Pts_Problems1')
      ALTER TABLE [Pts_ProblemRelations] DROP CONSTRAINT [FK_Pts_ProblemRelations_Pts_Problems1]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemStateHistory_Pts_Problems')
      ALTER TABLE [Pts_ProblemStateRecord] DROP CONSTRAINT [FK_Pts_ProblemStateHistory_Pts_Problems]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Records_Pts_Problems')
      ALTER TABLE [Pts_Records] DROP CONSTRAINT [FK_Pts_Records_Pts_Problems]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Accounts_Users')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Accounts_Users]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Accounts_Users1')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Accounts_Users1]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemCatalogs')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Pts_ProblemCatalogs]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemPriority')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Pts_ProblemPriority]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemSeverities')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Pts_ProblemSeverities]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemState')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Pts_ProblemState]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemType')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Pts_ProblemType]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_Projects')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Pts_Projects]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_Projects1')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [FK_Pts_Problems_Pts_Projects1]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Problems_OriginProjectID')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [DF_Pts_Problems_OriginProjectID]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Problems_ProblemIndex')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [DF_Pts_Problems_ProblemIndex]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Problems_CreateTime')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [DF_Pts_Problems_CreateTime]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Problems_RecordNum')
      ALTER TABLE [Pts_Problems] DROP CONSTRAINT [DF_Pts_Problems_RecordNum]
GO



IF 1 = 1
   CREATE TABLE [tmp_Pts_Problems] (
   [ProblemID] [int] IDENTITY (1, 1) NOT NULL,
   [ProjectID] [int] NOT NULL,
   [OriginProjectID] [int] NOT NULL CONSTRAINT [DF_Pts_Problems_OriginProjectID] DEFAULT ((0)),
   [ProblemIndex] [int] NOT NULL CONSTRAINT [DF_Pts_Problems_ProblemIndex] DEFAULT ((1)),
   [ProblemCatalogID] [int] NULL,
   [ProblemTypeID] [int] NULL,
   [ProblemStateID] [int] NULL,
   [ProblemSeverityID] [int] NULL,
   [ProblemPriorityID] [int] NULL,
   [CreateTime] [datetime] NOT NULL CONSTRAINT [DF_Pts_Problems_CreateTime] DEFAULT (getdate()),
   [CloseTime] [datetime] NULL,
   [CreateUserID] [int] NOT NULL,
   [Deadline] [datetime] NULL,
   [AssignedTo] [int] NULL,
   [Title] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [RecordNum] [smallint] NOT NULL CONSTRAINT [DF_Pts_Problems_RecordNum] DEFAULT ((0)),
   [LastUser] [int] NULL,
   [LastTime] [datetime] NULL,
   [LastRecord] [int] NULL,
   [HistoryID] [int] NULL,
   [Int1] [int] NULL,
   [Int2] [int] NULL,
   [Int3] [int] NULL,
   [Int4] [int] NULL,
   [Int5] [int] NULL,
   [Float1] [float] NULL,
   [Float2] [float] NULL,
   [Float3] [float] NULL,
   [Float4] [float] NULL,
   [Float5] [float] NULL,
   [Date1] [datetime] NULL,
   [Date2] [datetime] NULL,
   [Date3] [datetime] NULL,
   [Date4] [datetime] NULL,
   [Date5] [datetime] NULL,
   [Date6] [datetime] NULL,
   [Date7] [datetime] NULL,
   [Date8] [datetime] NULL,
   [Date9] [datetime] NULL,
   [Date10] [datetime] NULL,
   [BigText1] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText2] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText3] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText4] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText5] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [Text1] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text2] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text3] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text4] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text5] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Select1] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select2] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select3] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select4] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select5] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select6] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select7] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select8] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select9] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select10] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [YesNo1] [bit] NULL,
   [YesNo2] [bit] NULL,
   [YesNo3] [bit] NULL,
   [YesNo4] [bit] NULL,
   [YesNo5] [bit] NULL,
   [Url1] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Url2] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Url3] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Url4] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Url5] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [BigText6] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText7] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText8] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText9] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText10] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [Text6] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text7] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text8] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text9] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text10] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text11] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text12] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text13] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text14] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text15] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text16] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text17] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text18] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text19] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Text20] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Select11] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select12] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select13] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select14] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select15] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Email1] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Email2] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Email3] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Email4] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Email5] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect1] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect2] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect3] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect4] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect5] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [ArticleID] [int] NULL,
   [StartTime] [datetime] NULL,
   [Int6] [int] NULL,
   [Int7] [int] NULL,
   [Int8] [int] NULL,
   [Int9] [int] NULL,
   [Int10] [int] NULL,
   [Int11] [int] NULL,
   [Int12] [int] NULL,
   [Int13] [int] NULL,
   [Int14] [int] NULL,
   [Int15] [int] NULL,
   [Int16] [int] NULL,
   [Int17] [int] NULL,
   [Int18] [int] NULL,
   [Int19] [int] NULL,
   [Int20] [int] NULL,
   [Float6] [float] NULL,
   [Float7] [float] NULL,
   [Float8] [float] NULL,
   [Float9] [float] NULL,
   [Float10] [float] NULL,
   [Float11] [float] NULL,
   [Float12] [float] NULL,
   [Float13] [float] NULL,
   [Float14] [float] NULL,
   [Float15] [float] NULL,
   [Float16] [float] NULL,
   [Float17] [float] NULL,
   [Float18] [float] NULL,
   [Float19] [float] NULL,
   [Float20] [float] NULL,
   [Date11] [datetime] NULL,
   [Date12] [datetime] NULL,
   [Date13] [datetime] NULL,
   [Date14] [datetime] NULL,
   [Date15] [datetime] NULL,
   [Date16] [datetime] NULL,
   [Date17] [datetime] NULL,
   [Date18] [datetime] NULL,
   [Date19] [datetime] NULL,
   [Date20] [datetime] NULL,
   [BigText11] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText12] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText13] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText14] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText15] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText16] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText17] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText18] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText19] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [BigText20] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [Select16] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select17] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select18] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select19] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Select20] [nvarchar] (80) COLLATE Chinese_PRC_CI_AS NULL,
   [Email6] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Email7] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Email8] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Email9] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Email10] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect6] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect7] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect8] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect9] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect10] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [YesNo6] [bit] NULL,
   [YesNo7] [bit] NULL,
   [YesNo8] [bit] NULL,
   [YesNo9] [bit] NULL,
   [YesNo10] [bit] NULL,
   [YesNo11] [bit] NULL,
   [YesNo12] [bit] NULL,
   [YesNo13] [bit] NULL,
   [YesNo14] [bit] NULL,
   [YesNo15] [bit] NULL,
   [YesNo16] [bit] NULL,
   [YesNo17] [bit] NULL,
   [YesNo18] [bit] NULL,
   [YesNo19] [bit] NULL,
   [YesNo20] [bit] NULL,
   [Url6] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Url7] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Url8] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Url9] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [Url10] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect11] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect12] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect13] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect14] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect15] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect16] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect17] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect18] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect19] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [MultiSelect20] [nvarchar] (2048) COLLATE Chinese_PRC_CI_AS NULL,
   [ReadByAssignee] [bit] NOT NULL CONSTRAINT [DF_Pts_Problems_ReadByAssignee] DEFAULT ((0)),
   [AssigneeReadTime] [datetime] NULL
)
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Pts_Problems] ON
GO



IF 1 = 1
   INSERT INTO [tmp_Pts_Problems] ([ProblemID], [ProjectID], [OriginProjectID], [ProblemIndex], [ProblemCatalogID], [ProblemTypeID], [ProblemStateID], [ProblemSeverityID], [ProblemPriorityID], [CreateTime], [CloseTime], [CreateUserID], [Deadline], [AssignedTo], [Title], [Description], [RecordNum], [LastUser], [LastTime], [LastRecord], [HistoryID], [Int1], [Int2], [Int3], [Int4], [Int5], [Float1], [Float2], [Float3], [Float4], [Float5], [Date1], [Date2], [Date3], [Date4], [Date5], [Date6], [Date7], [Date8], [Date9], [Date10], [BigText1], [BigText2], [BigText3], [BigText4], [BigText5], [Text1], [Text2], [Text3], [Text4], [Text5], [Select1], [Select2], [Select3], [Select4], [Select5], [Select6], [Select7], [Select8], [Select9], [Select10], [YesNo1], [YesNo2], [YesNo3], [YesNo4], [YesNo5], [Url1], [Url2], [Url3], [Url4], [Url5], [BigText6], [BigText7], [BigText8], [BigText9], [BigText10], [Text6], [Text7], [Text8], [Text9], [Text10], [Text11], [Text12], [Text13], [Text14], [Text15], [Text16], [Text17], [Text18], [Text19], [Text20], [Select11], [Select12], [Select13], [Select14], [Select15], [Email1], [Email2], [Email3], [Email4], [Email5], [MultiSelect1], [MultiSelect2], [MultiSelect3], [MultiSelect4], [MultiSelect5], [ArticleID], [StartTime], [Int6], [Int7], [Int8], [Int9], [Int10], [Int11], [Int12], [Int13], [Int14], [Int15], [Int16], [Int17], [Int18], [Int19], [Int20], [Float6], [Float7], [Float8], [Float9], [Float10], [Float11], [Float12], [Float13], [Float14], [Float15], [Float16], [Float17], [Float18], [Float19], [Float20], [Date11], [Date12], [Date13], [Date14], [Date15], [Date16], [Date17], [Date18], [Date19], [Date20], [BigText11], [BigText12], [BigText13], [BigText14], [BigText15], [BigText16], [BigText17], [BigText18], [BigText19], [BigText20], [Select16], [Select17], [Select18], [Select19], [Select20], [Email6], [Email7], [Email8], [Email9], [Email10], [MultiSelect6], [MultiSelect7], [MultiSelect8], [MultiSelect9], [MultiSelect10], [YesNo6], [YesNo7], [YesNo8], [YesNo9], [YesNo10], [YesNo11], [YesNo12], [YesNo13], [YesNo14], [YesNo15], [YesNo16], [YesNo17], [YesNo18], [YesNo19], [YesNo20], [Url6], [Url7], [Url8], [Url9], [Url10], [MultiSelect11], [MultiSelect12], [MultiSelect13], [MultiSelect14], [MultiSelect15], [MultiSelect16], [MultiSelect17], [MultiSelect18], [MultiSelect19], [MultiSelect20], [AssigneeReadTime])
   SELECT [ProblemID], [ProjectID], [OriginProjectID], [ProblemIndex], [ProblemCatalogID], [ProblemTypeID], [ProblemStateID], [ProblemSeverityID], [ProblemPriorityID], [CreateTime], [CloseTime], [CreateUserID], [Deadline], [AssignedTo], [Title], [Description], [RecordNum], [LastUser], [LastTime], [LastRecord], [HistoryID], [Int1], [Int2], [Int3], [Int4], [Int5], [Float1], [Float2], [Float3], [Float4], [Float5], [Date1], [Date2], [Date3], [Date4], [Date5], [Date6], [Date7], [Date8], [Date9], [Date10], [BigText1], [BigText2], [BigText3], [BigText4], [BigText5], [Text1], [Text2], [Text3], [Text4], [Text5], [Select1], [Select2], [Select3], [Select4], [Select5], [Select6], [Select7], [Select8], [Select9], [Select10], [YesNo1], [YesNo2], [YesNo3], [YesNo4], [YesNo5], [Url1], [Url2], [Url3], [Url4], [Url5], [BigText6], [BigText7], [BigText8], [BigText9], [BigText10], [Text6], [Text7], [Text8], [Text9], [Text10], [Text11], [Text12], [Text13], [Text14], [Text15], [Text16], [Text17], [Text18], [Text19], [Text20], [Select11], [Select12], [Select13], [Select14], [Select15], [Email1], [Email2], [Email3], [Email4], [Email5], [MultiSelect1], [MultiSelect2], [MultiSelect3], [MultiSelect4], [MultiSelect5], [ArticleID], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
   FROM [Pts_Problems]
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Pts_Problems] OFF
GO



IF 1 = 1
   DROP TABLE [Pts_Problems]
GO

sp_rename N'[tmp_Pts_Problems]', N'Pts_Problems'



IF 1 = 1
   ALTER TABLE [Pts_Problems] ADD CONSTRAINT [PK_Pts_Problems] PRIMARY KEY CLUSTERED ([ProblemID])
GO



IF 1 = 1
   CREATE INDEX [IX_Pts_Problems] ON [Pts_Problems] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_Problems Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_Problems Table'
END
GO


--
-- Script To Update Pts_ProblemAttachments Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemAttachments Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemAttachments_Pts_Problems')
      ALTER TABLE [Pts_ProblemAttachments] DROP CONSTRAINT [FK_Pts_ProblemAttachments_Pts_Problems]
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemAttachments Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemAttachments Table'
END
GO


--
-- Script To Create Pts_ProblemCreateRoles Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_ProblemCreateRoles Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_ProblemCreateRoles] (
   [ID] [int] IDENTITY (1, 1) NOT NULL,
   [ProjectID] [int] NOT NULL,
   [DstStateID] [int] NOT NULL,
   [Description] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NULL,
   [AssignType] [int] NOT NULL,
   [Assignee] [int] NULL,
   [SelectableAssigneeWorkgroupIDs] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NULL,
   [SelectableAssigneeUserIDs] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NULL
)
GO



IF 1 = 1
   ALTER TABLE [Pts_ProblemCreateRoles] ADD CONSTRAINT [PK_Pts_ProblemCreateRoles] PRIMARY KEY CLUSTERED ([ID])
GO





IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemCreateRoles Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_ProblemCreateRoles Table'
END
GO


--
-- Script To Create Pts_ProblemFieldEditableState Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_ProblemFieldEditableState Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_ProblemFieldEditableState] (
   [ID] [int] IDENTITY (1, 1) NOT NULL,
   [FieldID] [int] NOT NULL,
   [FromStateID] [int] NOT NULL,
   [ToStateID] [int] NOT NULL
)
GO



IF 1 = 1
   ALTER TABLE [Pts_ProblemFieldEditableState] ADD CONSTRAINT [PK_Pts_ProblemFieldEditableState] PRIMARY KEY CLUSTERED ([ID])
GO




IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemFieldEditableState Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_ProblemFieldEditableState Table'
END
GO


--
-- Script To Create Pts_ProblemFieldEditableWorkgroup Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_ProblemFieldEditableWorkgroup Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_ProblemFieldEditableWorkgroup] (
   [ID] [int] IDENTITY (1, 1) NOT NULL,
   [FieldID] [int] NOT NULL,
   [WorkgroupID] [int] NOT NULL
)
GO



IF 1 = 1
   ALTER TABLE [Pts_ProblemFieldEditableWorkgroup] ADD CONSTRAINT [PK_Pts_ProblemFieldEditableGroup] PRIMARY KEY CLUSTERED ([ID])
GO







IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemFieldEditableWorkgroup Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_ProblemFieldEditableWorkgroup Table'
END
GO


--
-- Script To Create Pts_ProblemFieldReadableWorkgroup Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_ProblemFieldReadableWorkgroup Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_ProblemFieldReadableWorkgroup] (
   [ID] [int] IDENTITY (1, 1) NOT NULL,
   [FieldID] [int] NOT NULL,
   [WorkgroupID] [int] NOT NULL
)
GO



IF 1 = 1
   ALTER TABLE [Pts_ProblemFieldReadableWorkgroup] ADD CONSTRAINT [PK_Pts_ProblemFieldReadableGroup] PRIMARY KEY CLUSTERED ([ID])
GO






IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemFieldReadableWorkgroup Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_ProblemFieldReadableWorkgroup Table'
END
GO


--
-- Script To Update Pts_ProblemHistory Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemHistory Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemHistory Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemHistory Table'
END
GO


--
-- Script To Update Pts_ProblemInitStateWorkgroup Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemInitStateWorkgroup Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemInitStateWorkgroup Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemInitStateWorkgroup Table'
END
GO


--
-- Script To Create Pts_ProblemRelatedArticles Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_ProblemRelatedArticles Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_ProblemRelatedArticles] (
   [ProblemID] [int] NOT NULL,
   [ArticleID] [int] NOT NULL
)
GO



IF 1 = 1
   CREATE INDEX [IX_Pts_ProblemRelateArticles] ON [Pts_ProblemRelatedArticles] ([ProblemID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemRelatedArticles Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_ProblemRelatedArticles Table'
END
GO

--
-- Script To Update Pts_ProblemRelations Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemRelations Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemRelations_Pts_Problems')
      ALTER TABLE [Pts_ProblemRelations] DROP CONSTRAINT [FK_Pts_ProblemRelations_Pts_Problems]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemRelations_Pts_Problems1')
      ALTER TABLE [Pts_ProblemRelations] DROP CONSTRAINT [FK_Pts_ProblemRelations_Pts_Problems1]
GO



IF 1 = 1
   CREATE TABLE [tmp_Pts_ProblemRelations] (
   [ProblemID_1] [int] NOT NULL,
   [ProblemID_2] [int] NOT NULL,
   [RelationType] [int] NOT NULL
)
GO



IF 1 = 1
   INSERT INTO [tmp_Pts_ProblemRelations] ([ProblemID_1], [ProblemID_2], [RelationType])
   SELECT [ProblemID_1], [ProblemID_2], 0
   FROM [Pts_ProblemRelations]
GO



IF 1 = 1
   DROP TABLE [Pts_ProblemRelations]
GO

sp_rename N'[tmp_Pts_ProblemRelations]', N'Pts_ProblemRelations'



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemRelations Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemRelations Table'
END
GO


--
-- Script To Update Pts_ProblemStateRecord Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemStateRecord Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemStateHistory_Pts_Problems')
      ALTER TABLE [Pts_ProblemStateRecord] DROP CONSTRAINT [FK_Pts_ProblemStateHistory_Pts_Problems]
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemStateRecord Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemStateRecord Table'
END
GO


--
-- Script To Create Pts_ProblemTimers Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_ProblemTimers Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_ProblemTimers] (
   [ProblemTimerID] [int] IDENTITY (1, 1) NOT NULL,
   [ProblemID] [int] NOT NULL,
   [CreateTime] [datetime] NOT NULL,
   [ExpireTime] [datetime] NOT NULL,
   [IsExecuted] [bit] NOT NULL CONSTRAINT [DF_Pts_ProblemTimers_IsExecuted] DEFAULT ((0)),
   [ExecuteTime] [datetime] NULL,
   [IsExecuteOK] [bit] NULL,
   [ExecuteMessage] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [TimerConfig] [ntext] COLLATE Chinese_PRC_CI_AS NOT NULL
)
GO



IF 1 = 1
   ALTER TABLE [Pts_ProblemTimers] ADD CONSTRAINT [PK_Pts_ProblemTimers] PRIMARY KEY CLUSTERED ([ProblemTimerID])
GO



IF 1 = 1
   CREATE INDEX [IX_Pts_ProblemTimers] ON [Pts_ProblemTimers] ([ProblemID])
GO



IF 1 = 1
   CREATE INDEX [IX_Pts_ProblemTimers_1] ON [Pts_ProblemTimers] ([ExpireTime])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemTimers Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_ProblemTimers Table'
END
GO

--
-- Script To Create Pts_ProblemTimerSettings Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_ProblemTimerSettings Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_ProblemTimerSettings] (
   [ProblemTimerSettingID] [int] IDENTITY (1, 1) NOT NULL,
   [ProjectID] [int] NOT NULL,
   [Title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [Config] [ntext] COLLATE Chinese_PRC_CI_AS NULL
)
GO



IF 1 = 1
   ALTER TABLE [Pts_ProblemTimerSettings] ADD CONSTRAINT [PK_Pts_ProblemTimerSettings] PRIMARY KEY CLUSTERED ([ProblemTimerSettingID])
GO



IF 1 = 1
   CREATE INDEX [IX_Pts_ProblemTimerSettings] ON [Pts_ProblemTimerSettings] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemTimerSettings Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_ProblemTimerSettings Table'
END
GO

--
-- Script To Update Pts_RecordType Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_RecordType Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_RecordType_Pts_Projects')
      ALTER TABLE [Pts_RecordType] DROP CONSTRAINT [FK_Pts_RecordType_Pts_Projects]
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_RecordType Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_RecordType Table'
END
GO


--
-- Script To Update Pts_Records Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_Records Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_RecordAttachments_Pts_Records')
      ALTER TABLE [Pts_RecordAttachments] DROP CONSTRAINT [FK_Pts_RecordAttachments_Pts_Records]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Records_Accounts_Users')
      ALTER TABLE [Pts_Records] DROP CONSTRAINT [FK_Pts_Records_Accounts_Users]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Records_Accounts_Users1')
      ALTER TABLE [Pts_Records] DROP CONSTRAINT [FK_Pts_Records_Accounts_Users1]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Records_Pts_Problems')
      ALTER TABLE [Pts_Records] DROP CONSTRAINT [FK_Pts_Records_Pts_Problems]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Records_Pts_RecordType')
      ALTER TABLE [Pts_Records] DROP CONSTRAINT [FK_Pts_Records_Pts_RecordType]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF_Pts_Records_DateCreated')
      ALTER TABLE [Pts_Records] DROP CONSTRAINT [DF_Pts_Records_DateCreated]
GO



IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'DF__Pts_Recor__State__3EDC53F0')
      ALTER TABLE [Pts_Records] DROP CONSTRAINT [DF__Pts_Recor__State__3EDC53F0]
GO



IF 1 = 1
   CREATE TABLE [tmp_Pts_Records] (
   [RecordID] [int] IDENTITY (1, 1) NOT NULL,
   [ProblemID] [int] NOT NULL,
   [CreateUser] [int] NOT NULL,
   [DateCreated] [smalldatetime] NOT NULL CONSTRAINT [DF_Pts_Records_DateCreated] DEFAULT (getdate()),
   [IsKeyRecord] [bit] NOT NULL,
   [RecordType] [int] NULL,
   [AssignTo] [int] NULL,
   [Title] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [Content] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [StateID] [int] NOT NULL CONSTRAINT [DF__Pts_Recor__State__3EDC53F0] DEFAULT (0),
   [HistoryID] [int] NULL,
   [RecordClass] [int] NOT NULL CONSTRAINT [DF_Pts_Records_Type] DEFAULT ((0)),
   [SrcStateID] [int] NULL,
   [SrcUserID] [int] NULL
)
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Pts_Records] ON
GO



IF 1 = 1
   INSERT INTO [tmp_Pts_Records] ([RecordID], [ProblemID], [CreateUser], [DateCreated], [IsKeyRecord], [RecordType], [AssignTo], [Title], [Content], [StateID], [HistoryID], [SrcStateID], [SrcUserID])
   SELECT [RecordID], [ProblemID], [CreateUser], [DateCreated], [IsKeyRecord], [RecordType], [AssignTo], [Title], [Content], [StateID], [HistoryID], NULL, NULL
   FROM [Pts_Records]
GO



IF 1 = 1
   SET IDENTITY_INSERT [tmp_Pts_Records] OFF
GO



IF 1 = 1
   DROP TABLE [Pts_Records]
GO

sp_rename N'[tmp_Pts_Records]', N'Pts_Records'



IF 1 = 1
   ALTER TABLE [Pts_Records] ADD CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED ([RecordID])
GO



IF 1 = 1
   CREATE INDEX [IX_Pts_Records] ON [Pts_Records] ([ProblemID])
GO







IF 1 = 1
BEGIN
   PRINT 'Pts_Records Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_Records Table'
END
GO


--
-- Script To Update Pts_RecordAttachments Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_RecordAttachments Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_RecordAttachments_Pts_Records')
      ALTER TABLE [Pts_RecordAttachments] DROP CONSTRAINT [FK_Pts_RecordAttachments_Pts_Records]
GO



IF 1 = 1
   ALTER TABLE [Pts_RecordAttachments]
      ALTER COLUMN [OriginName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL
GO



IF 1 = 1
   ALTER TABLE [Pts_RecordAttachments]
      ALTER COLUMN [SaveName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_RecordAttachments Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_RecordAttachments Table'
END
GO


--
-- Script To Create Pts_RelatedUsers Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_RelatedUsers Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_RelatedUsers] (
   [ProblemID] [int] NOT NULL,
   [UserID] [int] NOT NULL
)
GO



IF 1 = 1
   ALTER TABLE [Pts_RelatedUsers] ADD CONSTRAINT [PK_Pts_RelatedUsers] PRIMARY KEY CLUSTERED ([ProblemID], [UserID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_RelatedUsers Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_RelatedUsers Table'
END
GO

--
-- Script To Create Pts_SharedItems Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_SharedItems Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_SharedItems] (
   [ItemID] [int] IDENTITY (1, 1) NOT NULL,
   [ProjectID] [int] NOT NULL,
   [Title] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [Type] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL,
   [KeyWords] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [CreateDate] [datetime] NULL,
   [CreateUser] [int] NULL,
   [UpdateDate] [datetime] NULL,
   [Options] [int] NULL
)
GO



IF 1 = 1
   ALTER TABLE [Pts_SharedItems] ADD CONSTRAINT [PK_Pts_SharedItems] PRIMARY KEY CLUSTERED ([ItemID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_SharedItems Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_SharedItems Table'
END
GO


--
-- Script To Create Pts_SharedItemAttachments Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_SharedItemAttachments Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_SharedItemAttachments] (
   [AttachmentID] [int] IDENTITY (1, 1) NOT NULL,
   [ItemID] [int] NOT NULL,
   [SaveName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [OriginName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [FileSize] [int] NULL,
   [Description] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
   [CreateDate] [datetime] NULL,
   [CreateUser] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL
)
GO



IF 1 = 1
   ALTER TABLE [Pts_SharedItemAttachments] ADD CONSTRAINT [PK_Pts_SharedItemAttachments] PRIMARY KEY CLUSTERED ([AttachmentID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_SharedItemAttachments Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_SharedItemAttachments Table'
END
GO


--
-- Script To Create Pts_Subscription Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_Subscription Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_Subscription] (
   [SubscribeID] [int] IDENTITY (1, 1) NOT NULL,
   [UserID] [int] NOT NULL,
   [TargetType] [int] NOT NULL,
   [TargetID] [int] NOT NULL
)
GO



IF 1 = 1
   ALTER TABLE [Pts_Subscription] ADD CONSTRAINT [PK_Pts_Subscribe] PRIMARY KEY CLUSTERED ([SubscribeID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_Subscription Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_Subscription Table'
END
GO

--
-- Script To Create Pts_WorkflowSteps Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_WorkflowSteps Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO

CREATE TABLE [Pts_WorkflowSteps] (
   [StepID] [int] IDENTITY (1, 1) NOT NULL,
   [ProjectID] [int] NOT NULL,
   [SrcStateID] [int] NOT NULL,
   [DstStateID] [int] NOT NULL,
   [StepName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL,
   [Description] [ntext] COLLATE Chinese_PRC_CI_AS NULL,
   [AssignType] [int] NOT NULL,
   [Assignee] [int] NULL,
   [SelectableAssigneeWorkgroupIDs] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NULL,
   [SelectableAssigneeUserIDs] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NULL
)
GO



IF 1 = 1
   ALTER TABLE [Pts_WorkflowSteps] ADD CONSTRAINT [PK_Pts_WorkflowSteps] PRIMARY KEY CLUSTERED ([StepID])
GO











IF 1 = 1
BEGIN
   PRINT 'Pts_WorkflowSteps Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_WorkflowSteps Table'
END
GO


--
-- Script To Update Pts_Workgroups Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_Workgroups Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Workgroups_Pts_Projects')
      ALTER TABLE [Pts_Workgroups] DROP CONSTRAINT [FK_Pts_Workgroups_Pts_Projects]
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_Workgroups Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_Workgroups Table'
END
GO


--
-- Script To Update Pts_WorkgroupUsers Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_WorkgroupUsers Table'
GO

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL ON
GO

SET NUMERIC_ROUNDABORT OFF
GO




IF 1 = 1
   IF EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_WorkgroupUsers_Accounts_Users')
      ALTER TABLE [Pts_WorkgroupUsers] DROP CONSTRAINT [FK_Pts_WorkgroupUsers_Accounts_Users]
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_WorkgroupUsers Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_WorkgroupUsers Table'
END
GO


--
-- Script To Update Accounts_Users Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Accounts_Users Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Accounts_Users_Accounts_AccessLists')
      ALTER TABLE [Accounts_Users] ADD CONSTRAINT [FK_Accounts_Users_Accounts_AccessLists] FOREIGN KEY ([AccessListID]) REFERENCES [Accounts_AccessLists] ([AccessListID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Accounts_Users_Accounts_UserState')
      ALTER TABLE [Accounts_Users] ADD CONSTRAINT [FK_Accounts_Users_Accounts_UserState] FOREIGN KEY ([UserState]) REFERENCES [Accounts_UserState] ([UserStateID])
GO



IF 1 = 1
BEGIN
   PRINT 'Accounts_Users Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Accounts_Users Table'
END
GO


--
-- Script To Update Accounts_UserRoles Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Accounts_UserRoles Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Accounts_UserRoles_Accounts_Users')
      ALTER TABLE [Accounts_UserRoles] WITH NOCHECK ADD CONSTRAINT [FK_Accounts_UserRoles_Accounts_Users] FOREIGN KEY ([UserID]) REFERENCES [Accounts_Users] ([UserID])
GO



IF 1 = 1
BEGIN
   PRINT 'Accounts_UserRoles Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Accounts_UserRoles Table'
END
GO


--
-- Script To Update Kb_ArticleAttachments Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Kb_ArticleAttachments Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Kb_ArticleAttachments_Kb_Articles')
      ALTER TABLE [Kb_ArticleAttachments] ADD CONSTRAINT [FK_Kb_ArticleAttachments_Kb_Articles] FOREIGN KEY ([ArticleID]) REFERENCES [Kb_Articles] ([ArticleID]) ON DELETE CASCADE
GO



IF 1 = 1
BEGIN
   PRINT 'Kb_ArticleAttachments Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Kb_ArticleAttachments Table'
END
GO


--
-- Script To Update Kb_ArticleComment Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Kb_ArticleComment Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Kb_ArticleComment_Kb_Articles')
      ALTER TABLE [Kb_ArticleComment] ADD CONSTRAINT [FK_Kb_ArticleComment_Kb_Articles] FOREIGN KEY ([ArticleID]) REFERENCES [Kb_Articles] ([ArticleID])
GO



IF 1 = 1
BEGIN
   PRINT 'Kb_ArticleComment Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Kb_ArticleComment Table'
END
GO


--
-- Script To Update Pts_DbDirectory Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_DbDirectory Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_DbDirectory_Pts_Projects')
      ALTER TABLE [Pts_DbDirectory] ADD CONSTRAINT [FK_Pts_DbDirectory_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID]) ON DELETE CASCADE
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_DbDirectory Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_DbDirectory Table'
END
GO


--
-- Script To Update Pts_FilterNodes Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_FilterNodes Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_FilterNodes_Pts_Filters')
      ALTER TABLE [Pts_FilterNodes] ADD CONSTRAINT [FK_Pts_FilterNodes_Pts_Filters] FOREIGN KEY ([FilterID]) REFERENCES [Pts_Filters] ([FilterID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_FilterNodes Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_FilterNodes Table'
END
GO


--
-- Script To Update Pts_Filters Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_Filters Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Filters_Pts_Projects')
      ALTER TABLE [Pts_Filters] ADD CONSTRAINT [FK_Pts_Filters_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_Filters Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_Filters Table'
END
GO


--
-- Script To Update Pts_Projects Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_Projects Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Projects_Pts_ProjectCatalogs')
      ALTER TABLE [Pts_Projects] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Projects_Pts_ProjectCatalogs] FOREIGN KEY ([ProjectCatalogID]) REFERENCES [Pts_ProjectCatalogs] ([ProjectCatalogID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Projects_Pts_ProjectStates')
      ALTER TABLE [Pts_Projects] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Projects_Pts_ProjectStates] FOREIGN KEY ([ProjectStateID]) REFERENCES [Pts_ProjectStates] ([ProjectStateID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemCatalogs_Pts_Projects')
      ALTER TABLE [Pts_ProblemCatalogs] ADD CONSTRAINT [FK_Pts_ProblemCatalogs_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemPriority_Pts_Projects')
      ALTER TABLE [Pts_ProblemPriority] ADD CONSTRAINT [FK_Pts_ProblemPriority_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_Projects')
      ALTER TABLE [Pts_Problems] ADD CONSTRAINT [FK_Pts_Problems_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_Projects1')
      ALTER TABLE [Pts_Problems] ADD CONSTRAINT [FK_Pts_Problems_Pts_Projects1] FOREIGN KEY ([OriginProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemSeverities_Pts_Projects')
      ALTER TABLE [Pts_ProblemSeverity] ADD CONSTRAINT [FK_Pts_ProblemSeverities_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemState_Pts_Projects')
      ALTER TABLE [Pts_ProblemState] ADD CONSTRAINT [FK_Pts_ProblemState_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemType_Pts_Projects')
      ALTER TABLE [Pts_ProblemType] ADD CONSTRAINT [FK_Pts_ProblemType_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_RecordType_Pts_Projects')
      ALTER TABLE [Pts_RecordType] ADD CONSTRAINT [FK_Pts_RecordType_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Workgroups_Pts_Projects')
      ALTER TABLE [Pts_Workgroups] ADD CONSTRAINT [FK_Pts_Workgroups_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_Projects Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_Projects Table'
END
GO


--
-- Script To Update Pts_ProblemCatalogs Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemCatalogs Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemCatalogs_Pts_Projects')
      ALTER TABLE [Pts_ProblemCatalogs] WITH NOCHECK ADD CONSTRAINT [FK_Pts_ProblemCatalogs_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemCatalogs Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemCatalogs Table'
END
GO


--
-- Script To Update Pts_ProblemPriority Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemPriority Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemPriority_Pts_Projects')
      ALTER TABLE [Pts_ProblemPriority] WITH NOCHECK ADD CONSTRAINT [FK_Pts_ProblemPriority_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemPriority Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemPriority Table'
END
GO


--
-- Script To Update Pts_ProblemSeverity Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemSeverity Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemSeverities_Pts_Projects')
      ALTER TABLE [Pts_ProblemSeverity] WITH NOCHECK ADD CONSTRAINT [FK_Pts_ProblemSeverities_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemSeverity Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemSeverity Table'
END
GO


--
-- Script To Update Pts_ProblemState Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemState Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemState_Pts_Projects')
      ALTER TABLE [Pts_ProblemState] WITH NOCHECK ADD CONSTRAINT [FK_Pts_ProblemState_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemState')
      ALTER TABLE [Pts_Problems] ADD CONSTRAINT [FK_Pts_Problems_Pts_ProblemState] FOREIGN KEY ([ProblemStateID]) REFERENCES [Pts_ProblemState] ([ProblemStateID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemStateHistory_Pts_ProblemState')
      ALTER TABLE [Pts_ProblemStateRecord] ADD CONSTRAINT [FK_Pts_ProblemStateHistory_Pts_ProblemState] FOREIGN KEY ([StateID]) REFERENCES [Pts_ProblemState] ([ProblemStateID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_StateTimeLimit_Pts_ProblemState')
      ALTER TABLE [Pts_ProblemStateTimeLimit] ADD CONSTRAINT [FK_Pts_StateTimeLimit_Pts_ProblemState] FOREIGN KEY ([StateID]) REFERENCES [Pts_ProblemState] ([ProblemStateID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemStateTransfer_Pts_ProblemState')
      ALTER TABLE [Pts_ProblemStateTransfer] ADD CONSTRAINT [FK_Pts_ProblemStateTransfer_Pts_ProblemState] FOREIGN KEY ([FromProblemStateID]) REFERENCES [Pts_ProblemState] ([ProblemStateID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemStateTransfer_Pts_ProblemState1')
      ALTER TABLE [Pts_ProblemStateTransfer] ADD CONSTRAINT [FK_Pts_ProblemStateTransfer_Pts_ProblemState1] FOREIGN KEY ([ToProblemStateID]) REFERENCES [Pts_ProblemState] ([ProblemStateID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemState Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemState Table'
END
GO


--
-- Script To Update Pts_ProblemType Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemType Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemType_Pts_Projects')
      ALTER TABLE [Pts_ProblemType] WITH NOCHECK ADD CONSTRAINT [FK_Pts_ProblemType_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemType Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemType Table'
END
GO


--
-- Script To Update Pts_Problems Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_Problems Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Accounts_Users')
      ALTER TABLE [Pts_Problems] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Problems_Accounts_Users] FOREIGN KEY ([CreateUserID]) REFERENCES [Accounts_Users] ([UserID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemCatalogs')
      ALTER TABLE [Pts_Problems] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Problems_Pts_ProblemCatalogs] FOREIGN KEY ([ProblemCatalogID]) REFERENCES [Pts_ProblemCatalogs] ([ProblemCatalogID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemPriority')
      ALTER TABLE [Pts_Problems] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Problems_Pts_ProblemPriority] FOREIGN KEY ([ProblemPriorityID]) REFERENCES [Pts_ProblemPriority] ([ProblemPriorityID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemSeverities')
      ALTER TABLE [Pts_Problems] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Problems_Pts_ProblemSeverities] FOREIGN KEY ([ProblemSeverityID]) REFERENCES [Pts_ProblemSeverity] ([ProblemSeverityID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemState')
      ALTER TABLE [Pts_Problems] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Problems_Pts_ProblemState] FOREIGN KEY ([ProblemStateID]) REFERENCES [Pts_ProblemState] ([ProblemStateID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_ProblemType')
      ALTER TABLE [Pts_Problems] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Problems_Pts_ProblemType] FOREIGN KEY ([ProblemTypeID]) REFERENCES [Pts_ProblemType] ([ProblemTypeID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_Projects')
      ALTER TABLE [Pts_Problems] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Problems_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Problems_Pts_Projects1')
      ALTER TABLE [Pts_Problems] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Problems_Pts_Projects1] FOREIGN KEY ([OriginProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemAttachments_Pts_Problems')
      ALTER TABLE [Pts_ProblemAttachments] ADD CONSTRAINT [FK_Pts_ProblemAttachments_Pts_Problems] FOREIGN KEY ([ProblemID]) REFERENCES [Pts_Problems] ([ProblemID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemRelations_Pts_Problems')
      ALTER TABLE [Pts_ProblemRelations] ADD CONSTRAINT [FK_Pts_ProblemRelations_Pts_Problems] FOREIGN KEY ([ProblemID_1]) REFERENCES [Pts_Problems] ([ProblemID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemRelations_Pts_Problems1')
      ALTER TABLE [Pts_ProblemRelations] ADD CONSTRAINT [FK_Pts_ProblemRelations_Pts_Problems1] FOREIGN KEY ([ProblemID_2]) REFERENCES [Pts_Problems] ([ProblemID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemStateHistory_Pts_Problems')
      ALTER TABLE [Pts_ProblemStateRecord] ADD CONSTRAINT [FK_Pts_ProblemStateHistory_Pts_Problems] FOREIGN KEY ([ProblemID]) REFERENCES [Pts_Problems] ([ProblemID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Records_Pts_Problems')
      ALTER TABLE [Pts_Records] ADD CONSTRAINT [FK_Pts_Records_Pts_Problems] FOREIGN KEY ([ProblemID]) REFERENCES [Pts_Problems] ([ProblemID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_Problems Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_Problems Table'
END
GO


--
-- Script To Update Pts_ProblemAttachments Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemAttachments Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemAttachments_Pts_Problems')
      ALTER TABLE [Pts_ProblemAttachments] WITH NOCHECK ADD CONSTRAINT [FK_Pts_ProblemAttachments_Pts_Problems] FOREIGN KEY ([ProblemID]) REFERENCES [Pts_Problems] ([ProblemID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemAttachments Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemAttachments Table'
END
GO


--
-- Script To Create Pts_ProblemCreateRoles Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_ProblemCreateRoles Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemCreateRoles_Pts_ProblemState')
      ALTER TABLE [Pts_ProblemCreateRoles] ADD CONSTRAINT [FK_Pts_ProblemCreateRoles_Pts_ProblemState] FOREIGN KEY ([DstStateID]) REFERENCES [Pts_ProblemState] ([ProblemStateID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemCreateRoles_Pts_Projects')
      ALTER TABLE [Pts_ProblemCreateRoles] ADD CONSTRAINT [FK_Pts_ProblemCreateRoles_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemCreateRoles Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_ProblemCreateRoles Table'
END
GO


--
-- Script To Create Pts_ProblemFieldEditableState Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_ProblemFieldEditableState Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemFieldEditableState_Pts_DbDirectory')
      ALTER TABLE [Pts_ProblemFieldEditableState] ADD CONSTRAINT [FK_Pts_ProblemFieldEditableState_Pts_DbDirectory] FOREIGN KEY ([FieldID]) REFERENCES [Pts_DbDirectory] ([ID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemFieldEditableState Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_ProblemFieldEditableState Table'
END
GO


--
-- Script To Create Pts_ProblemFieldEditableWorkgroup Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_ProblemFieldEditableWorkgroup Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemFieldEditableGroup_Pts_DbDirectory')
      ALTER TABLE [Pts_ProblemFieldEditableWorkgroup] ADD CONSTRAINT [FK_Pts_ProblemFieldEditableGroup_Pts_DbDirectory] FOREIGN KEY ([FieldID]) REFERENCES [Pts_DbDirectory] ([ID]) ON DELETE CASCADE
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemFieldEditableGroup_Pts_Workgroups')
      ALTER TABLE [Pts_ProblemFieldEditableWorkgroup] ADD CONSTRAINT [FK_Pts_ProblemFieldEditableGroup_Pts_Workgroups] FOREIGN KEY ([WorkgroupID]) REFERENCES [Pts_Workgroups] ([WorkgroupID]) ON DELETE CASCADE
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemFieldEditableWorkgroup Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_ProblemFieldEditableWorkgroup Table'
END
GO


--
-- Script To Create Pts_ProblemFieldReadableWorkgroup Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_ProblemFieldReadableWorkgroup Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemFieldReadableGroup_Pts_DbDirectory')
      ALTER TABLE [Pts_ProblemFieldReadableWorkgroup] ADD CONSTRAINT [FK_Pts_ProblemFieldReadableGroup_Pts_DbDirectory] FOREIGN KEY ([FieldID]) REFERENCES [Pts_DbDirectory] ([ID]) ON UPDATE CASCADE ON DELETE CASCADE
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemFieldReadableGroup_Pts_Workgroups')
      ALTER TABLE [Pts_ProblemFieldReadableWorkgroup] ADD CONSTRAINT [FK_Pts_ProblemFieldReadableGroup_Pts_Workgroups] FOREIGN KEY ([WorkgroupID]) REFERENCES [Pts_Workgroups] ([WorkgroupID]) ON UPDATE CASCADE ON DELETE CASCADE
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemFieldReadableWorkgroup Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_ProblemFieldReadableWorkgroup Table'
END
GO


--
-- Script To Update Pts_ProblemHistory Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemHistory Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemHistory_Pts_Problems')
      ALTER TABLE [Pts_ProblemHistory] WITH NOCHECK ADD CONSTRAINT [FK_Pts_ProblemHistory_Pts_Problems] FOREIGN KEY ([ProblemID]) REFERENCES [Pts_Problems] ([ProblemID]) ON DELETE CASCADE
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemHistory Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemHistory Table'
END
GO


--
-- Script To Update Pts_ProblemInitStateWorkgroup Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemInitStateWorkgroup Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemInitStateWorkgroup_Pts_ProblemState')
      ALTER TABLE [Pts_ProblemInitStateWorkgroup] ADD CONSTRAINT [FK_Pts_ProblemInitStateWorkgroup_Pts_ProblemState] FOREIGN KEY ([ProblemStateID]) REFERENCES [Pts_ProblemState] ([ProblemStateID]) ON DELETE CASCADE
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemInitStateWorkgroup_Pts_Workgroups')
      ALTER TABLE [Pts_ProblemInitStateWorkgroup] ADD CONSTRAINT [FK_Pts_ProblemInitStateWorkgroup_Pts_Workgroups] FOREIGN KEY ([WorkgroupID]) REFERENCES [Pts_Workgroups] ([WorkgroupID]) ON DELETE CASCADE
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemInitStateWorkgroup Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemInitStateWorkgroup Table'
END
GO


--
-- Script To Update Pts_ProblemRelations Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemRelations Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemRelations_Pts_Problems')
      ALTER TABLE [Pts_ProblemRelations] WITH NOCHECK ADD CONSTRAINT [FK_Pts_ProblemRelations_Pts_Problems] FOREIGN KEY ([ProblemID_1]) REFERENCES [Pts_Problems] ([ProblemID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemRelations_Pts_Problems1')
      ALTER TABLE [Pts_ProblemRelations] WITH NOCHECK ADD CONSTRAINT [FK_Pts_ProblemRelations_Pts_Problems1] FOREIGN KEY ([ProblemID_2]) REFERENCES [Pts_Problems] ([ProblemID]) ON DELETE CASCADE
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemRelations Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemRelations Table'
END
GO


--
-- Script To Update Pts_ProblemStateRecord Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_ProblemStateRecord Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_ProblemStateHistory_Pts_Problems')
      ALTER TABLE [Pts_ProblemStateRecord] WITH NOCHECK ADD CONSTRAINT [FK_Pts_ProblemStateHistory_Pts_Problems] FOREIGN KEY ([ProblemID]) REFERENCES [Pts_Problems] ([ProblemID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_ProblemStateRecord Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_ProblemStateRecord Table'
END
GO


--
-- Script To Update Pts_RecordType Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_RecordType Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_RecordType_Pts_Projects')
      ALTER TABLE [Pts_RecordType] WITH NOCHECK ADD CONSTRAINT [FK_Pts_RecordType_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_RecordType Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_RecordType Table'
END
GO


--
-- Script To Update Pts_Records Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_Records Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Records_Pts_Problems')
      ALTER TABLE [Pts_Records] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Records_Pts_Problems] FOREIGN KEY ([ProblemID]) REFERENCES [Pts_Problems] ([ProblemID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_RecordAttachments_Pts_Records')
      ALTER TABLE [Pts_RecordAttachments] ADD CONSTRAINT [FK_Pts_RecordAttachments_Pts_Records] FOREIGN KEY ([RecordID]) REFERENCES [Pts_Records] ([RecordID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_Records Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_Records Table'
END
GO


--
-- Script To Update Pts_RecordAttachments Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_RecordAttachments Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_RecordAttachments_Pts_Records')
      ALTER TABLE [Pts_RecordAttachments] WITH NOCHECK ADD CONSTRAINT [FK_Pts_RecordAttachments_Pts_Records] FOREIGN KEY ([RecordID]) REFERENCES [Pts_Records] ([RecordID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_RecordAttachments Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_RecordAttachments Table'
END
GO


--
-- Script To Create Pts_SharedItems Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_SharedItems Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_SharedItems_Pts_Projects')
      ALTER TABLE [Pts_SharedItems] ADD CONSTRAINT [FK_Pts_SharedItems_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID]) ON DELETE CASCADE
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_SharedItems Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_SharedItems Table'
END
GO


--
-- Script To Create Pts_SharedItemAttachments Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_SharedItemAttachments Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_SharedItemAttachments_Pts_SharedItems')
      ALTER TABLE [Pts_SharedItemAttachments] ADD CONSTRAINT [FK_Pts_SharedItemAttachments_Pts_SharedItems] FOREIGN KEY ([ItemID]) REFERENCES [Pts_SharedItems] ([ItemID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_SharedItemAttachments Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_SharedItemAttachments Table'
END
GO


--
-- Script To Create Pts_WorkflowSteps Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Creating Pts_WorkflowSteps Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_WorkflowSteps_Pts_ProblemState')
      ALTER TABLE [Pts_WorkflowSteps] ADD CONSTRAINT [FK_Pts_WorkflowSteps_Pts_ProblemState] FOREIGN KEY ([SrcStateID]) REFERENCES [Pts_ProblemState] ([ProblemStateID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_WorkflowSteps_Pts_ProblemState1')
      ALTER TABLE [Pts_WorkflowSteps] ADD CONSTRAINT [FK_Pts_WorkflowSteps_Pts_ProblemState1] FOREIGN KEY ([DstStateID]) REFERENCES [Pts_ProblemState] ([ProblemStateID])
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_WorkflowSteps_Pts_Projects')
      ALTER TABLE [Pts_WorkflowSteps] ADD CONSTRAINT [FK_Pts_WorkflowSteps_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_WorkflowSteps Table Added Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Add Pts_WorkflowSteps Table'
END
GO


--
-- Script To Update Pts_Workgroups Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_Workgroups Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_Workgroups_Pts_Projects')
      ALTER TABLE [Pts_Workgroups] WITH NOCHECK ADD CONSTRAINT [FK_Pts_Workgroups_Pts_Projects] FOREIGN KEY ([ProjectID]) REFERENCES [Pts_Projects] ([ProjectID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_Workgroups Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_Workgroups Table'
END
GO


--
-- Script To Update Pts_WorkgroupUsers Table In (local)\SQLExpress.URTracker230
-- Generated 星期日, 四月 13, 2008, at 11:10 PM
--
-- Please backup (local)\SQLExpress.URTracker230 before executing this script
--



GO

GO

PRINT 'Updating Pts_WorkgroupUsers Table'
GO



IF 1 = 1
   IF NOT EXISTS (SELECT name FROM sysobjects WHERE name = N'FK_Pts_WorkgroupUsers_Accounts_Users')
      ALTER TABLE [Pts_WorkgroupUsers] WITH NOCHECK ADD CONSTRAINT [FK_Pts_WorkgroupUsers_Accounts_Users] FOREIGN KEY ([UserID]) REFERENCES [Accounts_Users] ([UserID])
GO



IF 1 = 1
BEGIN
   PRINT 'Pts_WorkgroupUsers Table Updated Successfully'
   
END ELSE
BEGIN
   PRINT 'Failed To Update Pts_WorkgroupUsers Table'
END
GO
