2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-02 16:12:16 +00:00
|
|
|
class CorrectDedications < ActiveRecord::Migration
|
|
|
|
def up
|
2019-07-30 21:29:24 +00:00
|
|
|
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 16:12:16 +00:00
|
|
|
SQL
|
|
|
|
|
2018-10-04 20:29:30 +00:00
|
|
|
dedications = MaintainDedications.retrieve_non_json_dedications
|
2018-10-02 16:12:16 +00:00
|
|
|
|
2018-10-04 20:29:30 +00:00
|
|
|
MaintainDedications.create_json_dedications_from_plain_text(dedications)
|
2018-10-02 16:12:16 +00:00
|
|
|
|
2018-10-04 20:29:30 +00:00
|
|
|
dedications = MaintainDedications.retrieve_json_dedications
|
|
|
|
MaintainDedications.add_honor_to_any_json_dedications_without_type(dedications)
|
2018-10-02 16:12:16 +00:00
|
|
|
end
|
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
def down; end
|
2018-10-02 16:12:16 +00:00
|
|
|
end
|