rake :db migrate 不返回任何内容
我创建了一篇模型文章并在 001_create_articles.rb 中添加了以下代码
class CreateArticles < ActiveRecord::Migration
def self.up
create_table :articles do |t|
t.string :title
t.text :body
t.string :published_at
t.timestamps
end
end
def self.down
drop_table :articles
end
end
然后我尝试运行
rake db:migrate --traceI dint get any output, the console just blinks for a minute. The output of the rake is
C:\InstantRails-2.0-win\rails_apps\blog>rake db:migrate --trace (in C:/InstantRails-2.0-win/rails_apps/blog) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump
另外rake:db migrate在我的任何项目中都不起作用
此外Mysql服务器正在运行并且我能够登录到服务器。我的database.yml 文件没问题。
这是配置问题还是我遗漏了什么?
i created a model Article and addedd the following code in 001_create_articles.rb
class CreateArticles < ActiveRecord::Migration
def self.up
create_table :articles do |t|
t.string :title
t.text :body
t.string :published_at
t.timestamps
end
end
def self.down
drop_table :articles
end
end
Then i tried running
rake db:migrate --trace
I dint get any output, the console just blinks for a minute.
The output of the rake is
C:\InstantRails-2.0-win\rails_apps\blog>rake db:migrate --trace (in C:/InstantRails-2.0-win/rails_apps/blog) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump
also rake :db migrate is not working in anyof my projects
Also Mysql server is running and i am able to login to the server. my database.yml file is fine.
Is this a configuration issue or i am missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的数据库有一个 schema_migrations
如果文件已经运行,版本号将在那里,您可以删除该数据库中的条目并运行 db:migrate,请注意,它可能也会删除您的所有数据。
如果您想对数据库进行增量更改而不修改数据,您可以创建一个新的迁移来修改现有的数据库结构,例如:
Your database has a schema_migrations
if the file has already been run the version number will be there, you can remove the entries in that DB and run db:migrate, note that it will probably remove all your data as well.
if you want to make an incremental change to the db without modifying the data you can create a new migration that modifies the existing database structure an example: