我正在寻找一种在 Rails 中删除表并重新开始的方法,并遇到了这个答案:Rails DB Migration - How To Drop a Table?
但是,当我运行时,出现drop_table :examples
以下错误:
-bash: drop_table: command not found
这是我的create_examples
迁移文件:
def self.down
drop_table :examples
end
谁能帮助指导我解决这个问题并让我了解我做错了什么?我需要修复它,因为这个特定的迁移阻止执行 a rake db:migrate
,产生以下错误:
== CreateExamples: migrating ====================================================
-- create_table(:examples)
rake aborted!
An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: table "examples" already exists: CREATE TABLE "examples" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "content" varchar(255), "user_id" integer, "created_at" datetime, "updated_at" datetime)
谢谢!(如果我需要提供更多代码,请告诉我。)