Add migration to set all the mod#author from mod#authors
parent
acd153add3
commit
84d4a3fadc
|
@ -36,8 +36,8 @@ class Mod < ActiveRecord::Base
|
|||
has_many :game_versions, -> { uniq.sort_by_older_to_newer }, through: :mod_game_versions
|
||||
has_many :categories, through: :categories_mods
|
||||
has_many :categories_mods, dependent: :destroy
|
||||
# has_many :authors, ->{ includes(:authors_mods).order('authors_mods.sort_order') }, through: :authors_mods
|
||||
# has_many :authors_mods, dependent: :destroy
|
||||
has_many :authors, ->{ includes(:authors_mods).order('authors_mods.sort_order') }, through: :authors_mods
|
||||
has_many :authors_mods, dependent: :destroy
|
||||
|
||||
# has_one :latest_version, -> { sort_by_newer_to_older.limit(1) }, class_name: 'ModVersion'
|
||||
# has_one :second_latest_version, -> { sort_by_newer_to_older.limit(1).offset(1) }, class_name: 'ModVersion'
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class SetModAuthorsToModAuthor < ActiveRecord::Migration
|
||||
def change
|
||||
Mod.all.each do |mod|
|
||||
# Not really related, but this was pending from another previous migration
|
||||
mod.info_json_name = mod.slug if mod.info_json_name.blank?
|
||||
|
||||
# We don't really have more than 1 author for each mod on production
|
||||
# Well, I think we have 1, but it's not worth it to make something more complex
|
||||
mod.author = mod.authors.first
|
||||
mod.save!
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150807104820) do
|
||||
ActiveRecord::Schema.define(version: 20150807140522) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
Loading…
Reference in New Issue