Tag: postgresql

ActiveRecord :: StatementInvalid:PG :: ReadOnlySqlTransaction: – 即使在取消关注后,Heroku数据库仍然只读

我想在heroku中将数据库从一个应用程序复制到另一个应用程序。 我有一个索引问题迫使我使用跟随数据库然后取消关注。 我的问题是,现在在创建了关注者,取消关注并推广它之后,我在尝试写入时遇到错误: ActiveRecord::StatementInvalid: PG::ReadOnlySqlTransaction: ERROR: cannot execute ALTER TABLE in a read-only transaction 另外,当我运行时: SELECT pg_is_in_recovery(); 我明白了 我做的是: heroku addons:create heroku-postgresql:standard-4 –follow MAIN_DB_ADDON_NAME -a app-that-follows heroku pg:unfollow HEROKU_POSTGRESQL_COLOR_URL -a app-that-follows heroku pg:promote HEROKU_POSTGRESQL_COLOR_URL -a app-that-follows 知道为什么我会收到这个错误,更重要的是, 我该怎么解决 ? 谢谢, 乌里

配置与Heroku PostgreSQL的RubyMine远程连接

我应该如何配置RubyMine jdbc数据源以远程连接到Heroku的PostgreSQL数据库? 目前我正在使用这样的连接URL: jdbc:postgresql://ec2-54-197-241-67.compute-1.amazonaws.com/dbqi9t12t5035q 但是我在pg_hba.conf中遇到主机’62 .87.242.2’缺少条目的错误。 我很确定用户和密码是正确的,因为它在线运行…… :-)。 你可以帮帮我吗? 先感谢您!

Postgres on Rails FATAL:数据库不存在

我重新安装了Postgres(9.2.4),但是我无法使用Rails 3.2.11进行备份。 我做了: brew install postgresql initdb /usr/local/var/postgres pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start 所以现在我有 $ psql –version psql (PostgreSQL) 9.2.4 $ which psql /usr/local/bin/psql 我的database.yml文件看起来像 development: adapter: postgresql encoding: unicode database: myapp_development pool: 5 username: Tyler password: host: localhost port: 5432 当我运行rake db:create:all然后rake db:migrate我得到错误: PG::Error: ERROR: relation “posts” does not exist LINE 5: WHERE […]

PostgreSQL模式的Rails迁移

我正在为不同的客户端使用PostgreSQL模式开发多租户rails应用程序。 Rails迁移不适用于开箱即用的多个模式,所以我做了以下rake任务来迁移所有模式,它似乎工作。 我的问题是,如果其他人实施了更好,更优雅的解决方案。 我也非常满意一个很好的教程,包括使用多个模式的PostgreSQL的rails代码示例。 到目前为止,我只找到了关于这个主题的一个很好的演讲http://aac2009.confreaks.com/06-feb-2009-14-30-writing-multi-tenant-applications-in-rails-guy-naor.html和我的目标是tomayko.com/writings/rails-multiple-connections desc ‘Migrates all postgres schemas’ task :schemas do # get all schemas env = “#{RAILS_ENV}” config = YAML::load(File.open(‘config/database.yml’)) ActiveRecord::Base.establish_connection(config[env]) schemas = ActiveRecord::Base.connection.select_values(“select * from pg_namespace where nspname != ‘information_schema’ AND nspname NOT LIKE ‘pg%'”) puts “Migrate schemas: #{schemas.inspect}” # migrate each schema schemas.each do |schema| puts “Migrate schema: #{schema}” config […]

Cloud9 + rails + Postgresql用法

我无法使用Postgresql在Cloud9(c9.io)上进行开发来设置Rails应用程序:迁移不成功。 常见错误: ~/workspace (master) $ rake db:migrate rake aborted! PG::ConnectionBad: could not connect to server: Connection refused Is the server running on host “0.0.0.0” and accepting TCP/IP connections on port 5432?

Rails 3.2 – 未定义的方法`where’for#<Array:… – Model.where()的查询

我试图将给定Header中的字段与Alarm模型中的其他字段进行比较。 正如您在代码中看到的,我以3个不同的步骤过滤警报。 前2个工作完美。 但是,最后一个不起作用。 它说: undefined method `where’ for #<Array:… 据我所知.where是一个与数组一起使用的类方法。 为什么不在这里工作? 我也试过.find_all_by和不同的东西……但无济于事。 @header = Header.find(1) # Extracts those alarms that are ACTIVE and have something in common with the tittles @alarmsT = Alarm.activated.where(“keyword in (?)”, [@header.title_es, @header.title_en, @header.title_en]) # Extracts alarms when Header has at least the same categories as an alarm @alarmsT = […]

Rails无法写入数据库中的序列化数组字段

我在我的模型上设置了数组,当我将数组写入我的记录时,它表示COMMIT为true,但在返回空数组后立即检查该记录上的字段。 模型: class Feature < ActiveRecord::Base serialize :content, Array attr_accessible :content end 移民: class AddContentToFeatures < ActiveRecord::Migration def change add_column :features, :content, :text, array: true, default: [] end end 我尝试过的,以及各种符号和字符串语法,是这样的: > f=Feature.new > f.content_will_change! #i feel like i shouldn’t have to do this > f.content = [‘sadasd’,’asdasd’] > f.save! BEGIN COMMIT => true > f.content […]

用点击将SQLite数据库推送到Heroku?

所以我试图将一个SQLite3数据库推送到Heroku,我认为这是可能的,但是在这里和这里阅读意味着它可能不是(以下不起作用)。 heroku pg:push sqlite://db/development.sqlite3 HEROKU_POSTGRESQL_OLIVE_URL ! LOCAL_SOURCE_DATABASE is not a valid database name 当Heroku将语法切换为pg:push时,这是否已更改pg:push从db:push还是永远不可能? 鉴于不可能将解决方案从SQLite3迁移到本地postgres,然后推送到Heroku?

Rails 4 – 使用postgres逐个渲染数组值

我使用Postgres作为数据库,并利用Rails 4开箱即用的Postgres数组支持。 我有一个名为Recipe的模型,它包含t.text :steps, array: true数组属性。 我想在由每个值分隔的文本字段中呈现此数组属性。 我已经尝试了以下但是我得到错误undefined method ‘each’ for nil:NilClass 。

heroku运行rake db:迁移错误

我想在我的应用程序上运行我在heroku上的迁移,但是我收到此错误: Running `rake db:migrate` attached to terminal… up, run.1 DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on […]