houdini/db/migrate/20181002160627_correct_dedications.rb

31 lines
728 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-10-02 16:12:16 +00:00
class CorrectDedications < ActiveRecord::Migration
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 16:12:16 +00:00
SQL
dedications = MaintainDedications.retrieve_non_json_dedications
2018-10-02 16:12:16 +00:00
MaintainDedications.create_json_dedications_from_plain_text(dedications)
2018-10-02 16:12:16 +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
def down; end
2018-10-02 16:12:16 +00:00
end