diff --git a/src/SFA.DAS.EAS.Employer_Account.Database/SFA.DAS.EAS.Employer_Account.Database.sqlproj b/src/SFA.DAS.EAS.Employer_Account.Database/SFA.DAS.EAS.Employer_Account.Database.sqlproj index dcd26449d8..cebe73acaf 100644 --- a/src/SFA.DAS.EAS.Employer_Account.Database/SFA.DAS.EAS.Employer_Account.Database.sqlproj +++ b/src/SFA.DAS.EAS.Employer_Account.Database/SFA.DAS.EAS.Employer_Account.Database.sqlproj @@ -168,6 +168,7 @@ + diff --git a/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql b/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql new file mode 100644 index 0000000000..f50f184935 --- /dev/null +++ b/src/SFA.DAS.EAS.Employer_Account.Database/Scripts/Manual/CON-3921-DataFixForTermAndConditionsAcceptedOn.sql @@ -0,0 +1,11 @@ +-- Update TermsAndConditionsAcceptedOn for all users created afer 27th July 2021 + Update [employer_account].[User] + Set TermAndConditionsAcceptedOn = GETDATE() + where Id in ( + Select UserId from ( + Select *, ROW_NUMBER() over (partition by M.UserId order by M.CreatedDate) As Rank2 + from [employer_account].[Membership] M + ) Result + Where Result.Rank2 = 1 + and CreatedDate >= CONVERT(DATETIME,'27/07/2021',103) --dd/MM/yyyy + ) \ No newline at end of file diff --git a/src/SFA.DAS.EAS.Employer_Account.Database/StoredProcedures/UpsertUser.sql b/src/SFA.DAS.EAS.Employer_Account.Database/StoredProcedures/UpsertUser.sql index 8a4c620b2b..b618b3ef3d 100644 --- a/src/SFA.DAS.EAS.Employer_Account.Database/StoredProcedures/UpsertUser.sql +++ b/src/SFA.DAS.EAS.Employer_Account.Database/StoredProcedures/UpsertUser.sql @@ -9,4 +9,4 @@ AS USING (SELECT @userRef AS UserRef) AS [Source] ON [Target].UserRef = [Source].UserRef WHEN MATCHED THEN UPDATE SET [Target].Email = @email, [Target].FirstName = @firstName, [Target].LastName = @lastName, [Target].CorrelationId = COALESCE(@correlationId, [Target].CorrelationId) - WHEN NOT MATCHED THEN INSERT (UserRef, Email, FirstName, LastName, CorrelationId) VALUES (@userRef, @email, @firstName, @lastName, @correlationId); + WHEN NOT MATCHED THEN INSERT (UserRef, Email, FirstName, LastName, CorrelationId, TermAndConditionsAcceptedOn) VALUES (@userRef, @email, @firstName, @lastName, @correlationId, GETDATE());