Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to #27844 - EF Core 6.0 temporal table migration when altering computed column not generating correct script #32398

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Nov 23, 2023

Working with computed column on a temporal table requires special processing - we need to disable the versioning, add the computed column to regular table and a column with the same name/type/position to the history table, but as a regular column. After all is done we re-enable versioning. Historical information on the computed column will be copied to the counterpart column in history table without issue.

One thing that we can't do is modifying computed column SQL when table is temporal. What happens in case of CCSQL modification, we drop the column and create a new one with new CCSQL. This is not an issue for regular table, because the value is computed anyway, so old value is useless. But when we drop-create column, that column gets created at the last position in the table, and so the table no longer matches it's history table exactly (positions of columns may differ). We would have to drop+recreate column on a history table, but that results in losing historical data of that column. And that is valuable data, unlike for regular table. We could enable that scenario once/if we support table rebuilds.

Fixes #27844

…mputed column not generating correct script

Working with computed column on a temporal table requires special processing - we need to disable the versioning, add the computed column to regular table and a column with the same name/type/position to the history table, but as a regular column.
After all is done we re-enable versioning. Historical information on the computed column will be copied to the counterpart column in history table without issue.

One thing that we can't do is modifying computed column SQL when table is temporal. What happens in case of CCSQL modification, we drop the column and create a new one with new CCSQL. This is not an issue for regular table, because the value is computed anyway, so old value is useless. But when we drop-create column, that column gets created at the last position in the table, and so the table no longer matches it's history table exactly (positions of columns may differ). We would have to drop+recreate column on a history table, but that results in losing historical data of that column. And that is valuable data, unlike for regular table. We could enable that scenario once/if we support table rebuilds.

Fixes #27844
@maumar maumar merged commit b96c768 into main Nov 29, 2023
7 checks passed
@maumar maumar deleted the fix27844_take2 branch November 29, 2023 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EF Core 6.0 temporal table migration when altering computed column not generating correct script
3 participants