-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '73ec47270227f38532a53736b60ee6e4a43785ef' (remote-track…
…ing branch 'redmine/master') into yuya-develop
- Loading branch information
Showing
7 changed files
with
32 additions
and
17 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
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
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
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
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
18 changes: 18 additions & 0 deletions
18
db/migrate/20241026031710_update_orphaned_journal_updated_by_id_to_anonymous.rb
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,18 @@ | ||
class UpdateOrphanedJournalUpdatedByIdToAnonymous < ActiveRecord::Migration[7.2] | ||
def up | ||
# Don't use `User.anonymous` here because it creates a new anonymous | ||
# user if one doesn't exist yet. | ||
anonymous_user_id = AnonymousUser.unscoped.pick(:id) | ||
# The absence of an anonymous user implies a fresh installation. | ||
return if anonymous_user_id.nil? | ||
|
||
Journal.joins('LEFT JOIN users ON users.id = journals.updated_by_id') | ||
.where.not(updated_by_id: nil) | ||
.where(users: { id: nil }) | ||
.update_all(updated_by_id: anonymous_user_id) | ||
end | ||
|
||
def down | ||
# no-op | ||
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