Skip to content

Commit f7f467d

Browse files
committed
Ensure existing events have presence set
1 parent 12e35fc commit f7f467d

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

app/models/event.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ class Event < ApplicationRecord
9797
# :nocov:
9898
end
9999

100-
# TODO: Rails 7 - Migrate this to use hash-syntax with explicit values, e.g.: { onsite: 0, online: 1, hybrid: 2 }
101-
enum presence: [:onsite, :online, :hybrid]
100+
enum presence: { onsite: 0, online: 1, hybrid: 2 }
102101

103102
belongs_to :user
104103
has_one :edit_suggestion, as: :suggestible, dependent: :destroy
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class SetPresenceOnEvents < ActiveRecord::Migration[7.0]
2+
def up
3+
ActiveRecord::Base.connection.execute("UPDATE events SET presence = 0 WHERE presence IS NULL")
4+
end
5+
6+
def down
7+
end
8+
end

db/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.0].define(version: 2023_10_13_132536) do
13+
ActiveRecord::Schema[7.0].define(version: 2023_10_13_134117) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "plpgsql"
1616

0 commit comments

Comments
 (0)