Method: ActiveRecord::LiteTable::Validator#index
- Defined in:
- lib/vex/active_record/lite_table.rb
#index(column_name, options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/vex/active_record/lite_table.rb', line 56 def index(column_name, ={}) begin klass.connection.add_index klass.table_name, column_name, rescue # TODO: It would be *great* to have a unique exception type here! # But even in this case we have to check the options for identity! case $! when ActiveRecord::StatementInvalid, SQLite3::SQLException return if $!.to_s =~ /Duplicate key name/ # for MySQL return if $!.to_s =~ /index .* already exists/ # for Sqlite3 return if $!.to_s =~ /relation .* already exists/ # for Postgresql end raise end end |