# typed: strict
# frozen_string_literal: true

class RemoveJsonAttributesFromDomainPostFiles < ActiveRecord::Migration[7.2]
  extend T::Sig

  sig { void }
  def change
    remove_index :domain_post_files,
                 "((json_attributes->>'ib_id')::integer)",
                 where: "type = 'Domain::PostFile::InkbunnyPostFile'",
                 name: "idx_domain_inkbunny_post_files_on_ib_id",
                 unique: true

    remove_index :domain_post_files,
                 "lower((json_attributes->>'url_str')::text) text_pattern_ops",
                 name: "idx_domain_post_files_on_url_str_lower"

    remove_index :domain_post_files,
                 "reverse(lower((json_attributes->>'url_str')::text)) text_pattern_ops",
                 name: "idx_domain_post_files_on_url_str_lower_reverse"

    remove_column :domain_post_files, :json_attributes, :jsonb, default: {}

    mirai_tablespace!(both_ways: true)
  end
end
