This project is archived and is in readonly mode.
add_column with non-existing type
-
qoobaa
- Tag changed from activerecord, edge, migrations, sqlite to activerecord, edge, migrations, patch, sqlite
The patch solves problem with reversing migrations. We should also consider restricting SQLite3 types to avoid mistakes like above.
-
Pratik
- Assigned user set to Pratik
Shouldn't the real fix be to raise an exception when someone tries to add a column of unknown type ?
Also, the patch is missing tests.
Thanks.
-
qoobaa
AFAIR (it was few months ago) the problem is that SQLite3 doesn't have any strict set of types. Restricting them is the easiest way to fix the problem but it might cause problems when somebody uses strange type names already (don't know what for :-) ).
-
qoobaa
It's also really nasty bug. When you create such strange typed column, there's no easy way to remove it - SQLite3 doesn't support removing columns from tables. My solution was the easiest way to repair my DB.
-
Pratik
- State changed from new to stale
-
bterkuile
I had the same problem, setting a type to :bool for sqlite3 will cause many problems. At least it should be converted to :boolean when a sqlite database is used. The problem is described at: http://kconrails.com/blog/articles/2008/07/15/ruby-on-rails-bool-vs... so I won't add much words to that, except how I resolved the problem.
Since migrations fail when the field has type bool it has to be changed manually. Since I don't like the code to change the column type for sqlite my most elegant solution was in the console:
ActiveRecord::Base.connection.change_column :table_name, :column_name, :boolean, :default => false
