This makes the index a unique index, which will allow
only one instance of any combination of tractor_id and farmer_id.
By default, the name of the index is tablename_allcolumnnames_index. If you didn??™t want
the index on the cows table to be named cows_farmer_id_index, you could specify the :name
option (as has been done in the preceding example). However, since Active Record doesn??™t
really care about the name of the index, it??™s not terribly important to have a nice name on it.
The syntax for removing the index depends on how it was named in the first place. If you
let the standard Active Record index naming take place, then you do not need to specify the
index name, as it will be assumed:
remove_index :ownerships, :column => [:farmer_id, :tractor_id]
However, if you did not take the standard Active Record name, you will need to explicitly
specify the index name in order to successfully remove it:
remove_index :cows, :name => "index_on_cows_for_farmers"
You should note that if you??™re going to remove an index and a table at the same time, it??™s
important to remove the index first.
Pages:
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164