Fix most auto-correctable rubocop issues
This commit is contained in:
parent
34e3e51456
commit
ef7f3d800c
206 changed files with 2925 additions and 3473 deletions
|
@ -13,7 +13,7 @@ class CreateOsmDb < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
add_index "current_nodes", ["id"], :name => "current_nodes_id_idx"
|
||||
add_index "current_nodes", ["latitude", "longitude"], :name => "current_nodes_lat_lon_idx"
|
||||
add_index "current_nodes", %w(latitude longitude), :name => "current_nodes_lat_lon_idx"
|
||||
add_index "current_nodes", ["timestamp"], :name => "current_nodes_timestamp_idx"
|
||||
|
||||
create_table "current_segments", :id => false do |t|
|
||||
|
@ -26,7 +26,7 @@ class CreateOsmDb < ActiveRecord::Migration
|
|||
t.column "timestamp", :datetime
|
||||
end
|
||||
|
||||
add_index "current_segments", ["id", "visible"], :name => "current_segments_id_visible_idx"
|
||||
add_index "current_segments", %w(id visible), :name => "current_segments_id_visible_idx"
|
||||
add_index "current_segments", ["node_a"], :name => "current_segments_a_idx"
|
||||
add_index "current_segments", ["node_b"], :name => "current_segments_b_idx"
|
||||
|
||||
|
@ -82,7 +82,7 @@ class CreateOsmDb < ActiveRecord::Migration
|
|||
t.column "timestamp", :datetime
|
||||
end
|
||||
|
||||
add_index "gps_points", ["latitude", "longitude", "user_id"], :name => "points_idx"
|
||||
add_index "gps_points", %w(latitude longitude user_id), :name => "points_idx"
|
||||
add_index "gps_points", ["user_id"], :name => "points_uid_idx"
|
||||
add_index "gps_points", ["gpx_id"], :name => "points_gpxid_idx"
|
||||
|
||||
|
@ -109,7 +109,7 @@ class CreateOsmDb < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
add_index "gpx_files", ["timestamp"], :name => "gpx_files_timestamp_idx"
|
||||
add_index "gpx_files", ["visible", "public"], :name => "gpx_files_visible_public_idx"
|
||||
add_index "gpx_files", %w(visible public), :name => "gpx_files_visible_public_idx"
|
||||
|
||||
create_table "gpx_pending_files", :id => false do |t|
|
||||
t.column "originalname", :string
|
||||
|
@ -148,7 +148,7 @@ class CreateOsmDb < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
add_index "nodes", ["id"], :name => "nodes_uid_idx"
|
||||
add_index "nodes", ["latitude", "longitude"], :name => "nodes_latlon_idx"
|
||||
add_index "nodes", %w(latitude longitude), :name => "nodes_latlon_idx"
|
||||
|
||||
create_table "segments", :id => false do |t|
|
||||
t.column "id", :bigint
|
||||
|
@ -193,7 +193,7 @@ class CreateOsmDb < ActiveRecord::Migration
|
|||
t.column "sequence_id", :bigint, :null => false
|
||||
end
|
||||
|
||||
add_primary_key "way_segments", ["id", "version", "sequence_id"]
|
||||
add_primary_key "way_segments", %w(id version sequence_id)
|
||||
|
||||
create_table "way_tags", :id => false do |t|
|
||||
t.column "id", :bigint, :default => 0, :null => false
|
||||
|
@ -202,7 +202,7 @@ class CreateOsmDb < ActiveRecord::Migration
|
|||
t.column "version", :bigint
|
||||
end
|
||||
|
||||
add_index "way_tags", ["id", "version"], :name => "way_tags_id_version_idx"
|
||||
add_index "way_tags", %w(id version), :name => "way_tags_id_version_idx"
|
||||
|
||||
create_table "ways", :id => false do |t|
|
||||
t.column "id", :bigint, :default => 0, :null => false
|
||||
|
@ -212,11 +212,10 @@ class CreateOsmDb < ActiveRecord::Migration
|
|||
t.column "visible", :boolean, :default => true
|
||||
end
|
||||
|
||||
add_primary_key "ways", ["id", "version"]
|
||||
add_primary_key "ways", %w(id version)
|
||||
add_index "ways", ["id"], :name => "ways_id_version_idx"
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class CleanupOsmDb < ActiveRecord::Migration
|
|||
change_column "current_way_segments", "id", :bigint, :null => false
|
||||
change_column "current_way_segments", "segment_id", :bigint, :null => false
|
||||
change_column "current_way_segments", "sequence_id", :bigint, :null => false
|
||||
add_primary_key "current_way_segments", ["id", "sequence_id"]
|
||||
add_primary_key "current_way_segments", %w(id sequence_id)
|
||||
remove_index "current_way_segments", :name => "current_way_segments_id_idx"
|
||||
|
||||
change_column "current_way_tags", "id", :bigint, :null => false
|
||||
|
@ -40,7 +40,7 @@ class CleanupOsmDb < ActiveRecord::Migration
|
|||
remove_index "gps_points", :name => "points_uid_idx"
|
||||
remove_index "gps_points", :name => "points_idx"
|
||||
remove_column "gps_points", "user_id"
|
||||
add_index "gps_points", ["latitude", "longitude"], :name => "points_idx"
|
||||
add_index "gps_points", %w(latitude longitude), :name => "points_idx"
|
||||
change_column "gps_points", "trackid", :integer, :null => false
|
||||
change_column "gps_points", "latitude", :integer, :null => false
|
||||
change_column "gps_points", "longitude", :integer, :null => false
|
||||
|
@ -204,7 +204,7 @@ class CleanupOsmDb < ActiveRecord::Migration
|
|||
change_column "current_way_segments", "segment_id", :bigint
|
||||
change_column "current_way_segments", "id", :bigint
|
||||
|
||||
add_index "current_segments", ["id", "visible"], :name => "current_segments_id_visible_idx"
|
||||
add_index "current_segments", %w(id visible), :name => "current_segments_id_visible_idx"
|
||||
remove_primary_key "current_segments"
|
||||
change_column "current_segments", "timestamp", :datetime
|
||||
change_column "current_segments", "visible", :boolean
|
||||
|
|
|
@ -12,7 +12,7 @@ class UserEnhancements < ActiveRecord::Migration
|
|||
t.column "v", :string, :null => false
|
||||
end
|
||||
|
||||
add_primary_key "user_preferences", ["user_id", "k"]
|
||||
add_primary_key "user_preferences", %w(user_id k)
|
||||
|
||||
create_table "user_tokens", :id => false do |t|
|
||||
t.column "id", :bigserial, :primary_key => true, :null => false
|
||||
|
@ -35,7 +35,7 @@ class UserEnhancements < ActiveRecord::Migration
|
|||
add_column "users", "nearby", :integer, :default => 50
|
||||
add_column "users", "pass_salt", :string
|
||||
|
||||
User.update_all("nearby = 50");
|
||||
User.update_all("nearby = 50")
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
@ -20,7 +20,7 @@ class TileTracepoints < ActiveRecord::Migration
|
|||
def self.down
|
||||
Tracepoint.update_all("latitude = latitude / 10, longitude = longitude / 10")
|
||||
|
||||
add_index "gps_points", ["latitude", "longitude"], :name => "points_idx"
|
||||
add_index "gps_points", %w(latitude longitude), :name => "points_idx"
|
||||
remove_index "gps_points", :name => "points_tile_idx"
|
||||
remove_column "gps_points", "tile"
|
||||
end
|
||||
|
|
|
@ -19,9 +19,7 @@ class TileNodes < ActiveRecord::Migration
|
|||
FROM #{from_table}
|
||||
END_SQL
|
||||
|
||||
model.all.each do |n|
|
||||
n.save!
|
||||
end
|
||||
model.all.each(&:save!)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -59,8 +57,8 @@ class TileNodes < ActiveRecord::Migration
|
|||
|
||||
drop_table "current_nodes_v5"
|
||||
|
||||
remove_index "nodes", :name=> "nodes_uid_idx"
|
||||
remove_index "nodes", :name=> "nodes_timestamp_idx"
|
||||
remove_index "nodes", :name => "nodes_uid_idx"
|
||||
remove_index "nodes", :name => "nodes_timestamp_idx"
|
||||
rename_table "nodes", "nodes_v5"
|
||||
|
||||
create_table "nodes", :id => false do |t|
|
||||
|
@ -98,7 +96,7 @@ class TileNodes < ActiveRecord::Migration
|
|||
t.column "timestamp", :datetime, :null => false
|
||||
end
|
||||
|
||||
add_index "current_nodes", ["latitude", "longitude"], :name => "current_nodes_lat_lon_idx"
|
||||
add_index "current_nodes", %w(latitude longitude), :name => "current_nodes_lat_lon_idx"
|
||||
add_index "current_nodes", ["timestamp"], :name => "current_nodes_timestamp_idx"
|
||||
|
||||
downgrade_table "current_nodes_v6", "current_nodes"
|
||||
|
@ -118,7 +116,7 @@ class TileNodes < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
add_index "nodes", ["id"], :name => "nodes_uid_idx"
|
||||
add_index "nodes", ["latitude", "longitude"], :name => "nodes_latlon_idx"
|
||||
add_index "nodes", %w(latitude longitude), :name => "nodes_latlon_idx"
|
||||
add_index "nodes", ["timestamp"], :name => "nodes_timestamp_idx"
|
||||
|
||||
downgrade_table "nodes_v6", "nodes"
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'migrate'
|
|||
class AddRelations < ActiveRecord::Migration
|
||||
def self.up
|
||||
# enums work like strings but are more efficient
|
||||
create_enumeration :nwr_enum, ["Node", "Way", "Relation"]
|
||||
create_enumeration :nwr_enum, %w(Node Way Relation)
|
||||
|
||||
# a relation can have members much like a way can have nodes.
|
||||
# differences:
|
||||
|
@ -16,8 +16,8 @@ class AddRelations < ActiveRecord::Migration
|
|||
t.column "member_role", :string
|
||||
end
|
||||
|
||||
add_primary_key "current_relation_members", ["id", "member_type", "member_id", "member_role"]
|
||||
add_index "current_relation_members", ["member_type", "member_id"], :name => "current_relation_members_member_idx"
|
||||
add_primary_key "current_relation_members", %w(id member_type member_id member_role)
|
||||
add_index "current_relation_members", %w(member_type member_id), :name => "current_relation_members_member_idx"
|
||||
# the following is obsolete given the primary key, is it not?
|
||||
# add_index "current_relation_members", ["id"], :name => "current_relation_members_id_idx"
|
||||
create_table "current_relation_tags", :id => false do |t|
|
||||
|
@ -44,8 +44,8 @@ class AddRelations < ActiveRecord::Migration
|
|||
t.column "version", :bigint, :default => 0, :null => false
|
||||
end
|
||||
|
||||
add_primary_key "relation_members", ["id", "version", "member_type", "member_id", "member_role"]
|
||||
add_index "relation_members", ["member_type", "member_id"], :name => "relation_members_member_idx"
|
||||
add_primary_key "relation_members", %w(id version member_type member_id member_role)
|
||||
add_index "relation_members", %w(member_type member_id), :name => "relation_members_member_idx"
|
||||
|
||||
create_table "relation_tags", :id => false do |t|
|
||||
t.column "id", :bigint, :default => 0, :null => false
|
||||
|
@ -54,7 +54,7 @@ class AddRelations < ActiveRecord::Migration
|
|||
t.column "version", :bigint, :null => false
|
||||
end
|
||||
|
||||
add_index "relation_tags", ["id", "version"], :name => "relation_tags_id_version_idx"
|
||||
add_index "relation_tags", %w(id version), :name => "relation_tags_id_version_idx"
|
||||
|
||||
create_table "relations", :id => false do |t|
|
||||
t.column "id", :bigint, :null => false, :default => 0
|
||||
|
@ -64,7 +64,7 @@ class AddRelations < ActiveRecord::Migration
|
|||
t.column "visible", :boolean, :null => false, :default => true
|
||||
end
|
||||
|
||||
add_primary_key "relations", ["id", "version"]
|
||||
add_primary_key "relations", %w(id version)
|
||||
add_index "relations", ["timestamp"], :name => "relations_timestamp_idx"
|
||||
end
|
||||
|
||||
|
|
|
@ -5,25 +5,24 @@ class RemoveSegments < ActiveRecord::Migration
|
|||
have_segs = select_value("SELECT count(*) FROM current_segments").to_i != 0
|
||||
|
||||
if have_segs
|
||||
prefix = File.join Dir.tmpdir, "008_remove_segments.#{$$}."
|
||||
prefix = File.join Dir.tmpdir, "008_remove_segments.#{$PROCESS_ID}."
|
||||
|
||||
cmd = "db/migrate/008_remove_segments_helper"
|
||||
src = "#{cmd}.cc"
|
||||
if not File.exists? cmd or File.mtime(cmd) < File.mtime(src) then
|
||||
system 'c++ -O3 -Wall `mysql_config --cflags --libs` ' +
|
||||
"#{src} -o #{cmd}" or fail
|
||||
if !File.exist?(cmd) || File.mtime(cmd) < File.mtime(src)
|
||||
system('c++ -O3 -Wall `mysql_config --cflags --libs` ' +
|
||||
"#{src} -o #{cmd}") || fail
|
||||
end
|
||||
|
||||
conn_opts = ActiveRecord::Base.connection.
|
||||
instance_eval { @connection_options }
|
||||
args = conn_opts.map { |arg| arg.to_s } + [prefix]
|
||||
conn_opts = ActiveRecord::Base.connection
|
||||
.instance_eval { @connection_options }
|
||||
args = conn_opts.map(&:to_s) + [prefix]
|
||||
fail "#{cmd} failed" unless system cmd, *args
|
||||
|
||||
tempfiles = ['ways', 'way_nodes', 'way_tags',
|
||||
'relations', 'relation_members', 'relation_tags'].
|
||||
map { |base| prefix + base }
|
||||
tempfiles = %w(ways way_nodes way_tags relations relation_members relation_tags)
|
||||
.map { |base| prefix + base }
|
||||
ways, way_nodes, way_tags,
|
||||
relations, relation_members, relation_tags = tempfiles
|
||||
relations, relation_members, relation_tags = tempfiles
|
||||
end
|
||||
|
||||
drop_table :segments
|
||||
|
@ -82,6 +81,6 @@ class RemoveSegments < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
fail ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,8 +11,7 @@ class DiaryComments < ActiveRecord::Migration
|
|||
t.column "updated_at", :datetime, :null => false
|
||||
end
|
||||
|
||||
add_index "diary_comments", ["diary_entry_id", "id"], :name => "diary_comments_entry_id_idx", :unique => true
|
||||
|
||||
add_index "diary_comments", %w(diary_entry_id id), :name => "diary_comments_entry_id_idx", :unique => true
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class AddEmailValid < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column "users", "email_valid", :boolean, :default => false, :null => false
|
||||
User.update_all("email_valid = (active != 0)") #email_valid is :boolean, but active is :integer. "email_valid = active" (see r11802 or earlier) will fail for stricter dbs than mysql
|
||||
User.update_all("email_valid = (active != 0)") # email_valid is :boolean, but active is :integer. "email_valid = active" (see r11802 or earlier) will fail for stricter dbs than mysql
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
@ -5,21 +5,21 @@ class PopulateNodeTagsAndRemove < ActiveRecord::Migration
|
|||
have_nodes = select_value("SELECT count(*) FROM current_nodes").to_i != 0
|
||||
|
||||
if have_nodes
|
||||
prefix = File.join Dir.tmpdir, "020_populate_node_tags_and_remove.#{$$}."
|
||||
prefix = File.join Dir.tmpdir, "020_populate_node_tags_and_remove.#{$PROCESS_ID}."
|
||||
|
||||
cmd = "db/migrate/020_populate_node_tags_and_remove_helper"
|
||||
src = "#{cmd}.c"
|
||||
if not File.exists? cmd or File.mtime(cmd) < File.mtime(src) then
|
||||
system 'cc -O3 -Wall `mysql_config --cflags --libs` ' +
|
||||
"#{src} -o #{cmd}" or fail
|
||||
if !File.exist?(cmd) || File.mtime(cmd) < File.mtime(src)
|
||||
system('cc -O3 -Wall `mysql_config --cflags --libs` ' +
|
||||
"#{src} -o #{cmd}") || fail
|
||||
end
|
||||
|
||||
conn_opts = ActiveRecord::Base.connection.instance_eval { @connection_options }
|
||||
args = conn_opts.map { |arg| arg.to_s } + [prefix]
|
||||
args = conn_opts.map(&:to_s) + [prefix]
|
||||
fail "#{cmd} failed" unless system cmd, *args
|
||||
|
||||
tempfiles = ['nodes', 'node_tags', 'current_nodes', 'current_node_tags'].
|
||||
map { |base| prefix + base }
|
||||
tempfiles = %w(nodes node_tags current_nodes current_node_tags)
|
||||
.map { |base| prefix + base }
|
||||
nodes, node_tags, current_nodes, current_node_tags = tempfiles
|
||||
end
|
||||
|
||||
|
@ -46,7 +46,7 @@ class PopulateNodeTagsAndRemove < ActiveRecord::Migration
|
|||
csvopts = "FIELDS TERMINATED BY ',' ENCLOSED BY '\"' ESCAPED BY '\"' LINES TERMINATED BY '\\n'"
|
||||
|
||||
if have_nodes
|
||||
execute "LOAD DATA INFILE '#{nodes}' INTO TABLE nodes #{csvopts} (id, latitude, longitude, user_id, visible, timestamp, tile, version)";
|
||||
execute "LOAD DATA INFILE '#{nodes}' INTO TABLE nodes #{csvopts} (id, latitude, longitude, user_id, visible, timestamp, tile, version)"
|
||||
execute "LOAD DATA INFILE '#{node_tags}' INTO TABLE node_tags #{csvopts} (id, version, k, v)"
|
||||
execute "LOAD DATA INFILE '#{current_node_tags}' INTO TABLE current_node_tags #{csvopts} (id, k, v)"
|
||||
end
|
||||
|
@ -55,8 +55,8 @@ class PopulateNodeTagsAndRemove < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
# add_column :nodes, "tags", :text, :default => "", :null => false
|
||||
# add_column :current_nodes, "tags", :text, :default => "", :null => false
|
||||
fail ActiveRecord::IrreversibleMigration
|
||||
# add_column :nodes, "tags", :text, :default => "", :null => false
|
||||
# add_column :current_nodes, "tags", :text, :default => "", :null => false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,43 +1,41 @@
|
|||
require 'migrate'
|
||||
|
||||
class MoveToInnodb < ActiveRecord::Migration
|
||||
@@conv_tables = ['nodes', 'ways', 'way_tags', 'way_nodes',
|
||||
'current_way_tags', 'relation_members',
|
||||
'relations', 'relation_tags', 'current_relation_tags']
|
||||
@@conv_tables = %w(nodes ways way_tags way_nodes current_way_tags relation_members relations relation_tags current_relation_tags)
|
||||
|
||||
@@ver_tbl = ['nodes', 'ways', 'relations']
|
||||
@@ver_tbl = %w(nodes ways relations)
|
||||
|
||||
def self.up
|
||||
remove_index :current_way_tags, :name=> :current_way_tags_v_idx
|
||||
remove_index :current_relation_tags, :name=> :current_relation_tags_v_idx
|
||||
remove_index :current_way_tags, :name => :current_way_tags_v_idx
|
||||
remove_index :current_relation_tags, :name => :current_relation_tags_v_idx
|
||||
|
||||
@@ver_tbl.each { |tbl|
|
||||
@@ver_tbl.each do |tbl|
|
||||
change_column tbl, "version", :bigint, :null => false
|
||||
}
|
||||
end
|
||||
|
||||
@@ver_tbl.each { |tbl|
|
||||
@@ver_tbl.each do |tbl|
|
||||
add_column "current_#{tbl}", "version", :bigint, :null => false
|
||||
# As the initial version of all nodes, ways and relations is 0, we set the
|
||||
# current version to something less so that we can update the version in
|
||||
# batches of 10000
|
||||
tbl.classify.constantize.update_all("version=-1")
|
||||
while tbl.classify.constantize.count(:conditions => {:version => -1}) > 0
|
||||
tbl.classify.constantize.update_all("version=(SELECT max(version) FROM #{tbl} WHERE #{tbl}.id = current_#{tbl}.id)", {:version => -1}, :limit => 10000)
|
||||
while tbl.classify.constantize.count(:conditions => { :version => -1 }) > 0
|
||||
tbl.classify.constantize.update_all("version=(SELECT max(version) FROM #{tbl} WHERE #{tbl}.id = current_#{tbl}.id)", { :version => -1 }, { :limit => 10000 })
|
||||
end
|
||||
# execute "UPDATE current_#{tbl} SET version = " +
|
||||
# execute "UPDATE current_#{tbl} SET version = " +
|
||||
# "(SELECT max(version) FROM #{tbl} WHERE #{tbl}.id = current_#{tbl}.id)"
|
||||
# The above update causes a MySQL error:
|
||||
# -- add_column("current_nodes", "version", :bigint, {:null=>false, :limit=>20})
|
||||
# -> 1410.9152s
|
||||
# -- execute("UPDATE current_nodes SET version = (SELECT max(version) FROM nodes WHERE nodes.id = current_nodes.id)")
|
||||
# rake aborted!
|
||||
# Mysql::Error: The total number of locks exceeds the lock table size: UPDATE current_nodes SET version = (SELECT max(version) FROM nodes WHERE nodes.id = current_nodes.id)
|
||||
# The above update causes a MySQL error:
|
||||
# -- add_column("current_nodes", "version", :bigint, {:null=>false, :limit=>20})
|
||||
# -> 1410.9152s
|
||||
# -- execute("UPDATE current_nodes SET version = (SELECT max(version) FROM nodes WHERE nodes.id = current_nodes.id)")
|
||||
# rake aborted!
|
||||
# Mysql::Error: The total number of locks exceeds the lock table size: UPDATE current_nodes SET version = (SELECT max(version) FROM nodes WHERE nodes.id = current_nodes.id)
|
||||
|
||||
# The above rails version will take longer, however will no run out of locks
|
||||
}
|
||||
# The above rails version will take longer, however will no run out of locks
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
fail ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
|
|
|
@ -47,6 +47,6 @@ class KeyConstraints < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
fail ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
require 'migrate'
|
||||
|
||||
class AddChangesets < ActiveRecord::Migration
|
||||
@@conv_user_tables = ['current_nodes',
|
||||
'current_relations', 'current_ways', 'nodes', 'relations', 'ways' ]
|
||||
@@conv_user_tables = %w(current_nodes current_relations current_ways nodes relations ways)
|
||||
|
||||
def self.up
|
||||
create_table "changesets", :id => false do |t|
|
||||
|
@ -32,17 +31,17 @@ class AddChangesets < ActiveRecord::Migration
|
|||
execute "INSERT INTO changesets (id, user_id, created_at, open)" +
|
||||
"SELECT id, id, creation_time, false from users;"
|
||||
|
||||
@@conv_user_tables.each { |tbl|
|
||||
@@conv_user_tables.each do |tbl|
|
||||
rename_column tbl, :user_id, :changeset_id
|
||||
#foreign keys too
|
||||
# foreign keys too
|
||||
add_foreign_key tbl, :changesets, :name => "#{tbl}_changeset_id_fkey"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
# It's not easy to generate the user ids from the changesets
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
#drop_table "changesets"
|
||||
#drop_table "changeset_tags"
|
||||
fail ActiveRecord::IrreversibleMigration
|
||||
# drop_table "changesets"
|
||||
# drop_table "changeset_tags"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ class AddMoreChangesetIndexes < ActiveRecord::Migration
|
|||
def self.up
|
||||
add_index "changesets", ["created_at"], :name => "changesets_created_at_idx"
|
||||
add_index "changesets", ["closed_at"], :name => "changesets_closed_at_idx"
|
||||
add_index "changesets", ["min_lat","max_lat","min_lon","max_lon"], :name => "changesets_bbox_idx", :using => "GIST"
|
||||
add_index "changesets", %w(min_lat max_lat min_lon max_lon), :name => "changesets_bbox_idx", :using => "GIST"
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
@ -9,6 +9,6 @@ class AddForeignKeys < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
def self.down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
fail ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,6 @@ class CreateLanguages < ActiveRecord::Migration
|
|||
Language.load("#{Rails.root}/config/languages.yml")
|
||||
|
||||
add_foreign_key :users, :languages, :column => :locale, :primary_key => :code, :name => "users_locale_fkey"
|
||||
add_foreign_key :diary_entries, :languages, :column => :language_code , :primary_key => :code, :name => "diary_entries_language_code_fkey"
|
||||
add_foreign_key :diary_entries, :languages, :column => :language_code, :primary_key => :code, :name => "diary_entries_language_code_fkey"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class AddMessageSenderIndex < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_index :messages, [:from_user_id], :name=> "messages_from_user_id_idx"
|
||||
add_index :messages, [:from_user_id], :name => "messages_from_user_id_idx"
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :messages, :name=> "messages_from_user_id_idx"
|
||||
remove_index :messages, :name => "messages_from_user_id_idx"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'migrate'
|
|||
|
||||
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.where(:public => false).update_all(:visibility => "private")
|
||||
add_index :gpx_files, [:visible, :visibility], :name => "gpx_files_visible_visibility_idx"
|
||||
|
|
|
@ -32,7 +32,6 @@ class CreateOauthTables < ActiveRecord::Migration
|
|||
t.timestamps
|
||||
end
|
||||
add_index :oauth_nonces, [:nonce, :timestamp], :unique => true
|
||||
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
@ -40,5 +39,4 @@ class CreateOauthTables < ActiveRecord::Migration
|
|||
drop_table :oauth_tokens
|
||||
drop_table :oauth_nonces
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class AddFineOAuthPermissions < ActiveRecord::Migration
|
||||
PERMISSIONS = [:allow_read_prefs, :allow_write_prefs, :allow_write_diary,
|
||||
:allow_write_api, :allow_read_gpx, :allow_write_gpx ]
|
||||
:allow_write_api, :allow_read_gpx, :allow_write_gpx]
|
||||
|
||||
def self.up
|
||||
PERMISSIONS.each do |perm|
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'migrate'
|
|||
|
||||
class CreateUserRoles < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_enumeration :user_role_enum, ["administrator", "moderator"]
|
||||
create_enumeration :user_role_enum, %w(administrator moderator)
|
||||
|
||||
create_table :user_roles do |t|
|
||||
t.column :user_id, :bigint, :null => false
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'migrate'
|
|||
|
||||
class AddStatusToUser < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_enumeration :user_status_enum, ["pending","active","confirmed","suspended","deleted"]
|
||||
create_enumeration :user_status_enum, %w(pending active confirmed suspended deleted)
|
||||
|
||||
add_column :users, :status, :user_status_enum, :null => false, :default => "pending"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'migrate'
|
|||
|
||||
class AddMapBugTables < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_enumeration :map_bug_status_enum, ["open", "closed", "hidden"]
|
||||
create_enumeration :map_bug_status_enum, %w(open closed hidden)
|
||||
|
||||
create_table :map_bugs do |t|
|
||||
t.integer :latitude, :null => false
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'migrate'
|
|||
|
||||
class AddMapBugCommentEvent < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_enumeration :map_bug_event_enum, ["opened", "closed", "reopened", "commented", "hidden"]
|
||||
create_enumeration :map_bug_event_enum, %w(opened closed reopened commented hidden)
|
||||
|
||||
add_column :map_bug_comment, :event, :map_bug_event_enum
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ class MergeAclAddressAndMask < ActiveRecord::Migration
|
|||
|
||||
while netmask != "0.0.0.0"
|
||||
netmask = netmask << 1
|
||||
prefix = prefix + 1
|
||||
prefix += 1
|
||||
end
|
||||
|
||||
acl.address = "#{address.mask(prefix)}/#{prefix}"
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'migrate'
|
|||
|
||||
class AddTextFormat < ActiveRecord::Migration
|
||||
def up
|
||||
create_enumeration :format_enum, ["html", "markdown", "text"]
|
||||
create_enumeration :format_enum, %w(html markdown text)
|
||||
add_column :users, :description_format, :format_enum, :null => false, :default => "html"
|
||||
add_column :user_blocks, :reason_format, :format_enum, :null => false, :default => "html"
|
||||
add_column :diary_entries, :body_format, :format_enum, :null => false, :default => "html"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue