Created
November 16, 2011 19:42
-
-
Save fayimora/1371109 to your computer and use it in GitHub Desktop.
Database Migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AlterUsers < ActiveRecord::Migration | |
def up | |
rename_table("users", "admin_users") | |
add_column("admin_users", "username", :string, :limit => 25 ) | |
change_column("admin_users", "email", :string, :limit => 100 ) | |
rename_column("admin_users", "password", "hashed_password") | |
add_column("admin_users", "salt", :string, :limit => 40 ) | |
puts "*********ABOUT TO ADD INDEX************" | |
add_index("admin_users", "username") | |
end | |
def down | |
remove_index("admin_users", "username") | |
remove_column("admin_users", "salt" ) | |
rename_column("admin_users", "hashed_password", "password") | |
change_column("admin_users", "email", :string, :limit => 100 ) | |
remove_column("admin_users", "username") | |
rename_table("admin_users", "users") | |
end | |
end | |
################## ERROR ########################## | |
fayimora [simple_cms (master)]$ rake db:migrate VERSION=0 | |
== AlterUsers: reverting ===================================================== | |
-- remove_index("admin_users", "username") | |
rake aborted! | |
An error has occurred, all later migrations canceled: | |
Index name 'index_admin_users_on_username' on table 'admin_users' does not exist | |
Tasks: TOP => db:migrate | |
(See full trace by running task with --trace) | |
fayimora [simple_cms (master)]$ rake db:migrate VERSION=0 | |
== AlterUsers: reverting ===================================================== | |
-- remove_index("admin_users", "username") | |
rake aborted! | |
An error has occurred, all later migrations canceled: | |
Index name 'index_admin_users_on_username' on table 'admin_users' does not exist | |
Tasks: TOP => db:migrate | |
(See full trace by running task with --trace) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment