Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.1.2
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:KUbuntu 8.04
java version "1.6.0"
OpenJDK Runtime Environment (build 1.6.0-b09)
OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)
Description
When running a migration like:
change_column :flights, :flight_date, :string
I get the error:
ActiveRecord::StatementInvalid: ActiveRecord::ActiveRecordError: near "ALTER": syntax error: ALTER TABLE flights ALTER COLUMN flight_date text(0)
When I try to hack around it by migrating like:
remove_column :flights, :flight_date
add_column :flights, :flight_date, :string
I get:
ActiveRecord::StatementInvalid: ActiveRecord::ActiveRecordError: duplicate column name: flight_date: ALTER TABLE flights ADD flight_date text(10)
Queerer still, this behavior spans across migrations (if I drop a column in one and try to add a new column with the same name I still get the duplicate), so it kind of breaks the whole migrations mechanism.
Hey Ben ! This syntax looks incorrect: "ALTER TABLE flights ALTER COLUMN flight_date text(0)"
Afaik... in order to change the column type, you'd need to use some temp table trickery.
Just looked in active_record/connection_adapters/sqlite_adapter.rb, and that's the technique there as well.
So, looks like the jdbc_sqlite3.rb file needs to be updated a bit in order for change_column to work properly.
You're probably running into the same thing with the "remove then add" approach as well.