-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If the claim has a journey session we try and set the `started_at` to that, if it doesn't have a journey session we'll just use the `created_at` timestamp, which for claims pre the introduction of journey sessions will be the started at time.
- Loading branch information
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class BackFillClaimsStartedAt < ActiveRecord::Migration[7.0] | ||
def up | ||
execute <<-SQL | ||
UPDATE claims | ||
SET started_at = journeys_sessions.created_at | ||
FROM journeys_sessions | ||
WHERE claims.journeys_session_id = journeys_sessions.id | ||
AND claims.started_at IS NULL | ||
SQL | ||
|
||
execute <<-SQL | ||
UPDATE claims | ||
SET started_at = created_at | ||
WHERE journeys_session_id IS NULL | ||
AND claims.started_at IS NULL | ||
SQL | ||
|
||
change_column_null :claims, :started_at, false | ||
end | ||
|
||
def down | ||
Claim.update_all(started_at: nil) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters