X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e660e609661edadc1ed5ad49d6e83e936b2f91cd..424b6ef1cf760c4a3e27ac1e6f612ae42a9cd493:/db/migrate/025_add_end_time_to_changesets.rb diff --git a/db/migrate/025_add_end_time_to_changesets.rb b/db/migrate/025_add_end_time_to_changesets.rb index eaccc008f..5bd2d5879 100644 --- a/db/migrate/025_add_end_time_to_changesets.rb +++ b/db/migrate/025_add_end_time_to_changesets.rb @@ -1,25 +1,25 @@ -require 'migrate' +require "migrate" -class AddEndTimeToChangesets < ActiveRecord::Migration +class AddEndTimeToChangesets < ActiveRecord::Migration[5.0] def self.up # swap the boolean closed-or-not for a time when the changeset will # close or has closed. add_column(:changesets, :closed_at, :datetime, :null => false) - + # it appears that execute will only accept string arguments, so # this is an ugly, ugly hack to get some sort of mysql/postgres # independence. now i have to go wash my brain with bleach. - execute("update changesets set closed_at=(now()-#{interval_constant('1 hour')}) where open=(1=0)") - execute("update changesets set closed_at=(now()+#{interval_constant('1 hour')}) where open=(1=1)") + execute("update changesets set closed_at=(now()-'1 hour'::interval) where open=(1=0)") + execute("update changesets set closed_at=(now()+'1 hour'::interval) where open=(1=1)") - # remove the open column as it is unnecessary now and denormalises + # remove the open column as it is unnecessary now and denormalises # the table. remove_column :changesets, :open # add a column to keep track of the number of changes in a changeset. # could probably work out how many changes there are here, but i'm not # sure its actually important. - add_column(:changesets, :num_changes, :integer, + add_column(:changesets, :num_changes, :integer, :null => false, :default => 0) end