Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Alter column length on migration for PostgreSQL db fails due to incorrect syntax #42

Open
connectedtrips opened this issue Apr 23, 2012 · 1 comment

Comments

@connectedtrips
Copy link

My migration looks like:

migration 1, :modify_url_length do
up do
modify_table :hotels do
change_column :url, String, :length => 1..255
end
end

down do
modify_table :hotels do
change_column :url, String, :length => 1..255
end
end
end

However, the migration fails with the error: ERROR: syntax error at or near "VARCHAR".

Seems to me that the SQL being ran is:

ALTER TABLE "hotels" ALTER COLUMN "url" VARCHAR(1 AND 255)

when it needs to be

ALTER TABLE "hotels" ALTER COLUMN "url" TYPE VARCHAR(1 AND 255)

@vitork
Copy link

vitork commented Mar 21, 2014

Same here... This is happening because of the PostgreSQL version.

For version 8.x, the syntax is ALTER COLUMN "column_name" VARCHAR(1 AND 255), and for version 9.x, the syntax is ALTER COLUMN "column_name" TYPE VARCHAR(1 AND 255).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants