Avoid more models in old migrations
Although these migrations run fine today, they could break in the future if changes are made to the current model code.
This commit is contained in:
parent
6ebb21b660
commit
d130db9fa8
14 changed files with 56 additions and 0 deletions
|
@ -1,6 +1,10 @@
|
|||
require "migrate"
|
||||
|
||||
class TileTracepoints < ActiveRecord::Migration[4.2]
|
||||
class Tracepoint < ActiveRecord::Base
|
||||
self.table_name = "gps_points"
|
||||
end
|
||||
|
||||
def self.up
|
||||
add_column "gps_points", "tile", :bigint
|
||||
add_index "gps_points", ["tile"], :name => "points_tile_idx"
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
require "migrate"
|
||||
|
||||
class TileNodes < ActiveRecord::Migration[4.2]
|
||||
class Node < ActiveRecord::Base
|
||||
self.table_name = "current_nodes"
|
||||
end
|
||||
|
||||
class OldNode < ActiveRecord::Base
|
||||
self.table_name = "nodes"
|
||||
end
|
||||
|
||||
def self.upgrade_table(from_table, to_table, model)
|
||||
if ENV["USE_DB_FUNCTIONS"]
|
||||
execute <<-SQL
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class AddEmailValid < ActiveRecord::Migration[4.2]
|
||||
class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
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
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
require "migrate"
|
||||
|
||||
class AddMoreControlsToGpxFiles < ActiveRecord::Migration[4.2]
|
||||
class Trace < ActiveRecord::Base
|
||||
self.table_name = "gpx_files"
|
||||
end
|
||||
|
||||
def self.up
|
||||
create_enumeration :gpx_visibility_enum, %w[private public trackable identifiable]
|
||||
add_column :gpx_files, :visibility, :gpx_visibility_enum, :default => "public", :null => false
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
require "migrate"
|
||||
|
||||
class AlterUserRolesAndBlocks < ActiveRecord::Migration[4.2]
|
||||
class UserRole < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.up
|
||||
# the initial granter IDs can be "self" - there are none of these
|
||||
# in the current live DB, but there may be some in people's own local
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
require "migrate"
|
||||
|
||||
class AddStatusToUser < ActiveRecord::Migration[4.2]
|
||||
class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.up
|
||||
create_enumeration :user_status_enum, %w[pending active confirmed suspended deleted]
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class AddTermsSeenToUser < ActiveRecord::Migration[4.2]
|
||||
class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.up
|
||||
add_column :users, :terms_seen, :boolean, :null => false, :default => false
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ class IPAddr
|
|||
end
|
||||
|
||||
class MergeAclAddressAndMask < ActiveRecord::Migration[4.2]
|
||||
class Acl < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def up
|
||||
Acl.find_each do |acl|
|
||||
address = IPAddr.new(acl.address)
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
class AddCounterCaches < ActiveRecord::Migration[4.2]
|
||||
class Changeset < ActiveRecord::Base
|
||||
end
|
||||
|
||||
class Trace < ActiveRecord::Base
|
||||
self.table_name = "gpx_files"
|
||||
end
|
||||
|
||||
def self.up
|
||||
add_column :users, :changesets_count, :integer, :null => false, :default => 0
|
||||
add_column :users, :traces_count, :integer, :null => false, :default => 0
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
class AddDiaryEntryCounterCaches < ActiveRecord::Migration[4.2]
|
||||
class DiaryEntry < ActiveRecord::Base
|
||||
end
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.up
|
||||
add_column :users, :diary_entries_count, :integer, :null => false, :default => 0
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class AddImageUseGravatarToUsers < ActiveRecord::Migration[4.2]
|
||||
class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.up
|
||||
add_column :users, :image_use_gravatar, :boolean, :null => false, :default => false
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class SubscribeOldChangesets < ActiveRecord::Migration[4.2]
|
||||
class Changeset < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def up
|
||||
Changeset.find_each do |changeset|
|
||||
changeset.subscribers << changeset.user unless changeset.subscribers.exists?(changeset.user.id)
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class RenameOpenidUrl < ActiveRecord::Migration[4.2]
|
||||
class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def change
|
||||
rename_column :users, :openid_url, :auth_uid
|
||||
add_column :users, :auth_provider, :string
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class SubscribeAuthorsToDiaryEntries < ActiveRecord::Migration[4.2]
|
||||
class DiaryEntry < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def up
|
||||
DiaryEntry.find_each do |diary_entry|
|
||||
diary_entry.subscriptions.create(:user => diary_entry.user) unless diary_entry.subscribers.exists?(diary_entry.user.id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue