Issue with rake db:migrate whilst setting up pins scaffold - ruby-on-rails

I have been having some issues with rake db:migrate while setting up a pins scaffold for the One Mont Rails tutorial. When I try to migrate in the terminal I get the following error:
Taylors-MacBook-Pro:pinteresting taylorburton$ bin/rake db:migrate RAILS_ENV=development
== 20150410031405 AddUserIdToPins: migrating ==================================
-- add_column(:pins, :user_id, :integer)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: duplicate column name: user_id: ALTER TABLE "pins" ADD "user_id" integer/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:91:in `initialize'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:91:in `new'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:91:in `prepare'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:134:in `execute'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:333:in `block in execute'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `block in log'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598#global/gems/activesupport-4.2.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:460:in `log'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:333:in `execute'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:381:in `add_column'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:458:in `add_column'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:662:in `block in method_missing'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:632:in `block in say_with_time'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:632:in `say_with_time'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:652:in `method_missing'
/Users/taylorburton/Desktop/pinteresting/db/migrate/20150410031405_add_user_id_to_pins.rb:3:in `change'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:606:in `exec_migration'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:590:in `block (2 levels) in migrate'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:589:in `block in migrate'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:588:in `migrate'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:765:in `migrate'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:995:in `block in execute_migration_in_transaction'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:1041:in `block in ddl_transaction'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/transactions.rb:220:in `transaction'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:1041:in `ddl_transaction'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:994:in `execute_migration_in_transaction'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:956:in `block in migrate'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:952:in `each'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:952:in `migrate'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:820:in `up'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/migration.rb:798:in `migrate'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598#global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598#global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598#global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/taylorburton/.rvm/gems/ruby-2.0.0-p598#global/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
-e:1:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Taylors-MacBook-Pro:pinteresting taylorburton$

Read the error message carefully. It says:
duplicate column name: user_id: ALTER TABLE "pins" ADD "user_id"
This means user_id is already present in pins table when your migration is being carried out, which was unexpected. Hence the error.
If you drop user_id column from pins table this error will go and hopefully migration will succeed. However manually (by this I mean using SQL commands) altering Rails database is not recommended and in fact that itself is very likely to be the reason behind this error in first place.
Alternatively, if you dont care about any existing data, you can also do:
rake db:reset
Followed by rake db:migrate

Related

Migration not working in Ruby On Rails

For some reason or another my Ruby on Rails application is telling me that it can't run migrations. I an unsure how to fix this. I created a table with no information by accident. I then tried to delete the migration file and the table that it created. When I try to run the migration command it gives me this error:
rails aborted!
Don't know how to build task 'db:migration' (see --tasks)
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/railties-5.0.0/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/railties-5.0.0/lib/rails/commands/rake_proxy.rb:10:in `run_rake_task'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/railties-5.0.0/lib/rails/commands.rb:18:in `<top (required)>'
/home/ubuntu/workspace/saasapp/bin/rails:9:in `require'
/home/ubuntu/workspace/saasapp/bin/rails:9:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `load'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `call'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/spring-1.7.2/lib/spring/client/command.rb:7:in `call'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/spring-1.7.2/lib/spring/client.rb:30:in `run'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/spring-1.7.2/bin/spring:49:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `load'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `<top (required)>'
/home/ubuntu/workspace/saasapp/bin/spring:15:in `require'
/home/ubuntu/workspace/saasapp/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
(See full trace by running task with --trace)
Can someone please help me fix this issue. I need to remove the existing table so that I can create the correct one. It won't populate my schema file.
This is the error that I get when I run rake db:migrate
rake db:migrate
== 20170322214259 CreateProfiles: migrating ===================================
-- change_table(:profiles)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: Cannot add a NOT NULL column with default value NULL: ALTER TABLE "profiles" ADD "created_at" datetime NOT NULL
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in initialize'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:innew'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in prepare'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:137:inexecute'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:232:in block in execute'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:566:inblock in log'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activesupport-5.0.0/lib/active_support/notifications/instrumenter.rb:21:in instrument'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:560:inlog'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:232:in execute'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:547:inadd_column'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:373:in add_column'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:1096:inadd_timestamps'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_definitions.rb:525:in timestamps'
/home/ubuntu/workspace/saasapp/db/migrate/20170322214259_create_profiles.rb:11:inblock in change'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:443:in change_table'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:845:inblock in method_missing'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:814:in block in say_with_time'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:814:insay_with_time'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:834:in method_missing'
/home/ubuntu/workspace/saasapp/db/migrate/20170322214259_create_profiles.rb:3:inchange'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:788:in exec_migration'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:772:inblock (2 levels) in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:771:in block in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:inwith_connection'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:770:in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:950:inmigrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1211:in block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1279:inblock in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in block in transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/transaction.rb:189:inwithin_new_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/transactions.rb:211:intransaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1279:in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1210:inexecute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1183:in block in migrate_without_lock'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1182:ineach'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1182:in migrate_without_lock'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1133:inmigrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1005:in up'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:983:inmigrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/tasks/database_tasks.rb:161:in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/railties/databases.rake:58:inblock (2 levels) in '
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/rake-12.0.0/exe/rake:27:in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/bin/ruby_executable_hooks:15:ineval'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/bin/ruby_executable_hooks:15:in <main>'
ActiveRecord::StatementInvalid: SQLite3::SQLException: Cannot add a NOT NULL column with default value NULL: ALTER TABLE "profiles" ADD "created_at" datetime NOT NULL
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:ininitialize'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in new'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:inprepare'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:137:in execute'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:232:inblock in execute'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:566:in block in log'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activesupport-5.0.0/lib/active_support/notifications/instrumenter.rb:21:ininstrument'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:560:in log'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:232:inexecute'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:547:in add_column'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:373:inadd_column'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:1096:in add_timestamps'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_definitions.rb:525:intimestamps'
/home/ubuntu/workspace/saasapp/db/migrate/20170322214259_create_profiles.rb:11:in block in change'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:443:inchange_table'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:845:in block in method_missing'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:814:inblock in say_with_time'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:814:in say_with_time'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:834:inmethod_missing'
/home/ubuntu/workspace/saasapp/db/migrate/20170322214259_create_profiles.rb:3:in change'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:788:inexec_migration'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:772:in block (2 levels) in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:771:inblock in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in with_connection'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:770:inmigrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:950:in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1211:inblock in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1279:in block in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:232:inblock in transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/transaction.rb:189:in within_new_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:232:intransaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/transactions.rb:211:in transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1279:inddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1210:in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1183:inblock in migrate_without_lock'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1182:in each'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1182:inmigrate_without_lock'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1133:in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1005:inup'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:983:in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/tasks/database_tasks.rb:161:inmigrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/railties/databases.rake:58:in block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/rake-12.0.0/exe/rake:27:in'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/bin/ruby_executable_hooks:15:in eval'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/bin/ruby_executable_hooks:15:in'
SQLite3::SQLException: Cannot add a NOT NULL column with default value NULL
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in initialize'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:innew'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:91:in prepare'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/sqlite3-1.3.13/lib/sqlite3/database.rb:137:inexecute'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:232:in block in execute'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:566:inblock in log'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activesupport-5.0.0/lib/active_support/notifications/instrumenter.rb:21:in instrument'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:560:inlog'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:232:in execute'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:547:inadd_column'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:373:in add_column'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:1096:inadd_timestamps'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_definitions.rb:525:in timestamps'
/home/ubuntu/workspace/saasapp/db/migrate/20170322214259_create_profiles.rb:11:inblock in change'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:443:in change_table'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:845:inblock in method_missing'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:814:in block in say_with_time'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:814:insay_with_time'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:834:in method_missing'
/home/ubuntu/workspace/saasapp/db/migrate/20170322214259_create_profiles.rb:3:inchange'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:788:in exec_migration'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:772:inblock (2 levels) in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:771:in block in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:inwith_connection'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:770:in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:950:inmigrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1211:in block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1279:inblock in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in block in transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/transaction.rb:189:inwithin_new_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/transactions.rb:211:intransaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1279:in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1210:inexecute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1183:in block in migrate_without_lock'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1182:ineach'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1182:in migrate_without_lock'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1133:inmigrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:1005:in up'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/migration.rb:983:inmigrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/tasks/database_tasks.rb:161:in migrate'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/activerecord-5.0.0/lib/active_record/railties/databases.rake:58:inblock (2 levels) in '
/usr/local/rvm/gems/ruby-2.3.0#saasapp/gems/rake-12.0.0/exe/rake:27:in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/bin/ruby_executable_hooks:15:ineval'
/usr/local/rvm/gems/ruby-2.3.0#saasapp/bin/ruby_executable_hooks:15:in `'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
In addition to my comment suggesting you use rake db:migrate instead of rake db:migration:
I also suggest you look into rake db:rollback if you find you've made a mistake while generating your model/migration.
I believe you've used migration instead of migrate
rake db:migrate

Rails Migration Error - StandardError: An error has occurred, this and all later migrations canceled:

Using Rails 4.2, Ruby 2.2, OSX 10.10
I initially added a migration to my Movies table.
rails g migration addFieldsToMovies
invoke active_record
create db/migrate/20150616125848_add_fields_to_movies.rb
Then migrated to the database:
rake db:migrate
== 20150616125848 AddFieldsToMovies: migrating ================================
-- add_column(:movies, :description, :description)
-> 0.0006s
-- add_column(:movies, :release_date, :datetime)
-> 0.0003s
== 20150616125848 AddFieldsToMovies: migrated (0.0009s) =======================
I then realized I put the wrong data type on the description field. So I created a migration file like:
rails g migration change_description_type_in_my_table
invoke active_record
create db/migrate/20150616130929_change_description_type_in_my_table.rb
I added the change method to the migration file 20150616130929_change_description_type_in_my_table.rb to edit the field type to text:
class ChangeDescriptionTypeInMyTable < ActiveRecord::Migration
def change
change_column :movies, :description, :text
end
end
I then:
rake db:migrate
== 20150616130929 ChangeDescriptionTypeInMyTable: migrating ===================
-- change_column(:movies, :description, :text)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
undefined method `to_sym' for nil:NilClass/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/schema_definitions.rb:258:in `column'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:544:in `block (2 levels) in copy_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:537:in `each'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:537:in `block in copy_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:202:in `create_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:534:in `copy_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:527:in `move_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:520:in `block in alter_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:519:in `alter_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:483:in `change_column'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:662:in `block in method_missing'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:632:in `block in say_with_time'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:632:in `say_with_time'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:652:in `method_missing'
/Users/username/Documents/projectname/db/migrate/20150616130929_change_description_type_in_my_table.rb:3:in `change'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:606:in `exec_migration'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:590:in `block (2 levels) in migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:589:in `block in migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:588:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:765:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:995:in `block in execute_migration_in_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:1041:in `block in ddl_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/transactions.rb:220:in `transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:1041:in `ddl_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:994:in `execute_migration_in_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:956:in `block in migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:952:in `each'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:952:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:820:in `up'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:798:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
So I attempted to rollback the database like this SO Answer suggests:
rake db:rollback
== 20150616125848 AddFieldsToMovies: reverting ================================
-- remove_column(:movies, :release_date, :datetime)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
undefined method `to_sym' for nil:NilClass/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/schema_definitions.rb:258:in `column'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:544:in `block (2 levels) in copy_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:537:in `each'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:537:in `block in copy_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:202:in `create_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:534:in `copy_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:527:in `move_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:520:in `block in alter_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:519:in `alter_table'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:462:in `remove_column'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:662:in `block in method_missing'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:632:in `block in say_with_time'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:632:in `say_with_time'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:652:in `method_missing'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:497:in `block in revert'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:496:in `each'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:496:in `revert'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:604:in `exec_migration'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:590:in `block (2 levels) in migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:589:in `block in migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:588:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:765:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:995:in `block in execute_migration_in_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:1041:in `block in ddl_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/transactions.rb:220:in `transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:1041:in `ddl_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:994:in `execute_migration_in_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:956:in `block in migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:952:in `each'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:952:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:827:in `down'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:907:in `move'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:809:in `rollback'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/railties/databases.rake:125:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:rollback
(See full trace by running task with --trace)
Some SO answers suggest it is a SQLite 3 issue, but I doubt it because the rollback error would not occured (I believe).

cannot rollback migration with rake db:rollback

I guess this is another reason I should be backing up my work with GitHub, but alas, I have not been.
The migration I want to rollback is this:
class AddAssociationToTables < ActiveRecord::Migration
def change
add_column :articles, :user, :belongs_to
end
end
Which obviously isn't well formed because it seems to have totally removed my article table from the database.
I tried rake db:rollback:status and there is nothing 'missing' or anything.
I'm gonna skip copy-pasting the entire trace.
I tried to make a counteracting migration and run that. This is what I wrote:
class RemoveAssociationFromArticle < ActiveRecord::Migration
def change
remove_column :articles, :user, :belongs_to
end
end
But when I tried to run rake db:migrate with this I got what looks like the same error.
EDIT ok here's the whole trace for the rollback first, and then the migrate attempt
== AddAssociationToTables: reverting =========================================
-- remove_column(:articles, :user, :belongs_to)
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `to_sym' for nil:NilClass/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/schema_definitions.rb:215:in `column'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:545:in `block (2 levels) in copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:538:in `each'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:538:in `block in copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:184:in `create_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:535:in `copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:528:in `move_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:521:in `block in alter_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:200:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:520:in `alter_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:463:in `remove_column'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:625:in `block in method_missing'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:597:in `block in say_with_time'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:597:in `say_with_time'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:617:in `method_missing'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:462:in `block in revert'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:461:in `each'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:461:in `revert'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:569:in `exec_migration'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:555:in `block (2 levels) in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:554:in `block in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:553:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:709:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:959:in `block in execute_migration_in_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:1005:in `block in ddl_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:209:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:1005:in `ddl_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:958:in `execute_migration_in_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:920:in `block in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:916:in `each'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:916:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:771:in `down'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:857:in `move'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:753:in `rollback'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/railties/databases.rake:126:in `block (2 levels) in <top (required)>'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `eval'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:rollback
(See full trace by running task with --trace)
== RemoveAssociationFromArticle: migrating ===================================
-- remove_column(:articles, :user, :belongs_to)
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `to_sym' for nil:NilClass/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/schema_definitions.rb:215:in `column'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:545:in `block (2 levels) in copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:538:in `each'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:538:in `block in copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:184:in `create_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:535:in `copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:528:in `move_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:521:in `block in alter_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:200:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:520:in `alter_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:463:in `remove_column'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:625:in `block in method_missing'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:597:in `block in say_with_time'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:597:in `say_with_time'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:617:in `method_missing'
/home/macs/code/my_apps/rails_apps/satisfactory/dec1/whatis/db/migrate/20131202144933_remove_association_from_article.rb:3:in `change'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:571:in `exec_migration'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:555:in `block (2 levels) in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:554:in `block in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:553:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:709:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:959:in `block in execute_migration_in_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:1005:in `block in ddl_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:209:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:1005:in `ddl_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:958:in `execute_migration_in_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:920:in `block in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:916:in `each'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:916:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:764:in `up'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:742:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `eval'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
The third parameter should be the type of column.
The correct syntax is:
add_column :articles, :user_id, :integer
The :belongs_to parameter may causing conflict with ActiveRecord methods!
If it did not migrate properly in the first place, don't worry about rolling back. Just fix the migration and try to migrate again.
Your migration should be:
add_column :articles, :user, :references
The belongs_to is for in the model class, and not in the migration. If it gets to a point where you can't do anything, you can always recreate the database to start fresh (and lose all data).
$ rake db:drop db:create db:migrate
Start using version control, and read through all of this slowly and carefully at some point in life http://guides.rubyonrails.org/migrations.html

Rails: rake db:migrate failure `verify_readonly_attribute`

This migration worked fine on an initial developer machine but is failing in a second dev environment. Setups are identical as far as we can tell.
Migration:
class AddInventoryItemsCountToProduct < ActiveRecord::Migration
def change
add_column :products, :inventory_items_count, :integer, default: 0
reversible do |dir|
dir.up do
Product.all.each do |p|
p.update_attribute :inventory_items_count, p.inventory_items.length
end
end
end
end
end
Haven't seen this error. Anyone know what's going on?
$ rake db:migrate
== AddInventoryItemsCountToProduct: migrating ================================
-- add_column(:products, :inventory_items_count, :integer, {:default=>0})
-> 0.0112s
rake aborted!
An error has occurred, this and all later migrations canceled:
inventory_items_count is marked as readonly/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/persistence.rb:506:in `verify_readonly_attribute'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/persistence.rb:217:in `update_attribute'
/Users/meltemi/rails/input/myapp/db/migrate/20130823022914_add_inventory_items_count_to_product.rb:8:in `block (3 levels) in change'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/relation/delegation.rb:13:in `each'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/relation/delegation.rb:13:in `each'
/Users/meltemi/rails/input/myapp/db/migrate/20130823022914_add_inventory_items_count_to_product.rb:7:in `block (2 levels) in change'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:474:in `up'
/Users/meltemi/rails/input/myapp/db/migrate/20130823022914_add_inventory_items_count_to_product.rb:6:in `block in change'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:510:in `block in reversible'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:687:in `execute_block'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:510:in `reversible'
/Users/meltemi/rails/input/myapp/db/migrate/20130823022914_add_inventory_items_count_to_product.rb:5:in `change'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:571:in `exec_migration'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:555:in `block (2 levels) in migrate'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:554:in `block in migrate'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:553:in `migrate'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:709:in `migrate'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:959:in `block in execute_migration_in_transaction'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:1005:in `block in ddl_transaction'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:in `transaction'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:1005:in `ddl_transaction'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:958:in `execute_migration_in_transaction'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:920:in `block in migrate'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:916:in `each'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:916:in `migrate'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:764:in `up'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/migration.rb:742:in `migrate'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/bin/ruby_noexec_wrapper:14:in `eval'
/Users/meltemi/.rvm/gems/ruby-2.0.0-p247#myapp/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Check this answer: Problem with counter_cache implementation
Also you might to take the 2nd advice: find_each instead of each

Error after run heroku run rake db:migrate

I already ran "heroku pg:reset DATABASE".However,I still got this error.
Running `rake db:migrate` attached to terminal... up, run.8257
== AddPasswordDigestToUsers: migrating =======================================
-- add_column(:users, :password_digest, :string)
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::Error: ERROR: relation "users" does not exist
: ALTER TABLE "users" ADD COLUMN "password_digest" character varying(255)/app/ve
ndor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connection_adap
ters/postgresql/database_statements.rb:128:in `exec'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/postgresql/database_statements.rb:128:in `block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract_adapter.rb:425:in `block in log'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/notifi
cations/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract_adapter.rb:420:in `log'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/postgresql/database_statements.rb:127:in `execute'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract/schema_statements.rb:360:in `add_column'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/postgresql/schema_statements.rb:379:in `add_column'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:625:in `block in method_missing'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:597:in `block in say_with_time'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:597:in `say_with_time'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:617:in `method_missing'
/app/db/migrate/20130822145844_add_password_digest_to_users.rb:3:in `change'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:571:in `exec_migration'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:555:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:554:in `block in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:294:in `with_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:553:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:709:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:959:in `block in execute_migration_in_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:1005:in `block in ddl_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract/database_statements.rb:202:in `block in transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract/database_statements.rb:202:in `transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/transact
ions.rb:209:in `transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:1005:in `ddl_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:958:in `execute_migration_in_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:920:in `block in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:916:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:916:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:764:in `up'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:742:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/railties
/databases.rake:42:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Any suggestion?
Most likely its trying to run the migration of adding the password digest to the users table before creating the users table. You can try to create the database first or try resetting it. You can create db by doing rake db:create

Resources