How to define a full text index for sqlite in Rails migration?

539 Views Asked by At

The following migration for sqlite:

class CreateCeDicts < ActiveRecord::Migration
  def change
    create_table :ce_dicts do |t|
      t.string :hant
      t.string :hans
      t.string :pinyin
      t.string :english
    end
    add_index :ce_dicts, :hant
    add_index :ce_dicts, :hans
    add_index(:ce_dicts, :english, type: :fulltext)
  end
end

gives an error:

SQLite3::SQLException: near "fulltext": syntax error: CREATE fulltext INDEX "index_ce_dicts_on_english" ON "ce_dicts" ("english")

as :fulltext is only supported for MySQL.

How can I define a sqlite fulltext search index in Rails migration?

0

There are 0 best solutions below