Skip to content

Commit

Permalink
PC-1234: Improve migration SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
Glenn-Clarke committed Aug 7, 2024
1 parent be471d4 commit 9ec2b38
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
Sql = @"
with grouped_table as (
SELECT *, count(""RecommendationsFirstRetrievedAt"")
SELECT ""PropertyDataId"", ""RecommendationsFirstRetrievedAt"", count(""RecommendationsFirstRetrievedAt"")
OVER (ORDER BY ""PropertyDataId"") AS _grp
FROM ""PropertyData""
),
final_table AS(
SELECT *, _grp, FIRST_VALUE(""RecommendationsFirstRetrievedAt"")
SELECT ""PropertyDataId"", _grp, FIRST_VALUE(""RecommendationsFirstRetrievedAt"")
OVER (partition by _grp order by ""PropertyDataId"") AS smeared_timestamps FROM grouped_table
)
UPDATE ""PropertyData"" p
Expand Down

0 comments on commit 9ec2b38

Please sign in to comment.