houdini/db/migrate/20181002160627_correct_dedications.rb

31 lines
733 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2019-11-14 14:47:53 -06:00
class CorrectDedications < ActiveRecord::Migration[4.2]
2018-10-02 11:12:16 -05:00
def up
execute <<~SQL
create or replace function is_valid_json(p_json text)
returns boolean
as
$$
begin
return (p_json::json is not null);
exception
when others then
return false;
end;
$$
language plpgsql
immutable;
2018-10-02 11:12:16 -05:00
SQL
dedications = MaintainDedications.retrieve_non_json_dedications
2018-10-02 11:12:16 -05:00
MaintainDedications.create_json_dedications_from_plain_text(dedications)
2018-10-02 11:12:16 -05:00
dedications = MaintainDedications.retrieve_json_dedications
MaintainDedications.add_honor_to_any_json_dedications_without_type(dedications)
2018-10-02 11:12:16 -05:00
end
def down; end
2018-10-02 11:12:16 -05:00
end