Removes second_user_id and third_user_id From the Articles Table (#10383) [deploy]
* Removes second_user_id and third_user_id from the Articles table * Adds updated schema file to (fingers crossed) resolve Travis failure * Adds gaurd clause to data_update script to mitigate db issues
This commit is contained in:
parent
aa39a1f801
commit
8a01ed6a2c
3 changed files with 11 additions and 2 deletions
|
|
@ -0,0 +1,8 @@
|
|||
class RemoveColumnsFromArticles < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
safety_assured do
|
||||
remove_column :articles, :second_user_id, :bigint
|
||||
remove_column :articles, :third_user_id, :bigint
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -137,12 +137,10 @@ ActiveRecord::Schema.define(version: 2020_10_02_104711) do
|
|||
t.integer "score", default: 0
|
||||
t.string "search_optimized_description_replacement"
|
||||
t.string "search_optimized_title_preamble"
|
||||
t.bigint "second_user_id"
|
||||
t.boolean "show_comments", default: true
|
||||
t.text "slug"
|
||||
t.string "social_image"
|
||||
t.integer "spaminess_rating", default: 0
|
||||
t.bigint "third_user_id"
|
||||
t.string "title"
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "user_id"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
module DataUpdateScripts
|
||||
class BackfillCoAuthorIdsForArticles
|
||||
def run
|
||||
return unless ActiveRecord::Base.connection.column_exists?(:articles, :second_user_id) ||
|
||||
ActiveRecord::Base.connection.column_exists?(:articles, :third_user_id)
|
||||
|
||||
articles = Article.where.not(second_user_id: nil).or(Article.where.not(third_user_id: nil))
|
||||
articles.find_each do |article|
|
||||
co_author_ids = [article.second_user_id, article.third_user_id].compact
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue