summaryrefslogtreecommitdiff
path: root/db/migrate/20150509180749_convert_legacy_reference_notes.rb
blob: 84d4eb9e51fded69fbd4a81dd71d85227f217606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Convert legacy Markdown-emphasized notes to the current, non-emphasized format
#
#   _mentioned in 54f7727c850972f0401c1312a7c4a6a380de5666_
#
# becomes
#
#   mentioned in 54f7727c850972f0401c1312a7c4a6a380de5666
class ConvertLegacyReferenceNotes < ActiveRecord::Migration[4.2]
  def up
    quoted_column_name = ActiveRecord::Base.connection.quote_column_name('system')
    execute %Q{UPDATE notes SET note = trim(both '_' from note) WHERE #{quoted_column_name} = true AND note LIKE '\_%\_'}
  end

  def down
    # noop
  end
end