Nicolae Claudius
13 years ago
5 changed files with 46 additions and 4 deletions
@ -0,0 +1,15 @@ |
|||||||
|
class AddNameReversedToDomains < ActiveRecord::Migration |
||||||
|
def up |
||||||
|
# used for "%" search indexing in an ancestry fashion (materialized path pattern) |
||||||
|
# http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html |
||||||
|
add_column :domains, :name_reversed, :string, :limit => 255 |
||||||
|
execute "UPDATE domains SET name_reversed = REVERSE(name)" |
||||||
|
change_column :domains, :name_reversed, :string, :limit => 255, :null => false |
||||||
|
add_index :domains, :name_reversed |
||||||
|
end |
||||||
|
|
||||||
|
def down |
||||||
|
remove_index :domains, :column => :name_reversed |
||||||
|
remove_column :domains, :name_reversed |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue