IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME ='FK_OTALog_OTALogBase')
  ALTER TABLE [dbo].[OTALog] DROP CONSTRAINT [FK_OTALog_OTALogBase]

ALTER TABLE [dbo].[OTALog]  WITH NOCHECK ADD CONSTRAINT [FK_OTALog_OTALogBase] FOREIGN KEY([PK])
REFERENCES [dbo].[OTALogBase] ([OTALogId])
ON DELETE CASCADE

IF NOT EXISTS(SELECT * FROM sys.indexes WHERE name='IX_OTALogDateStamp' AND object_id = OBJECT_ID('OTALog'))
  CREATE NONCLUSTERED INDEX [IX_OTALogDateStamp] ON [dbo].OTALog 
  (
    [Datestamp] DESC
  )