samedi 16 juin 2018

Changing Column name in SQLite Database

I created a wrong column name in my reservations table by typing this in the terminal:

rails g model Reservation room:references

BUT i now want the column name change from room_id to wall_id

I tried to run this in my terminal:

rails g migration change_column_name

In the then created file i typed:

class ChangeColumnName < ActiveRecord::Migration[5.1]
def change
rename_column :reservations, :room, :wall
end
end

But after i run rails db:migrate this shows up in the Terminal:

rails aborted! StandardError: An error has occurred, this and all later migrations canceled: No such column: reservations.room

What am i doing wrong in the changing process?

Aucun commentaire:

Enregistrer un commentaire