Primary key constraint dropped but not recreated.
Mattias
Posts: 6 Bronze 2
SQL Compare 10.5.0.611
I am removing identity from a column so the table is dropped and recreated. But the recreated table does not get primary key constraint.
In a later stage this makes the whole installation fail because of a foreign key.
This is part of the created script with transactions removed for readability.
PRINT N'Dropping constraints from [dbo].[GroupOrVariableType]'
GO
ALTER TABLE [dbo].[GroupOrVariableType] DROP CONSTRAINT [PK_GroupOrVariableType]
GO
PRINT N'Rebuilding [dbo].[GroupOrVariableType]'
GO
CREATE TABLE [dbo].[tmp_rg_xx_GroupOrVariableType]
(
[id] [int] NOT NULL,
[descr] [varchar] (50) NULL
)
GO
INSERT INTO [dbo].[tmp_rg_xx_GroupOrVariableType]([id], [descr]) SELECT [id], [descr] FROM [dbo].[GroupOrVariableType]
GO
DROP TABLE [dbo].[GroupOrVariableType]
GO
EXEC sp_rename N'[dbo].[tmp_rg_xx_GroupOrVariableType]', N'GroupOrVariableType'
GO
PRINT N'Adding foreign keys to [dbo].[ConnectCall]'
GO
ALTER TABLE [dbo].[ConnectCall] ADD CONSTRAINT [FK_ConnectCall_GroupOrVariableType] FOREIGN KEY ([groupOrVariableTypeID]) REFERENCES [dbo].[GroupOrVariableType] ([id])
GO
I am removing identity from a column so the table is dropped and recreated. But the recreated table does not get primary key constraint.
In a later stage this makes the whole installation fail because of a foreign key.
This is part of the created script with transactions removed for readability.
PRINT N'Dropping constraints from [dbo].[GroupOrVariableType]'
GO
ALTER TABLE [dbo].[GroupOrVariableType] DROP CONSTRAINT [PK_GroupOrVariableType]
GO
PRINT N'Rebuilding [dbo].[GroupOrVariableType]'
GO
CREATE TABLE [dbo].[tmp_rg_xx_GroupOrVariableType]
(
[id] [int] NOT NULL,
[descr] [varchar] (50) NULL
)
GO
INSERT INTO [dbo].[tmp_rg_xx_GroupOrVariableType]([id], [descr]) SELECT [id], [descr] FROM [dbo].[GroupOrVariableType]
GO
DROP TABLE [dbo].[GroupOrVariableType]
GO
EXEC sp_rename N'[dbo].[tmp_rg_xx_GroupOrVariableType]', N'GroupOrVariableType'
GO
PRINT N'Adding foreign keys to [dbo].[ConnectCall]'
GO
ALTER TABLE [dbo].[ConnectCall] ADD CONSTRAINT [FK_ConnectCall_GroupOrVariableType] FOREIGN KEY ([groupOrVariableTypeID]) REFERENCES [dbo].[GroupOrVariableType] ([id])
GO
Comments
In the meantime, can you try downgrading to 10.4 and see if that fixes it?
http://downloads.red-gate.com/checkforu ... 4.8.87.exe
But the problem only occurs when I have Ignore Indexes checked. When I do, the script generator will not even create primary key constraints for new tables.