新手问题 rails migrate 只能一次执行一个,执行多个就会报错。

luoyou · 2014年10月23日 · 最后由 xiao1994 回复于 2016年04月21日 · 3990 次阅读

初学 rails,遇到好多 bug,这次遇到的 bug 最莫名其妙了 rake db:migrate 这个命令一次只能执行一个版本的更新,如果一次执行多个,就会报如下的错误:

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: database schema has changed: INSERT INTO "schema_migrations" ("version") VALUES (?)

后面还有一大堆信息,不过主要就是这个报错,把 migrate 文件夹里面的文件删成一个,每执行一次 rake 再添加一个文件,这样的话就没问题,光是试出这个就累死了,网上几乎找不到类似的 bug。

系统:centOS rails: 4.1.6 ruby: 2.1.3

麻烦各位大神了……

@luoyou 贴完整的 log 吧

#1 楼 @ailen

[root@luoyou1014 teach]# rake db:migrate
== 20141022053115 CreateUsers: migrating ======================================
-- create_table(:users)
   -> 0.0044s
== 20141022053115 CreateUsers: migrated (0.0045s) =============================

== 20141022053301 CreateCourseTags: migrating =================================
-- create_table(:course_tags)
   -> 0.0004s
== 20141022053301 CreateCourseTags: migrated (0.0004s) ========================

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: database schema has changed: INSERT INTO "schema_migrations" ("version") VALUES (?)/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:108:in `step'
/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:108:in `block in each'
/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:107:in `loop'
/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:107:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/sqlite3_adapter.rb:319:in `to_a'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/sqlite3_adapter.rb:319:in `block in exec_query'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/sqlite3_adapter.rb:298:in `exec_query'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:68:in `exec_insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:95:in `insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/relation.rb:64:in `insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/persistence.rb:503:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/attribute_methods/dirty.rb:87:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:306:in `block in _create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:82:in `run_callbacks'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:306:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/timestamp.rb:57:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/persistence.rb:483:in `create_or_update'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:82:in `run_callbacks'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:302:in `create_or_update'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/persistence.rb:125:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/validations.rb:57:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:273:in `block in save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:199:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:208:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:273:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/validations.rb:41:in `create!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:1022:in `record_version_state_after_migrating'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:992:in `block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:1037:in `block in ddl_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:208:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:1037:in `ddl_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:990:in `execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:952:in `block in migrate'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `migrate'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `up'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:785:in `migrate'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
ActiveRecord::StatementInvalid: SQLite3::SQLException: database schema has changed: INSERT INTO "schema_migrations" ("version") VALUES (?)
/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:108:in `step'
/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:108:in `block in each'
/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:107:in `loop'
/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:107:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/sqlite3_adapter.rb:319:in `to_a'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/sqlite3_adapter.rb:319:in `block in exec_query'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/sqlite3_adapter.rb:298:in `exec_query'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:68:in `exec_insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:95:in `insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/relation.rb:64:in `insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/persistence.rb:503:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/attribute_methods/dirty.rb:87:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:306:in `block in _create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:82:in `run_callbacks'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:306:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/timestamp.rb:57:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/persistence.rb:483:in `create_or_update'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:82:in `run_callbacks'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:302:in `create_or_update'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/persistence.rb:125:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/validations.rb:57:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:273:in `block in save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:199:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:208:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:273:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/validations.rb:41:in `create!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:1022:in `record_version_state_after_migrating'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:992:in `block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:1037:in `block in ddl_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:208:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:1037:in `ddl_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:990:in `execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:952:in `block in migrate'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `migrate'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `up'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:785:in `migrate'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
SQLite3::SQLException: database schema has changed
/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:108:in `step'
/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:108:in `block in each'
/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:107:in `loop'
/usr/local/rvm/gems/ruby-2.1.3/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb:107:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/sqlite3_adapter.rb:319:in `to_a'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/sqlite3_adapter.rb:319:in `block in exec_query'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
/usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/sqlite3_adapter.rb:298:in `exec_query'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:68:in `exec_insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:95:in `insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/relation.rb:64:in `insert'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/persistence.rb:503:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/attribute_methods/dirty.rb:87:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:306:in `block in _create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:82:in `run_callbacks'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:306:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/timestamp.rb:57:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/persistence.rb:483:in `create_or_update'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-4.1.6/lib/active_support/callbacks.rb:82:in `run_callbacks'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/callbacks.rb:302:in `create_or_update'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/persistence.rb:125:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/validations.rb:57:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:273:in `block in save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:199:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:208:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:273:in `save!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/validations.rb:41:in `create!'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:1022:in `record_version_state_after_migrating'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:992:in `block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:1037:in `block in ddl_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/transactions.rb:208:in `transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:1037:in `ddl_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:990:in `execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:952:in `block in migrate'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `migrate'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `up'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/migration.rb:785:in `migrate'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

#2 楼 @luoyou 数据库有啥重要的资料没?没有的话直接把 db/schema.rb 给删了,再执行 rake db:migrate 仅供参考,后果自负哦。

@luoyou 可以尝试下 rake db:reset 看看呢?

#3 楼 @paul_king 删了下,还是一样的

#4 楼 @ailen 也没有用

我还是写一个文件执行一下 rake db:migrate 吧,这样就没问题。

rake db:migrate 的时候在后面指定一下版本:VERSION=xxxxxx 不然默认全部执行一遍,免不了出现冲突。

我觉得应该是你的 migration 文件有误。

#6 楼 @lilonglongRoR 版本是 20141027 这种在文件前的数组吗? 这样就等同于一次执行一个文件了。

def up drop_table :users#(对应你要 db:migrate 的试试)

create_table :users do |t| t.string :name #...

t.timestamps end

需要 登录 后方可回复, 如果你还没有账号请 注册新账号