houdini/db/migrate/20181002160627_correct_dedications.rb
2019-11-14 14:52:29 -06:00

30 lines
733 B
Ruby

# frozen_string_literal: true
class CorrectDedications < ActiveRecord::Migration[4.2]
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;
SQL
dedications = MaintainDedications.retrieve_non_json_dedications
MaintainDedications.create_json_dedications_from_plain_text(dedications)
dedications = MaintainDedications.retrieve_json_dedications
MaintainDedications.add_honor_to_any_json_dedications_without_type(dedications)
end
def down; end
end