Ruby on Rails で、SQLite を利用している時にマイグレーションで「create_index」を行うとエラーになってしまう。

One Comment

  1. fumiu says:

    以下のrequireを先頭に追加してから、その下の3行をマイグレーション本文に追加するとSQLite以外でのみcreate_indexされるようにできます。

    require 'active_record/connection_adapters/sqlite_adapter'
    
    unless connection.kind_of?(ActiveRecord::ConnectionAdapters::SQLiteAdapter)
      create_index :table, :col
    end
    

Leave a Reply