I made a database with rails generate model User password:string …
now I want to delete the password attribute, because I’m going to encrypt it before saving, so I want to make an attribute with name encrypted_password instead of password.
How can I do that without deleting the whole file of migration and making all from scratch?
Thank you
I made a database with rails generate model User password:string …
now I want to delete the password attribute, because I’m going to encrypt it before saving, so I want to make an attribute with name encrypted_password instead of password.
How can I do that without deleting the whole file of migration and making all from scratch?
you can do this by creating a NEW migration like
add_column :users, :encrypted_password, :string
insert here the steps that will convert password to encrypted_password
remove_column :users, :password
or use devise/authlogic.
Thank, one more thing, is there a way to alter only the original migration so all the attributes stay listed in the same file and that can be easily altered?
Thank, one more thing, is there a way to alter only the original migration so all the attributes stay listed in the same file and that can be easily altered?
The best practice would be to create a new migration everytime you want to change the
database structure.
Sure, you can edit the previous migrations but you have to drop your database before you
can run the migration. Also, editing a migration will cause lots of confusion if it’s already
pushed to the remote repository and some other developers have already ran them.
I’m working alone o this project so it won’t be a problem.
How can I do that? I mean, drop the database?
I did change the migration, but when I rake db:migrate, the schema just gets back to what it was (I edited the schema too)
Forget it, I just did what you said and it worked =)
thank you very much