During our upgrade process I've found that DO tries to delete data from droppped table before actually droppping them. This is really WRONG. First we need to drop FKs/Columns other referencing object, then delete the data if any.
var batch =
EnumerableUtils.One(Driver.BatchBegin)
.Concat(translator.CleanupDataCommands)
.Concat(translator.PreUpgradeCommands)
.Concat(translator.UpgradeCommands)
.Concat(translator.CopyDataCommands)
.Concat(translator.PostCopyDataCommands)
.Concat(translator.CleanupCommands)
.Concat(EnumerableUtils.One(Driver.BatchEnd))
.ToArray();
In our case this lead to inability to perform an upgrade at all.
Xtensive.Orm.ReferentialConstraintViolationException: SQL error occured.
Storage error details 'Entity: Mortgage;'
SQL error details 'Type: ReferentialConstraintViolation; Database: Eis; Table: Mortgage; Column: ReasonOfMortgage_Id; Constraint: FK_Mortgage-ReasonOfMortgage-ReasonOfMortgage_ReasonOfMortgage;'
Query 'DELETE FROM [dbo].[ReasonOfMortgage];
DELETE FROM [dbo].[SubaccountWithoutStorage];
DELETE FROM [dbo].[ParCredentials];
DELETE FROM [dbo].[ParCredentialsForUser];
DELETE FROM [dbo].[TypeOfAuthority];
DELETE FROM [dbo].[Mortgage_TpPayment];
DELETE FROM [dbo].[Mortgage_TpFine];
DELETE FROM [dbo].[EntityIndex];
DELETE FROM [dbo].[ParLinkedEntityes];
DELETE FROM [dbo].[PersonRoleParametr];
DELETE FROM [dbo].[EntityIndex_MlIndexField];
DELETE FROM [dbo].[RegIsExchangeFoundation];'
Original message 'The DELETE statement conflicted with the REFERENCE constraint "FK_Mortgage-ReasonOfMortgage-ReasonOfMortgage_ReasonOfMortgage". The conflict occurred in database "Eis", table "dbo.Mortgage", column 'ReasonOfMortgage_Id'.
The statement has been terminated.'
asked
Oct 06 '11 at 09:48
xumix
425●75●76●82
I've just sent you the test project and db backup
I've sent you another simplified test with DB backup. Now it fails with foreign key whaen updating a table
How kind of you =)