Reputation: 27114
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?
Upvotes: 1
Views: 474
Reputation: 6068
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!
Upvotes: 4