Skip to content

Commit 2134fd9

Browse files
committed
TD-4785-Set the Removed date as the current date for old duplicate rows in the table
1 parent a8682c5 commit 2134fd9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace DigitalLearningSolutions.Data.Migrations
2+
{
3+
using FluentMigrator;
4+
5+
[Migration(202410091524)]
6+
public class UpdateCandidateAssessmentSupervisorsDuplicateRows : ForwardOnlyMigration
7+
{
8+
public override void Up()
9+
{
10+
Execute.Sql(@$"WITH CAS_Duplicates AS (
11+
SELECT ID,
12+
ROW_NUMBER() OVER (PARTITION BY CandidateAssessmentID,SupervisorDelegateId ORDER BY Id DESC) AS RowNum
13+
FROM CandidateAssessmentSupervisors
14+
WHERE CandidateAssessmentSupervisors.Removed is null
15+
)
16+
UPDATE CandidateAssessmentSupervisors
17+
SET Removed = GETUTCDATE()
18+
FROM CandidateAssessmentSupervisors cas INNER JOIN
19+
CAS_Duplicates casd ON cas.ID = casd.ID
20+
WHERE casd.RowNum > 1;");
21+
}
22+
23+
}
24+
}

0 commit comments

Comments
 (0)