rake db:migrateで問題が発生しています。この問題は、scaffoldを使用してモデルを作成し、db:migrateを実行してから、scaffolddPostsを使用してモデルを削除したときに始まりました。
ここで、scaffold gを使用してモデルを再度作成し、db:migrateを実行しました。ユーザーテーブルがすでに存在していたため、エラーが発生しました。どうすればこれを修正できますか?
murtaza@murtaza-dev:~/workspace/rails/base$ rake db:migrate
== CreatePosts: migrating ====================================================
-- create_table(:posts) rake aborted! An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: table "posts" already exists: CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "content" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
Tasks: TOP => db:migrate (See full trace by running task with --trace) murtaza@murtaza-dev:~/workspace/rails/base$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
== CreatePosts: migrating ====================================================
-- create_table(:posts) rake aborted! An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: table "posts" already exists: CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "content" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.6/lib/sqlite3/database.rb:91:in `initialize' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.6/lib/sqlite3/database.rb:91:in `new' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.6/lib/sqlite3/database.rb:91:in `prepare' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.6/lib/sqlite3/database.rb:134:in `execute' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/connection_adapters/sqlite_adapter.rb:278:in `block in execute' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/connection_adapters/sqlite_adapter.rb:278:in `execute' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:170:in `create_table' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:466:in `block in method_missing' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:438:in `block in say_with_time' /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/benchmark.rb:280:in `measure' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:438:in `say_with_time' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:458:in `method_missing' /home/murtaza/workspace/rails/base/db/migrate/20120802061742_create_posts.rb:3:in `change' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:407:in `block (2 levels) in migrate' /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/benchmark.rb:280:in `measure' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:407:in `block in migrate' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:123:in `with_connection' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:389:in `migrate' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:528:in `migrate' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:720:in `block (2 levels) in migrate' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `call' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `block in ddl_transaction' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/transactions.rb:208:in `transaction' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `ddl_transaction' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:719:in `block in migrate' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:700:in `each' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:700:in `migrate' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:570:in `up' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/migration.rb:551:in `migrate' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/railties/databases.rake:153:in `block (2 levels) in <top (required)>' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain' /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/bin/rake:23:in `load' /home/murtaza/.rvm/gems/ruby-1.9.3-p194/bin/rake:23:in `<main>' Tasks: TOP => db:migrate