1

I have this as a migration :

def up
  connection.execute(%q{
    alter table enterprise_members
    alter column sso_id
    type string using cast(sso_id as string)
  })
end

Where I am simply trying to convert an integer into a string. But when run, it returns :

PG::UndefinedObject: ERROR:  type "string" does not exist
: 
        alter table enterprise_members
        alter column sso_id
        type string using cast(sso_id as string)

Is it because I'm trying to cast it? How do I fix this?

1
  • 1
    Varchar, char, text are database typesm "string" is not. Character data types can be found on the manual Commented May 16, 2014 at 12:54

1 Answer 1

4

You can call string when you are using Rails but if you choose to go the manual way, as you did in your snippet, you have to stick in your DBMS' datatypes

Which brings up another point: try to be DB-agnostic when you can!

Sign up to request clarification or add additional context in comments.

1 Comment

Evidently I couldn't cast the other way and I had to write it manual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.