# typed: true
class CreateDomainFaPostFactors < ActiveRecord::Migration[7.0]
  def change
    create_table :domain_fa_post_factors do |t|
      t.references :post, index: { unique: true }, null: false
      t.vector :for_favorite, limit: 32
      t.timestamps
    end

    add_index :domain_fa_post_factors,
              :for_favorite,
              using: :ivfflat,
              opclass: :vector_l2_ops
    add_foreign_key :domain_fa_post_factors,
                    :domain_fa_posts,
                    column: :post_id,
                    primary_key: :id,
                    validate: true
  end
end
