Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何创建一个;核对无酶“;迁移中的表中的列?_Ruby On Rails_Sqlite_Migration_Collation - Fatal编程技术网

Ruby on rails 如何创建一个;核对无酶“;迁移中的表中的列?

Ruby on rails 如何创建一个;核对无酶“;迁移中的表中的列?,ruby-on-rails,sqlite,migration,collation,Ruby On Rails,Sqlite,Migration,Collation,这个问题的答案是: 说明如何创建具有“COLLATE NOCASE”列的表 我的问题是如何在rails迁移中创建这样的列? i、 e.从何而来 create table Test ( Text_Value text collate nocase ); create index Test_Text_Value_Index on Test (Text_Value collate nocase); 做: 我添加了新迁移,删除并重新创建了索引,如下所示: class AddIndexToW

这个问题的答案是: 说明如何创建具有“COLLATE NOCASE”列的表

我的问题是如何在rails迁移中创建这样的列? i、 e.从何而来

create table Test
(
  Text_Value  text collate nocase
);

create index Test_Text_Value_Index
  on Test (Text_Value collate nocase);
做:


我添加了新迁移,删除并重新创建了索引,如下所示:

class AddIndexToWordVariations < ActiveRecord::Migration

  def change

    remove_index :word_variations, :variation_word

    add_index :word_variations, :variation_word, :COLLATE => :NOCASE

  end

end
class addindextowordvariances:NOCASE
结束
结束

其中“word\u variances”是我的表

我添加了新的迁移,删除并重新创建了索引,如下所示:

class AddIndexToWordVariations < ActiveRecord::Migration

  def change

    remove_index :word_variations, :variation_word

    add_index :word_variations, :variation_word, :COLLATE => :NOCASE

  end

end
class addindextowordvariances:NOCASE
结束
结束

其中“word\u variances”是供人们搜索的我的表格,如果“collate”在您的rails版本中仍然不可用(您将得到“Unknown key::collate”),那么您必须手动创建索引:

execute("create index Test_Text_Value_Index on Test (Text_Value collate nocase);")

在“def up”(drop_table)中(“drop_table”也会在“def down”中删除索引)

对于用户搜索,如果“collate”在您的rails版本中仍然不可用(您将获得“Unknown key::collate”),那么您必须手动创建索引:

execute("create index Test_Text_Value_Index on Test (Text_Value collate nocase);")

在“def up”中(“drop_table”也会在“def down”中删除索引)

这可能不在sqlite3上(至少不在2013年),仅用于人员搜索:可能不在sqlite3上(至少不在2013年),仅用于人员搜索: