ALTER TABLE [dbo].[Principals] DROP CONSTRAINT [FK_Principals_WebApplications]
GO
ALTER TABLE [dbo].[Principals]  WITH CHECK ADD  CONSTRAINT [FK_Principals_WebApplications] FOREIGN KEY([TenantID])
REFERENCES [dbo].[WebApplications] ([ID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Principals] CHECK CONSTRAINT [FK_Principals_WebApplications]
GO

ALTER TABLE [dbo].[PrincipalMemberships] DROP CONSTRAINT [FK_PrincipalMemberships_Principals]
GO
ALTER TABLE [dbo].[PrincipalMemberships]  WITH CHECK ADD  CONSTRAINT [FK_PrincipalMemberships_Principals] FOREIGN KEY([GroupID])
REFERENCES [dbo].[Principals] ([PrincipalID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[PrincipalMemberships] CHECK CONSTRAINT [FK_PrincipalMemberships_Principals]
GO

ALTER TABLE [dbo].[RoleAssignments] DROP CONSTRAINT [FK_RoleAssignments_Principals]
GO
ALTER TABLE [dbo].[RoleAssignments]  WITH CHECK ADD  CONSTRAINT [FK_RoleAssignments_Principals] FOREIGN KEY([PrincipalID])
REFERENCES [dbo].[Principals] ([PrincipalID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[RoleAssignments] CHECK CONSTRAINT [FK_RoleAssignments_Principals]
GO

ALTER TABLE [dbo].[RoleAssignments] DROP CONSTRAINT [FK_RoleAssignments_Roles]
GO
ALTER TABLE [dbo].[RoleAssignments]  WITH CHECK ADD  CONSTRAINT [FK_RoleAssignments_Roles] FOREIGN KEY([RoleID])
REFERENCES [dbo].[Roles] ([RoleID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[RoleAssignments] CHECK CONSTRAINT [FK_RoleAssignments_Roles]
GO

ALTER TABLE [dbo].[RolePermissions] DROP CONSTRAINT [FK_RolePermissions_Roles]
GO
ALTER TABLE [dbo].[RolePermissions]  WITH CHECK ADD  CONSTRAINT [FK_RolePermissions_Roles] FOREIGN KEY([RoleID])
REFERENCES [dbo].[Roles] ([RoleID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[RolePermissions] CHECK CONSTRAINT [FK_RolePermissions_Roles]
GO

ALTER TABLE [dbo].[ScopeAssignments] DROP CONSTRAINT [FK_ScopeAssignments_SharePointObjects]
GO
ALTER TABLE [dbo].[ScopeAssignments]  WITH CHECK ADD  CONSTRAINT [FK_ScopeAssignments_SharePointObjects] FOREIGN KEY([SPObjectID])
REFERENCES [dbo].[SharePointObjects] ([ID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ScopeAssignments] CHECK CONSTRAINT [FK_ScopeAssignments_SharePointObjects]
GO

ALTER TABLE [dbo].[SharePointObjectMemberships] DROP CONSTRAINT [FK_SharePointObjectMemberships_SharePointObjects]
GO
ALTER TABLE [dbo].[SharePointObjectMemberships]  WITH CHECK ADD  CONSTRAINT [FK_SharePointObjectMemberships_SharePointObjects] FOREIGN KEY([ParentID])
REFERENCES [dbo].[SharePointObjects] ([ID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[SharePointObjectMemberships] CHECK CONSTRAINT [FK_SharePointObjectMemberships_SharePointObjects]
GO

ALTER TABLE [dbo].[SharePointObjects] DROP CONSTRAINT [FK_SharePointObjects_WebApplications]
GO
ALTER TABLE [dbo].[SharePointObjects]  WITH CHECK ADD  CONSTRAINT [FK_SharePointObjects_WebApplications] FOREIGN KEY([WebAppID])
REFERENCES [dbo].[WebApplications] ([ID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[SharePointObjects] CHECK CONSTRAINT [FK_SharePointObjects_WebApplications]
GO

ALTER TABLE [dbo].[SiteCollectionAdministrators] DROP CONSTRAINT [FK_SiteCollectionAdministrators_SharePointObjects]
GO
ALTER TABLE [dbo].[SiteCollectionAdministrators]  WITH CHECK ADD  CONSTRAINT [FK_SiteCollectionAdministrators_SharePointObjects] FOREIGN KEY([SharePointObjectID])
REFERENCES [dbo].[SharePointObjects] ([ID])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[SiteCollectionAdministrators] CHECK CONSTRAINT [FK_SiteCollectionAdministrators_SharePointObjects]
GO

UPDATE [dbo].[Options] SET [OptionValue] = '3.3.1' WHERE [OptionID] = 14

INSERT INTO [RuleTypes] ([ID], [Name], [Description]) VALUES (3, 'Display on Quick Launch' , 'Specify whether the documents will be displayed on the quick launch.')