class CreateSofurryTypes < ActiveRecord::Migration[7.2]
  def change
    mirai_tablespace!

    add_json_index(
      :domain_users,
      :sofurry_id,
      :integer,
      where: "type = 'Domain::User::SofurryUser'",
      unique: true,
    )

    add_json_index(
      :domain_users,
      :username,
      :text,
      where: "type = 'Domain::User::SofurryUser'",
      unique: true,
    )

    add_json_index(
      :domain_users,
      :useralias,
      :text,
      where: "type = 'Domain::User::SofurryUser'",
      unique: true,
    )

    add_json_index(
      :domain_posts,
      :sofurry_id,
      :integer,
      where: "type = 'Domain::Post::SofurryPost'",
      unique: true,
    )

    add_json_index(
      :domain_post_groups,
      :sofurry_id,
      :integer,
      where: "type = 'Domain::PostGroup::SofurryFolder'",
      unique: true,
    )

    add_json_index(
      :domain_post_groups,
      :owner_id,
      :integer,
      where: "type = 'Domain::PostGroup::SofurryFolder'",
    )
  end
end
