Tag: 数据库迁移

Rails迁移不会更改schema.rb

我有一个rails应用程序没有应用到我的schema.rb。 迁移应该创建一个表: class CreateUserGraphs < ActiveRecord::Migration def change create_table :user_graphs do |t| t.string :name t.string :content t.integer :user_id t.string :type_id t.integer :upload_id t.timestamps end add_index :user_graphs, [:user_id, :created_at] end end 我做了db:reset。 然后我尝试了rake db:migrate:up VERSION = 123123123(这是迁移#)。 我在我的“开发”环境中。 为什么迁移不会影响schema.rb?

Rails错误:无法访问日志文件。 请确保/home…/log/development.log存在并且是chmod 0666

我试图将db2数据库迁移到Ruby on Rails,但就在我运行rails g scaffold ,我得到了这个: Rails Error: Unable to access log file. Please ensure that /home/…/log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed. 我已经检查过,我的development.log不存在! 我不知道为什么,因为我在安装过程中遵循了每一步,但我的文件仍然不存在。 我该如何创建它? 我已经尝试过再次卸载和安装Rails,但问题仍然存在。

如何在Rails迁移中添加检查约束?

我需要在我的Rails应用程序中的现有表中添加一个新的整数列。 该列只能有值1,2,3,所以我想在表/列中添加一个检查约束。 如何在Rails迁移中指定此约束?

在Rails 4迁移中设置自定义主键时出现问题

我使用postgresql 9.3,Ruby 2.0,Rails 4.0.0。 在阅读了关于在表上设置主键的SO的大量问题之后,我生成并添加了以下迁移: class CreateShareholders < ActiveRecord::Migration def change create_table :shareholders, { id: false, primary_key: :uid } do |t| t.integer :uid, limit: 8 t.string :name t.integer :shares t.timestamps end end end 我还在我的模型中添加了self.primary_key = “uid” 。 迁移成功运行,但是当我使用pgAdmin III连接到数据库时,我看到uid列未设置为主键。 我错过了什么?

执行rake db时出错:在Heroku上进行迁移

什么时候做 heroku run rake db:migrate 执行所有迁移然后,最后我总是得到以下消息: /app/vendor/bundle/ruby/1.9.1/bin/rake: No such file or directory – pg_dump -i -s -x -O -f /app/db/structure.sql dan79p98fykovu 我无法在Heroku上将pg_dump添加到PATH。 怎么处理这个?