If I change the type of a field in my database via a Ruby 开发者_运维百科on Rails migration, from string to text, will I lose the data in the field?
As far as I remember, SQLite uses the type only for input/output. Internally, everything is stored as text (that's why you can also store text in an int-field if you want). So no, it shouldn't remove any data, because it's only a superficial change.
No guarantees though, it's been a while since since I last worked with SQLite ;-)
This page explains SQLite's typing system nicely.
You will not lose data. String and text in SQLite are the same. There are really only five types in SQLite (NULL, INTEGER, REAL, TEXT, BLOB). Even if your field originally contained binary data (BLOB) and the database type was changed to TEXT the data is unchanged unless you store new data.
精彩评论