# typed: strict
require_relative "../../app/lib/json_attr_helpers"
class MigrateE621ColumnsToJsonAttrs < ActiveRecord::Migration[7.2]
  extend T::Sig
  include JsonAttrHelpers

  sig { void }
  def change
    migrate_json_table("domain_e621_posts") do
      migrate_column("tags_array", :jsonb, :jsonb)
      migrate_column("flags_array", :jsonb, :jsonb)
      migrate_column("pools_array", :jsonb, :jsonb)
      migrate_column("sources_array", :jsonb, :jsonb)
      migrate_column("artists_array", :jsonb, :jsonb)
      migrate_json_column("state_detail", "e621_updated_at")
      migrate_json_column("state_detail", "last_index_page_id")
      migrate_json_column("state_detail", "index_page_ids")
      migrate_json_column("state_detail", "prev_md5s")
      migrate_json_column("state_detail", "caused_by_entry_id")
      migrate_json_column("state_detail", "scan_log_entry_id")
      migrate_json_column("state_detail", "scan_error")
      migrate_json_column("state_detail", "file_error")
    end
  end
end
