我下面从jumpstartlab.com,我有问题的博客教程..迁移错误
这是在控制台的错误信息,我得到的,当我尝试运行rake db:migrate
:
SQLite3::SQLException: table tags already exists: CREATE TABLE "tags"
("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255),
"created_at" datetime, "updated_at" datetime) /home/aki/.rvm/gems/ruby-
2.1.3/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:91:in `initialize
我怎样才能删除表tags
?我应该删除迁移文件吗?
这是schema.rb:
ActiveRecord::Schema.define(version: 20150506111021) do
create_table "articles", force: true do |t|
t.string "title"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "comments", force: true do |t|
t.string "author_name"
t.text "body"
t.integer "article_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "comments", ["article_id"], name: "index_comments_on_article_id"
create_table "taggings", force: true do |t|
t.integer "tag_id"
t.integer "article_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "taggings", ["article_id"], name: "index_taggings_on_article_id"
add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id"
create_table "tags", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
end
这是...create_tags.rb
迁移文件:
class CreateTags < ActiveRecord::Migration
def change
create_table :tags do |t|
t.string :name
t.timestamps
end
end
end
这是...create_taggings.rb
迁移文件:
class CreateTaggings < ActiveRecord::Migration
def change
create_table :taggings do |t|
t.references :tag, index: true
t.references :article, index: true
t.timestamps
end
end
end
如果您需要任何其他文件,我会更新我的问题。谢谢!!
尝试'耙分贝:降:all',然后尝试'耙分贝:migrate' – Sontya