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

  • Home
  • SEARCH
  • 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 8189167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:10:54+00:00 2026-06-07T03:10:54+00:00

I had a column called prize: create_table :contests do |t| t.text :prize I recently

  • 0

I had a column called “prize”:

create_table :contests do |t|
  t.text :prize

I recently realized that this will always be an integer and I wanted to set a default value:

def change
  change_column :contests, :prize, :integer, :default => 200

This works fine on my local machine, where I am using MySQL DB. However, when I push to my production site (which is hosted on Heroku, which gives me a Postgres DB) I get the following error:

PGError: ERROR:  column "prize" cannot be cast to type "pg_catalog.int4"
: ALTER TABLE "contests" ALTER COLUMN "prize" TYPE integer

In this article: http://www.postgresonline.com/periodical.php?i_id=3 they discuss the use of the USING to solve this problem. But I don’t know how I can do that, and whether this is appropriate for what I’m trying to do.

Any insight into figuring this out would be very much appreciated.

Thanks!
Ringo

  • 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-07T03:10:56+00:00Added an answer on June 7, 2026 at 3:10 am

    First you should use the same DB in both environments to prevent this kind of surprises.

    To run raw sql in migrations see this example http://guides.rubyonrails.org/migrations.html#using-the-up-down-methods

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

Sidebar

Related Questions

I had to add a column on a text file (edit with Notepad++ on
I had a simple table: class test(Base): __tablename__ = 'test' id = Column(Integer, primary_key=True)
Has anyone had this problem? I deleted a column in the table editor and
This question stems off another post I had. (see Search through column in excel
This is a question that I've had forever. As far as I know the
I had added in a new column called ForgotPasswordDate into aspnet_Membership table. When a
Imagine I had an id column and each of its rows contained a number.
I had made three tables. Table1=users .And the column names are userid (auto_increment) and
JPA/Hibernate missing column I am using JPA with Hibernate as the provider. I had
In SharePoint 2003 and 2007, there was a table called AllLists which had a

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.