X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/565171486f6d90321e0291d5ccc3cf6a1c12e730..7e7ede890e8e948236d3dbc48e24aca00cd01f62:/db/migrate/039_add_more_controls_to_gpx_files.rb diff --git a/db/migrate/039_add_more_controls_to_gpx_files.rb b/db/migrate/039_add_more_controls_to_gpx_files.rb index 133838ac2..9f6d62148 100644 --- a/db/migrate/039_add_more_controls_to_gpx_files.rb +++ b/db/migrate/039_add_more_controls_to_gpx_files.rb @@ -1,10 +1,12 @@ -require 'lib/migrate' +class AddMoreControlsToGpxFiles < ActiveRecord::Migration[4.2] + class Trace < ApplicationRecord + self.table_name = "gpx_files" + end -class AddMoreControlsToGpxFiles < ActiveRecord::Migration def self.up - create_enumeration :gpx_visibility_enum, ["private", "public", "trackable", "identifiable"] + create_enum :gpx_visibility_enum, %w[private public trackable identifiable] add_column :gpx_files, :visibility, :gpx_visibility_enum, :default => "public", :null => false - Trace.update_all("visibility = 'private'", { :public => false }) + Trace.where(:public => false).update_all(:visibility => "private") add_index :gpx_files, [:visible, :visibility], :name => "gpx_files_visible_visibility_idx" remove_index :gpx_files, :name => "gpx_files_visible_public_idx" remove_column :gpx_files, :public @@ -12,7 +14,7 @@ class AddMoreControlsToGpxFiles < ActiveRecord::Migration def self.down add_column :gpx_files, :public, :boolean, :default => true, :null => false - Trace.update_all("public = false", { :visibility => "private" }) + Trace.where(:visibility => "private").update_all(:public => false) add_index :gpx_files, [:visible, :public], :name => "gpx_files_visible_public_idx" remove_index :gpx_files, :name => "gpx_files_visible_visibility_idx" remove_column :gpx_files, :visibility