In my database table I have audit columns for create, update users and dates.
I want to update some rows using this migration script
update table set column_1=1, UpdatedBy='SystemUser', UpdatedDate=GETDATE() where column_1=2;
Now in the down script I want to revert it to the exact same state as it was before this migration. Ideally that is how it should work, right?
So I would have a down script that will do the opposite of the above Up script.
The problem is how should I know what was the updated date before the update of the rows?
So this should be my down script
update table set column_1=2, UpdatedBy='SystemUser', UpdatedDate=[WHAT_SHOULD_COME_HERE] where column_1=1;
How these type of previous data dependent down scripts are written?
2