google-code-export / dataobjectsdotnet

Automatically exported from code.google.com/p/dataobjectsdotnet
0 stars 0 forks source link

Upgrade of fields with [Field(Nullable = false)] fails #743

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
See http://forum.x-tensive.com/viewtopic.php?f=29&t=5994#p15176

Original issue reported on code.google.com by alex.yakunin on 13 Jul 2010 at 9:36

GoogleCodeExporter commented 9 years ago
Done, along with:
- Issue 790 (default column values)
- Issue 791 (NullableOnUpgrade)

Moreover, an issue related to SQL operation order during column type change was 
discovered and resolved. Earlier CopyData actions were executed after FK 
recreations, that was wrong, since in this case it was impossible to change 
e.g. FK column type from int? to int, if there were NULLs.

Now UpgradeStage.CopyData section is unused at all (but left there for now). As 
I discovered, it was necessary just to ensure copy data commands (UPDATE 
statements) are executed separately from batch where commands changing the 
schema before copying are executed (i.e. ALTER TABLE ... CREATE COLUMN and 
sp_rename). If they'd be executed in the same batch, the whole batch 
compilation would fail, because columns, that doesn't exist @ the moment when 
batch is compiled, are used there.

To properly workaround this issue, I explicitly request starting a new batch 
for each of these UPDATE commands.

Original comment by alex.yakunin on 29 Aug 2010 at 1:21