我正在尝试使用此迁移,但我不断收到错误,例如这些
这是我的迁移文件
class CreateEmployees < ActiveRecord::Migration
def self.up
create_table :employees do |t|
t.string :name
t.date :hiredate
t.float :salary
t.boolean :fulltime , :default => true
t.integer :vacationdays
t.text :comments
end
end
def self.down
drop_table :employees
end
end
当我尝试执行 rake db:migrate 得到这个错误:
== CreateEmployees:迁移 ============================================== === -- create_table(:employees) rake 中止!发生错误,此迁移和所有后续迁移均已取消:
SQLite3::SQLException: 表 "employees" 已经存在: CREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar (255), "hiredate" date, "salary" float, "fulltime" boolean默认't',“假期”整数,“评论”文本)/Library/Ruby/Gems/2.0.0/gems/sql ite3-1.3.8/lib/sqlite3/database.rb:91:in
initialize' /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3/database.rb:91:in
new'/Library /Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3/database.rb:91:inprepare' /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3/database.rb:134:in
执行' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib /active_record/connection_adapters/sqlite3_adapter.rb:328:inblock in execute' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:425:in
block in log' /Library/Ruby/Gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:20:ininstrument' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:420:in
log'/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:328:inexecute' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:190:in
create_table' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:625:inblock in method_missing' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:597:in
block in say_with_time' /Library/Ruby/Gems/2.0.0/gems/activerecord -4.0.0/lib/active_record/migration.rb:597:insay_with_time' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:617:in
method_missing' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:383:inmethod_missing' /Users/YuriAguirre/Documents/Aptana Studio 3 Workspace/company/db/migrate/20130923140626_create_employees.rb:3:in
up' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:534:inup' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:574:in
exec_migration' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0 /lib/active_record/migration.rb:555:inblock (2 levels) in migrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:554:in
block in migrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:inwith_connection' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:553:in
迁移' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:709:inmigrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:959:in
块中的 execute_migration_in_transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord -4.0.0/lib/active_record/migration.rb:1005:block in ddl_transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in
在事务块中'/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements。 rb:210:inwithin_new_transact ion' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in
transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:intransaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:1005:in
ddl_transaction' /Library/Ruby/Gems/2.0.0/ gems/activerecord-4.0.0/lib/active_record/migration.rb:958:inexecute_migration_in_transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:920:in
block in migrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb: 916:在each' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:916:in
迁移' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:764:inup' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:742:in
迁移' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.0 .0/lib/active_record/railties/databases.rake:42:in `block (2 levels) in ' Tasks: TOP => db:migrate (通过使用 --trace 运行任务查看完整跟踪)