You can rename the tables and columns using Rails database migration.
You can create a migration file to rename a table and another one to rename its columns.
Let's say we want to rename the emailSubscriptions
table.
> bundle exec rails generate migrations rename_email_subscriptions
# this creates db/migrate/xxxxxxxx_rename_email_subscriptions.rb
Edit the migration file
# this creates db/migrate/xxxxxxxx_rename_email_subscriptions.rb
class RenameEmailSubscriptions < ActiveRecord::Migration
def change
rename_table :emailSubscriptions, :email_subscriptions
end
end
And for the columns
> bundle exec rails generate migrations rename_email_subscriptions_columns
# this creates db/migrate/xxxxxxxx_rename_email_subscriptions_columns.rb
Edit the migration file
# this creates db/migrate/xxxxxxxx_rename_email_subscriptions_columns.rb
class RenameEmailSubscriptionsColumns < ActiveRecord::Migration
def change
change_table :email_subscriptions do |t|
t.rename :columnName1, :column_name_1
t.rename :columnName2, :column_name_2
t.rename :columnName3, :column_name_3
t.rename :columnName4, :column_name_4
end
end
end
Run bundle exec rake db:migrate
Do this for all the tables and their corresponding columns.
Note that I decided to split the migrations for renaming a table and its columns in order to make it possible to rollback the migrations.