|
I see the source shows where this was done, but it is not completely working.
I am running 3.9.4 and there are some constraints added at the end of the script, but there are quite a few spread throughout the script - and causing issues.
Looks to me like the code may be looking for the word 'CHECK' on the constraint, where it actually has NOCHECK and then at the bottom of the script adds the check option in?
Here is an example of what it misses...
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SomeKey]') AND parent_object_id = OBJECT_ID(N'[dbo].[SomeTable]'))
ALTER TABLE [dbo].[SomeTable] WITH NOCHECK ADD CONSTRAINT [FK_SomeKey] FOREIGN KEY([ForeignKey])
REFERENCES [dbo].[SomeForeignTable] ([Pkey])
GO
Then at the bottom of the script...
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SomeKey]') AND parent_object_id = OBJECT_ID(N'[dbo].[SomeTable]'))
ALTER TABLE [dbo].[SomeTable] CHECK CONSTRAINT [FK_SomeKey]
GO
|