Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8401717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:52:39+00:00 2026-06-09T21:52:39+00:00

I just changed my DB from mysql to postgres and I’m getting the following

  • 0

I just changed my DB from mysql to postgres and I’m getting the following error:

ActionView::Template::Error (PG::Error: ERROR:  operator does not exist: character varying = integer
LINE 1: ...ELECT COUNT(*) FROM "agents"  WHERE "agents"."client_id" = 1

when doing

client.agents.count

I have a Data is structured as follows: Clients have several Agents, and can only add more Agents if agents.count < X, so I’m using something like client.agents.count to retrieve this value and compare, but I’m getting that error. Do I need to use manual sql to get this done? Or am I missing something stupid?

Thank you for your comments

MODEL INFO

class Agent < User

  belongs_to :client
  attr_accessible :client_id

  validates :client_id, presence: true


end

class Client < User
  attr_accessible :appId, :expire_date, :legacy, :url, :plan_id, :chat_window_color, :chat_head_color, :chat_box_container_color, :chat_box_color, :tab_message, :greeting, :please_wait_message, :send_message_button, :comments_label, :offline_message

  belongs_to :plan
  has_many :agents, :dependent => :destroy

  has_secure_password

  after_initialize :init

  #omited validations

  private
  #BEGIN PRIVATE METHODS
end

Both inherit from user

class User < ActiveRecord::Base
    self.abstract_class = true

  attr_accessible :email, :name, :password, :password_confirmation

  attr_accessor :updating_password

  has_secure_password

  before_save { self.email.downcase! }

  #the controller must set updating_password to FALSE to avoid validation
  def should_update_password?
    updating_password || new_record?    
  end

end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:52:40+00:00Added an answer on June 9, 2026 at 9:52 pm

    So I found the issue, the column client_id is a varchar and mysql allowed this but postgres complained about the different datatypes. Got a mgiration working by doing something like this:

    def up
      rename_column :agents, :client_id, :client_id_old
      add_column :agents, :client_id, :integer
      Agent.reset_column_information
      Agent.find_each { |c| c.update_attribute(:client_id, c.client_id_old) } 
      remove_column :agents, :client_id_old
    end
    

    From this link How do I change column type in Heroku?.


    To avoid the issues when changing datatypes in postgres directly with change_column. Hope this helps someone else

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just changed from Access to mySQL. I have a few tables, called Veranstaltung
I just followed the instructions from this page ( http://www.alexkorn.com/blog/2011/03/getting-php-mysql-running-amazon-ec2/ ) to setup apache
So I just changed the PageControl project from Apple's site here . The issue
Short: how are the keys changed when migrating to HR. Does just the App
I've decided to switch from MySQL to PostgreSQL recently, mostly just to learn a
the underlying database on a project has changed from sql 2005 to MySql 5.1
I have just changed my database connection. I am not used to the PDO
Hi I am using Mysql 5.0.x I have just changed a lot of the
I need store just 10 arrays in my app, which I can change from
I changed the code shown below into ARC compatible. I just changed it as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.