Sha256: 79310b36526a957682ac349499c5fd085ac8452166f77fb6cac080245617f534
Contents?: true
Size: 801 Bytes
Versions: 12
Compression:
Stored size: 801 Bytes
Contents
class ConvertPullRequestLabelsToArray < ActiveRecord::Migration def up rename_column :pull_requests, :labels, :old_labels add_column :pull_requests, :labels, :text, array: true, default: [] Github::PullRequest.reset_column_information Github::PullRequest.pluck(:id, :old_labels).each do |id, old_labels| Github::PullRequest.where(id: id).update_all(labels: old_labels.split(/\n/)) end end def down raise IrreversibleMigration unless Github::PullRequest.column_names.member? "old_labels" Github::PullRequest.pluck(:id, :labels).each do |id, labels| Github::PullRequest.where(id: id).update_all(old_labels: Array(labels).uniq.join("\n")) end remove_column :pull_requests, :labels rename_column :pull_requests, :old_labels, :labels end end
Version data entries
12 entries across 12 versions & 1 rubygems