Skip to content

Commit

Permalink
Remove Session date column
Browse files Browse the repository at this point in the history
This is replaced by the SessionDate model which captures multiple dates
per session.
  • Loading branch information
thomasleese committed Sep 25, 2024
1 parent e8e1cc6 commit 1a73518
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 0 additions & 1 deletion app/models/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# id :bigint not null, primary key
# active :boolean default(FALSE), not null
# close_consent_at :date
# date :date
# send_consent_reminders_at :date
# send_consent_requests_at :date
# time_of_day :integer
Expand Down
16 changes: 16 additions & 0 deletions db/migrate/20240925081048_remove_date_from_sessions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

class RemoveDateFromSessions < ActiveRecord::Migration[7.2]
def up
Session.all.find_each do |session|
next if (date = session.date).nil?
session.dates.create!(value: date)
end

remove_column :sessions, :date
end

def down
add_column :sessions, :date, :date
end
end
Binary file modified erd.pdf
Binary file not shown.
2 changes: 0 additions & 2 deletions spec/factories/sessions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# id :bigint not null, primary key
# active :boolean default(FALSE), not null
# close_consent_at :date
# date :date
# send_consent_reminders_at :date
# send_consent_requests_at :date
# time_of_day :integer
Expand All @@ -32,7 +31,6 @@
team { programmes.first&.team || association(:team) }
location { association :location, :school }

date { Time.zone.today }
send_consent_requests_at { date - 14.days }
send_consent_reminders_at { send_consent_requests_at + 7.days }
close_consent_at { date }
Expand Down
1 change: 0 additions & 1 deletion spec/models/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# id :bigint not null, primary key
# active :boolean default(FALSE), not null
# close_consent_at :date
# date :date
# send_consent_reminders_at :date
# send_consent_requests_at :date
# time_of_day :integer
Expand Down

0 comments on commit 1a73518

Please sign in to comment.