Tag: 迁移

Ruby on Rails:向现有数据库添加列

我收到一个错误: SQLite3::SQLException: no such column: ideas.list_id: SELECT “ideas”.* FROM “ideas” WHERE “ideas”.”list_id” = 2 但我补充道 t.integer :list_id 到我的数据库迁移文件: class CreateIdeas < ActiveRecord::Migration def change create_table :ideas do |t| t.string :name t.text :description t.string :picture t.timestamps end add_foreign_key :ideas, :lists end end 这给了我这个: class CreateIdeas < ActiveRecord::Migration def change create_table :ideas do |t| t.string :name t.text […]

如何从ruby中获取数据库中的数据

我有数据库: class CreateDataintables < ActiveRecord::Migration def change create_table :windows do |t| t.string :window t.timestamps end create_table :channels do |t| t.integer :channel t.integer :data t.belongs_to :window t.timestamps end end end 我想从/向窗口“test”读取/写入数据,通道“1”但不知道该怎么做。 请给我一些示例代码。我真的需要它。

耙子流产了! 用于ActiveRecord :: Base的未定义方法`migration_error =’:Class

我正在使用Ruby on Rails开发项目直到现在我使用Rails 4并且在我遇到gem的无能力问题之前一切都很好。 我决定回滚到Rails 3,更改我的Gemfile,删除Gemfile.lock,所有rails安装和railties。 然后我运行bundle install并安装了Rails 3.2.13。 但是现在当我运行rake db时:创建一切仍然很好。 当我运行rake db:migrate问题开始时: JeffreeBook:llvoo kristijonas$ rake db:migrate WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8 rake aborted! undefined method `migration_error=’ for ActiveRecord::Base:Class /Users/kristijonas/.rvm/gems/ruby-1.9.3-p448@fashion/gems/activerecord-3.2.13/lib/active_record/dynamic_matchers.rb:55:in `method_missing’ /Users/kristijonas/.rvm/gems/ruby-1.9.3-p448@fashion/gems/activerecord-3.2.13/lib/active_record/railtie.rb:66:in `block (3 levels) in ‘ /Users/kristijonas/.rvm/gems/ruby-1.9.3-p448@fashion/gems/activerecord-3.2.13/lib/active_record/railtie.rb:65:in `each’ /Users/kristijonas/.rvm/gems/ruby-1.9.3-p448@fashion/gems/activerecord-3.2.13/lib/active_record/railtie.rb:65:in `block (2 levels) in ‘ /Users/kristijonas/.rvm/gems/ruby-1.9.3-p448@fashion/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval’ […]

heroku db:拉不起作用?

我收到以下错误消息: heroku db:pull –debug postgres://USERNAME:PASSWORD@localhost/test Loaded Taps v0.3.23 Warning: Data in the database ‘postgres://USERNAME:PASSWORD@localhost/test’ will be overwritten and will not be recoverable. Receiving schema Unable to fetch tables information from http://heroku:foo9dsfsdfsdb465ar@taps19.heroku.com. Please check the server log. 上面的命令不会在日志中生成任何可以使用“heroku logs”查看的消息。 知道我做错了什么吗?

类似Rails的数据库迁移?

是否有任何易于安装/使用(在unix上)的数据库迁移工具,如Rails迁移? 我真的很喜欢这个想法,但是纯粹安装ruby / rails来管理我的数据库迁移似乎有些过分。

Rails迁移更改列以使用Postgres数组

我试图更改我的数据库中的列,以便它可以使用Postgres数组数据类型。 目前,表列的类型为string。 我使用以下迁移来转换它: def change change_column :table, :dummy_column, :text, array: true, default: [] end 但是我收到以下错误: bundle exec rake db:migrate rake aborted! An error has occurred, this and all later migrations canceled: PG::Error: ERROR: column “dummy_column” cannot be cast automatically to type character varying[] HINT: Specify a USING expression to perform the conversion. : ALTER TABLE […]

Rails g迁移不起作用

当我运行命令 rails g migration migration_name 我会收到“错误”消息: Usage: rails new APP_PATH [options] Options: -r, [–ruby=PATH] # Path to the Ruby binary of your choice # Default: /Users/radek/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -b, [–builder=BUILDER] # Path to a application builder (can be a filesystem path or URL) -m, [–template=TEMPLATE] # Path to an application template (can be a filesystem path or […]

从Rails 2迁移到Rails 3

可能重复: Rails 3弃用了方法和API 哪些资源(免费或付费)可以帮助您完成将Ruby on Rails 2应用程序迁移到Rails 3的过程? 我在RoR网站上看到过一些博客文章(其中一些看起来过时了)和一本电子书出售,但你能推荐什么作为从版本2到版本3的变化的准确和完整的解释以及需要什么移植到Rails 3环境时要更新?