X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e660e609661edadc1ed5ad49d6e83e936b2f91cd..2233edbcfa15d532c2232e5e71a2a2495e3a72eb:/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 7cc485e6b..728b56989 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 '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_enumeration :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