Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJim Withington
12,025 PointsSo, apparently copy and paste messes up more than I thought it would. What do I do to repair this?
Silly me. I tried to follow these instructions in order to use the updated project files that were included over here. I had a feeling that dragging the files into the folder and telling it to replace all would mess up the database and such, but figured that I could fix it from there.
Well, as you see in that other forum...that's not the case. I tried running those sql commands but rake db:migrate
is getting aborted and when I try localhost:3000 I get this mess:
What do I do in order to a)use those updated files and b)get the darn thing working again?
Note: I tried the suggested bin/rake db:migrate RAILS_ENV=development
but that also got aborted before it finished. Console messages below!
Thanks in advance!
-- create_table(:accounts)
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Mysql2::Error: Table 'accounts' already exists: CREATE TABLE `accounts` (`id` int(11) auto_increment PRIMARY KEY, `type` varchar(255), `name` varchar(255), `email` varchar(255), `about` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB/Users/TCB/biller/db/migrate/20141125224939_create_accounts.rb:3:in `change'
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'accounts' already exists: CREATE TABLE `accounts` (`id` int(11) auto_increment PRIMARY KEY, `type` varchar(255), `name` varchar(255), `email` varchar(255), `about` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
/Users/TCB/biller/db/migrate/20141125224939_create_accounts.rb:3:in `change'
Mysql2::Error: Table 'accounts' already exists
/Users/TCB/biller/db/migrate/20141125224939_create_accounts.rb:3:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
after running trace:
-- create_table(:accounts)
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Mysql2::Error: Table 'accounts' already exists: CREATE TABLE `accounts` (`id` int(11) auto_increment PRIMARY KEY, `type` varchar(255), `name` varchar(255), `email` varchar(255), `about` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `query'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `block in execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/mysql2_adapter.rb:228:in `execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:205:in `create_table'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:460:in `create_table'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:649:in `block in method_missing'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:621:in `block in say_with_time'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:621:in `say_with_time'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:641:in `method_missing'
/Users/TCB/biller/db/migrate/20141125224939_create_accounts.rb:3:in `change'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:595:in `exec_migration'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:579:in `block (2 levels) in migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:578:in `block in migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:577:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:752:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:991:in `block in execute_migration_in_transaction'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:1039:in `ddl_transaction'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:990:in `execute_migration_in_transaction'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:952:in `block in migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `each'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `up'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:785:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/Users/TCB/.rbenv/versions/2.1.3/bin/rake:23:in `load'
/Users/TCB/.rbenv/versions/2.1.3/bin/rake:23:in `<main>'
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'accounts' already exists: CREATE TABLE `accounts` (`id` int(11) auto_increment PRIMARY KEY, `type` varchar(255), `name` varchar(255), `email` varchar(255), `about` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `query'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `block in execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/mysql2_adapter.rb:228:in `execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:205:in `create_table'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:460:in `create_table'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:649:in `block in method_missing'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:621:in `block in say_with_time'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:621:in `say_with_time'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:641:in `method_missing'
/Users/TCB/biller/db/migrate/20141125224939_create_accounts.rb:3:in `change'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:595:in `exec_migration'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:579:in `block (2 levels) in migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:578:in `block in migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:577:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:752:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:991:in `block in execute_migration_in_transaction'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:1039:in `ddl_transaction'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:990:in `execute_migration_in_transaction'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:952:in `block in migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `each'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `up'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:785:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/Users/TCB/.rbenv/versions/2.1.3/bin/rake:23:in `load'
/Users/TCB/.rbenv/versions/2.1.3/bin/rake:23:in `<main>'
Mysql2::Error: Table 'accounts' already exists
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `query'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `block in execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/mysql2_adapter.rb:228:in `execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:205:in `create_table'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:460:in `create_table'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:649:in `block in method_missing'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:621:in `block in say_with_time'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:621:in `say_with_time'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:641:in `method_missing'
/Users/TCB/biller/db/migrate/20141125224939_create_accounts.rb:3:in `change'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:595:in `exec_migration'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:579:in `block (2 levels) in migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:578:in `block in migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:577:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:752:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:991:in `block in execute_migration_in_transaction'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:1039:in `ddl_transaction'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:990:in `execute_migration_in_transaction'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:952:in `block in migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `each'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `up'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/migration.rb:785:in `migrate'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/Users/TCB/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/Users/TCB/.rbenv/versions/2.1.3/bin/rake:23:in `load'
/Users/TCB/.rbenv/versions/2.1.3/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate
3 Answers
Nathan Brown
229 PointsJim,
To restore your database you can run:
rake db:drop
rake db:create
rake db:migrate
rake db:drop
will clear your SQLite database from the current environment. rake db:create
will recreate your database based on your schema.rb file.
You will lose all of the records in your database but your Rails app will work and you’ll be able to input new data.
It won't solve the problem of updating the files but it will get you out of the mess of a corrupted database.
Nathan
Maciej Czuchnowski
36,441 PointsLike Nathan said, at this point you can only drop and recreate your database. Migrations files that were already migrated should never be touched or tampered with. Unmigrated files can still be deleted or modified. For the future, always keep your projects in Git and get back to a point in the past when it all worked - you know, like saving a game ;).
Nathan Brown
229 PointsJim,
I second what Maciej says about Git. You can do so much with Git. Its really amazing! Set aside some time to learn more about Git every week, every month...keep learning new aspects of it. Any time you invest will lead to big payoffs.
Here is one fun little Git tidbit to try on a project with some history of Git commits:
git log --graph
Gavin Ralston
28,770 Pointsrake db:drop rake db:create rake db:migrate
Once you wipe out the database and rebuild it fresh, you can just grab the insert statements for the two tables from the sql dump file and paste them in workbench or at the command line, and you'll have it all if you really want it.
If you're using slightly different versions of rails/ruby or the gems, you can probably just get away with copying just the following folders/files, too:
app > views app > controllers app > models config > routes.rb
That'll cover all the minor tweaks he made without running into any strangeness with the gemfile even after you sort out the db issues.
There's probably a better way, of course.
Jim Withington
12,025 PointsJim Withington
12,025 PointsThanks for the tips!
Is there any way that I can do this without having to clear out all the records? I still have those records somewhere...right?
Or is that not how a MySQL* database works?
*This instructor used MySQL, not SQLite, just so you know.
Nathan Brown
229 PointsNathan Brown
229 PointsYou can check and see if you still have your records by running the Rails console. In the terminal run
rails c
. You can do ActiveRecord queries on your database, i.e.,User.all
which will return all users currently in your database.I don't know how to restore the database without clearing out the records. Maybe hang tight and see if anyone else has an answer for you.