I know that there is a rename_column
transformation, but it seems that rename_index
does not exist.
Do I have to use remove_index
and add_index
instead?
You can change the migration file name, but you have to perform a few steps: rake db:rollback to the point that queries table is rolled back. Now change the name of migration file, also the contents. Change the name of any Model that may use the table.
Click the plus sign to expand the table on which you want to rename an index. Click the plus sign to expand the Indexes folder. Right-click the index you want to rename and select Rename. Type the index's new name and press Enter.
A Rails migration is a tool for changing an application's database schema. Instead of managing SQL scripts, you define database changes in a domain-specific language (DSL). The code is database-independent, so you can easily move your app to a new platform.
An index is used to speed up the performance of queries on a database. Rails allows us to create index on a database column by means of a migration. By default, the sort order for the index is ascending. But consider the case where we are fetching reports from the database.
rename_index
should be given strings and not symbols.
rename_index :table_name, 'old_name', 'new_name'
Had me scratching my head for a while when trying to rename a table and it's indexes. Rails 3.2.3 and MySQL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With