Heroku Push Problem 2 - Postgresql - PGError relationships do not exist - Ruby on Rails

So, I went through the last problem with the difference between Postgresql and SQLite and it seems Heroku is telling me that I have one more. I am new to ruby ​​and rails, so I can't decrypt a lot. Looking for a small direction here. The following are error messages and the PostsController index. I checked the routes.rb file and everything is fine there, but I could have missed something. I will send if you need.

Processing PostsController#index (for 99.7.50.140 at 2010-04-23 15:19:22) [GET]

ActiveRecord::StatementInvalid (PGError: ERROR:  relation "tags" does not exist
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"tags"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
):

PostsController #index

  def index
    @tag_counts = Tag.count(:group => :tag_name, 
       :order => 'count_all DESC', :limit => 20)
       conditions, joins = {}, :votes

    @ugtag_counts = Ugtag.count(:group => :ugctag_name, 
       :order => 'count_all DESC', :limit => 20)
       conditions, joins = {}, :votes

    @vote_counts = Vote.count(:group => :post_title, 
          :order => 'count_all DESC', :limit => 20)
          conditions, joins = {}, :votes


       unless(params[:tag_name] || "").empty?
         conditions = ["tags.tag_name = ? ", params[:tag_name]]
         joins = [:tags, :votes]
       end
       @posts=Post.paginate(
                 :select => "posts.*, count(*) as vote_total", 
                 :joins => joins, 
                 :conditions=> conditions, 
                 :group => "votes.post_id, posts.id ", 
                 :order => "created_at DESC",
                 :page => params[:page], :per_page => 5)
        @popular_posts=Post.paginate(
                 :select => "posts.*, count(*) as vote_total", 
                 :joins => joins, 
                 :conditions=> conditions, 
                 :group => "votes.post_id, posts.id", 
                 :order => "vote_total DESC",
                 :page => params[:page], :per_page => 3)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @posts }
      format.json { render :json => @posts }
      format.atom
    end
  end
+3
source share
10 answers

Rails? .gems ? , , . .gems, , . , : Heroku |

0

"PGError: ERROR: "... " " 3.0.3 3.0.5 - , , , : "project_metadatas" "project_metadata".

, , :

class MetadataName < ActiveRecord::Migration
  def self.up
    rename_table :project_metadatas, :project_metadata
  end

  def self.down
    rename_table :project_metadata, :project_metadatas
  end
end
+2

:

WHERE a.attrelid = '"tags"'::regclass

, . , " .

, Rails- , . ...

Leaky Abstraction.: -)

+1

- :

 `enter code here`WHERE a.attrelid = '"posts"'::regclass

gem, rails_admin, ? , , , :)

 #config.model Post do
 #  field :body, :text do
 #    ckeditor true
 #  end
 #end

, , (i m not sur) rake . , sql-, . env:)

+1

, , rake. :

bundle exec rake db:migrate
+1

rails, :

db, rake db: schema: dev-, ( ) ...

,

add_index :taggings, ["vectors"] 

add_index "taggings", ["vectors"] 

dev-, , , , db , db: push.

, .

- , ...

0

. , "", "".

"" Postgresql, . ? , GHOST .

0

To add the line below to /config/environment.rb:

ActiveRecord::Base.pluralize_table_names = false
0
source

Same problem for me, but only en test and prod env.

rake db:migrate 

OK

rake db:migrate RAILS_ENV=test
rake aborted!
PGError: ERREUR:  la relation « posts » n'existe pas
LINE 4:              WHERE a.attrelid = '"posts"'::regclass
                                        ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"posts"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
0
source

I had the same problem after a big push, although I remember that I started the migration. For me, the solution was to restart:

heroku restart
0
source

Source: https://habr.com/ru/post/1742542/


All Articles